Fixes for CentOS

This commit is contained in:
2018-01-12 23:48:39 +01:00
parent cf662cb380
commit c3cd1f62f3

View File

@@ -15,63 +15,44 @@ lowercase(){
} }
OS=`lowercase \`uname\`` OS=`lowercase \`uname\``
KERNEL=`uname -r`
MACH=`uname -m`
if [ "$OS" == "windowsnt" ]; then if [ -f /etc/os-release ]; then
OS=windows # freedesktop.org and systemd
elif [ "$OS" == "darwin" ]; then . /etc/os-release
OS=mac OS=`lowercase` $ID_LIKE
else ID=`lowercase` $ID
OS=`uname` VER=$VERSION_ID
if [ "${OS}" = "SunOS" ] ; then elif type lsb_release >/dev/null 2>&1; then
OS=Solaris # linuxbase.org
ARCH=`uname -p` OS=$(lsb_release -si)
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)" VER=$(lsb_release -sr)
elif [ "${OS}" = "AIX" ] ; then elif [ -f /etc/lsb-release ]; then
OSSTR="${OS} `oslevel` (`oslevel -r`)" # For some versions of Debian/Ubuntu without lsb_release command
elif [ "${OS}" = "Linux" ] ; then . /etc/lsb-release
if [ -f /etc/redhat-release ] ; then OS=$DISTRIB_ID
DistroBasedOn='RedHat' VER=$DISTRIB_RELEASE
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DistroBasedOn='SuSe'
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DistroBasedOn='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ]; then elif [ -f /etc/debian_version ]; then
DistroBasedOn='Debian' # Older Debian/Ubuntu/etc.
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'` OS=Debian
PSUEDONAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'` VER=$(cat /etc/debian_version)
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'` elif [ -f /etc/SuSe-release ]; then
fi # Older SuSE/etc.
if [ -f /etc/UnitedLinux-release ] ; then ...
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]" elif [ -f /etc/redhat-release ]; then
fi # Older Red Hat, CentOS, etc.
OS=`lowercase $OS` ...
DistroBasedOn=`lowercase $DistroBasedOn` else
readonly OS # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
readonly DIST OS=$(uname -s)
readonly DistroBasedOn VER=$(uname -r)
readonly PSUEDONAME
readonly REV
readonly KERNEL
readonly MACH
fi fi
fi read -p 'Soll Nginx mit Lets Encrypt eingerichtet werden? (y/n)' ifle
read -p 'Soll Nginx mit Lets Encrypt eingerichtet werden? (Y/n)' ifle if [ "$ifle" == "Y" ] || [ "$ifle" == "y" ]; then
if [ "$ifle" == "Y" ] || [ "$ifle" == "y" ] || ["$ifle" == "" ]; then
git clone https://github.com/certbot/certbot.git /opt/certbot git clone https://github.com/certbot/certbot.git /opt/certbot
if [ "$DIST" == "Fedora" || "$DIST" == "CentOS" ] || [ "$DIST" == "CentOS Linux" ]; then if [ $OS == "fedora" ] || [ $ID == "fedora" ] || [ $OS == "centos" ] || [ $ID == "centos" ]; then
ln -s /opt/certbot/certbot-auto /usr/local/sbin/certbot ln -s /opt/certbot/certbot-auto /usr/local/sbin/certbot
ln -s /opt/certbot/certbot-auto /usr/local/sbin/letsencrypt ln -s /opt/certbot/certbot-auto /usr/local/sbin/letsencrypt
cp make_cert /usr/local/sbin cp make_cert /usr/local/sbin
@@ -85,13 +66,13 @@ if [ "$ifle" == "Y" ] || [ "$ifle" == "y" ] || ["$ifle" == "" ]; then
crontab -l | { cat; echo "@weekly certbot renew --pre-hook 'systemctl stop nginx' --post-hook 'systemctl start nginx' --quiet"; } | crontab - crontab -l | { cat; echo "@weekly certbot renew --pre-hook 'systemctl stop nginx' --post-hook 'systemctl start nginx' --quiet"; } | crontab -
fi fi
if [ "$DIST" == "Fedora" ]; then if [ $OS == "fedora" ] || [ $ID == "fedora" ]; then
dnf install gcc gcc-c++ autoconf automake make perl -y dnf install gcc gcc-c++ autoconf automake make perl -y
elif [ "$DIST" == "Ubuntu" ] || [ "$DistroBasedOn" == "debian" ]; then elif [ $OS == "debian" ] || [ $ID == "ubuntu" ] || [ $ID == "debian" ]; then
apt-get install gcc g++ autoconf automake make perl openssl libssl-dev -y apt-get install gcc g++ autoconf automake make perl openssl libssl-dev -y
elif [ "$DIST" == "CentOS" ] || [ "$DIST" == "CentOS Linux" ]; then elif [ $OS == "centos" ] || [ $ID == "centos" ]; then
yum install gcc gcc-c++ autoconf automake make perl wget -y yum install gcc gcc-c++ autoconf automake make perl wget -y
elif [ "$DistroBasedOn" == "suse" ]; then elif [ $OS == "suse" ] || [ $ID == "opensuse" ]; then
zypper install -y gcc gcc-c++ autoconf automake make perl zypper install -y gcc gcc-c++ autoconf automake make perl
fi fi
@@ -126,7 +107,7 @@ cp nginx.conf /usr/local/nginx/
mkdir -p /usr/local/nginx/snippets mkdir -p /usr/local/nginx/snippets
cp ssl-params.conf /usr/local/nginx/snippets/ cp ssl-params.conf /usr/local/nginx/snippets/
if [ "$DIST" == "Fedora" || "$DIST" == "CentOS" ] || [ "$DIST" == "CentOS Linux" ]; then if [ $OS == "fedora" ] || [ $ID == "fedora" ] || [ $OS == "centos" ] || [ $ID == "centos" ]; then
cp ngensite /usr/local/sbin cp ngensite /usr/local/sbin
chmod +x /usr/local/sbin/ngensite chmod +x /usr/local/sbin/ngensite
else else
@@ -148,7 +129,7 @@ cd /usr/local/nginx
mkdir sites-available mkdir sites-available
mkdir sites-enabled mkdir sites-enabled
if [ "$DIST" == "Fedora" || "$DIST" == "CentOS" ] || [ "$DIST" == "CentOS Linux" ]; then if [ $OS == "fedora" ] || [ $ID == "fedora" ] || [ $OS == "centos" ] || [ $ID == "centos" ]; then
ln -s /usr/local/nginx/nginx /usr/local/sbin/nginx ln -s /usr/local/nginx/nginx /usr/local/sbin/nginx
else else
ln -s /usr/local/nginx/nginx /usr/local/bin/nginx ln -s /usr/local/nginx/nginx /usr/local/bin/nginx