Update 'Setup-Repo.sh'

This commit is contained in:
Bram Prieshof
2020-09-24 14:58:22 +02:00
parent d325c44175
commit 1db5bfe355

View File

@@ -2,26 +2,30 @@ dist_ver=$(grep --color=never -Po "^VERSION_ID=\K.*" "/etc/os-release")
dist=$(grep --color=never -Po "^ID=\K.*" "/etc/os-release") dist=$(grep --color=never -Po "^ID=\K.*" "/etc/os-release")
dist_name=$(grep -oP '(?<=^VERSION_CODENAME=).+' /etc/os-release | tr -d '"') dist_name=$(grep -oP '(?<=^VERSION_CODENAME=).+' /etc/os-release | tr -d '"')
if [ -z "$osrel" ] ; then
if [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"18.04"* ]]; then osrel=ubu1804;
elif [[ "${dist}" == *"ubuntu"* ]] && [[ "${dist_ver}" == *"20.04"* ]]; then osrel=ubu2004;
elif [[ "${dist}" == *"debian"* ]] && [[ "${dist_ver}" == *"10"* ]]; then osrel=deb10;
elif [[ "${dist}" == *"centos"* ]] && [[ "${dist_ver}" == *"8"* ]]; then osrel=cent8;
else exit;
fi
fi
init () { init () {
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
apt install -y --no-install-recommends software-properties-common gnupg apt install -y --no-install-recommends software-properties-common gnupg
elif [ "$osrel" = "deb10" ]; then elif [ "$osrel" = "deb10" ]; then
apt install -y --no-install-recommends gnupg2 apt-transport-https lsb-release ca-certificates curl apt install -y --no-install-recommends gnupg2 apt-transport-https lsb-release ca-certificates curl
elif [ "$osrel" = "cent8" ]; then elif [ "$osrel" = "cent8" ]; then
dnf install --setopt=install_weak_deps=False --best gnupg dnf install --setopt=install_weak_deps=False --best gnupg
fi fi
} }
mysql () { mysql () {
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] || [ "$osrel" = "deb10" ]; then
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] || [ "$osrel" = "deb10" ]; then
wget -qO - http://mirror.nxdi.nl/resources/mysql/RPM-GPG-KEY-mysql | apt-key add - wget -qO - http://mirror.nxdi.nl/resources/mysql/RPM-GPG-KEY-mysql | apt-key add -
echo "deb http://mirror.nxdi.nl/apt/mysql/"$dist"/ "$dist_name" mysql-8.0" >/etc/apt/sources.list.d/mysql.list echo "deb http://mirror.nxdi.nl/apt/mysql/"$dist"/ "$dist_name" mysql-8.0" >/etc/apt/sources.list.d/mysql.list
elif [ "$osrel" = "cent8" ]; then elif [ "$osrel" = "cent8" ]; then
rpm --import http://mirror.nxdi.nl/resources/mysql/RPM-GPG-KEY-mysql rpm --import http://mirror.nxdi.nl/resources/mysql/RPM-GPG-KEY-mysql
echo "[mysql80-community]" > /etc/yum.repos.d/mysql.repo echo "[mysql80-community]" > /etc/yum.repos.d/mysql.repo
@@ -32,45 +36,36 @@ elif [ "$osrel" = "cent8" ]; then
echo "gpgkey=http://mirror.nxdi.nl/resources/mysql/RPM-GPG-KEY-mysql" >> /etc/yum.repos.d/mysql.repo echo "gpgkey=http://mirror.nxdi.nl/resources/mysql/RPM-GPG-KEY-mysql" >> /etc/yum.repos.d/mysql.repo
dnf -y module disable mysql dnf -y module disable mysql
fi fi
} }
universe () { universe () {
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
add-apt-repository --no-update universe -y -n add-apt-repository --no-update universe -y -n
fi fi
} }
epel () { epel () {
if [ "$osrel" = "cent8" ] ; then
if [ "$osrel" = "cent8" ] ; then
$PKGI https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm $PKGI https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
fi fi
} }
apache () { apache () {
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
add-apt-repository --no-update ppa:ondrej/apache2 -y -n add-apt-repository --no-update ppa:ondrej/apache2 -y -n
elif [ "$osrel" = "deb10" ]; then elif [ "$osrel" = "deb10" ]; then
wget -O /etc/apt/trusted.gpg.d/apache2.gpg https://packages.sury.org/apache2/apt.gpg wget -O /etc/apt/trusted.gpg.d/apache2.gpg https://packages.sury.org/apache2/apt.gpg
echo "deb https://packages.sury.org/apache2/ "$dist_name" main" > /etc/apt/sources.list.d/apache2.list echo "deb https://packages.sury.org/apache2/ "$dist_name" main" > /etc/apt/sources.list.d/apache2.list
fi fi
} }
nginx () { nginx () {
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] || [ "$osrel" = "deb10" ] ; then
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] || [ "$osrel" = "deb10" ] ; then
echo "deb [arch=amd64] http://nginx.org/packages/"$dist" "$dist_name" nginx" > /etc/apt/sources.list.d/nginx.list echo "deb [arch=amd64] http://nginx.org/packages/"$dist" "$dist_name" nginx" > /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add - curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
elif [ "$osrel" = "cent8" ]; then elif [ "$osrel" = "cent8" ]; then
rpm --import https://nginx.org/keys/nginx_signing.key rpm --import https://nginx.org/keys/nginx_signing.key
echo '[nginx-stable]' >> /etc/yum.repos.d/nginx.repo echo '[nginx-stable]' >> /etc/yum.repos.d/nginx.repo
@@ -80,36 +75,28 @@ elif [ "$osrel" = "cent8" ]; then
echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo echo 'enabled=1' >> /etc/yum.repos.d/nginx.repo
echo 'gpgkey=https://nginx.org/keys/nginx_signing.key' >> /etc/yum.repos.d/nginx.repo echo 'gpgkey=https://nginx.org/keys/nginx_signing.key' >> /etc/yum.repos.d/nginx.repo
echo 'module_hotfixes=true' >> /etc/yum.repos.d/nginx.repo echo 'module_hotfixes=true' >> /etc/yum.repos.d/nginx.repo
fi fi
} }
php () { php () {
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
add-apt-repository --no-update ppa:ondrej/php -y -n add-apt-repository --no-update ppa:ondrej/php -y -n
elif [ "$osrel" = "deb10" ]; then elif [ "$osrel" = "deb10" ]; then
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ "$dist_name" main" > /etc/apt/sources.list.d/php.list echo "deb https://packages.sury.org/php/ "$dist_name" main" > /etc/apt/sources.list.d/php.list
fi fi
} }
certbot () { certbot () {
if [ "$osrel" = "ubu1804" ] ; then
if [ "$osrel" = "ubu1804" ] ; then
add-apt-repository --no-update ppa:certbot/certbot -y -n add-apt-repository --no-update ppa:certbot/certbot -y -n
fi fi
} }
redis () { redis () {
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
if [ "$osrel" = "ubu1804" ] || [ "$osrel" = "ubu2004" ] ; then
add-apt-repository --no-update ppa:chris-lea/redis-server -y -n add-apt-repository --no-update ppa:chris-lea/redis-server -y -n
fi fi
} }
$repo $repo