diff --git a/install.sh b/install.sh index dbe1716..896c7cc 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,8 @@ #!/bin/bash +rm -rf /usr/local/nginx +rm /etc/systemd/system/nginx.service + lowercase(){ echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" } @@ -56,6 +59,17 @@ else fi +read -p 'Soll Nginx mit Lets Encrypt eingerichtet werden? (Y/n)' ifle + +if [ "$ifle" == "Y" ] || [ "$ifle" == "y" ]; then + git clone https://github.com/certbot/certbot.git /opt/certbot + ln -s /opt/certbot/certbot-auto /usr/local/bin/certbot + ln -s /opt/certbot/certbot-auto /usr/local/bin/letsencrypt + cp make_cert /usr/local/bin + chmod +x /usr/local/bin/make_cert + crontab -l | { cat; echo "@weekly certbot renew --pre-hook 'systemctl stop nginx' --post-hook 'systemctl start nginx' --renew-hook 'systemctl reload nginx' --quiet"; } | crontab - +fi + if [ "$DIST" == "Fedora" ]; then dnf install gcc gcc-c++ autoconf automake make perl -y elif [ "$DIST" == "Ubuntu" ] || [ "$DistroBasedOn" == "debian" ]; then @@ -113,6 +127,8 @@ cd /usr/local/nginx mkdir sites-available mkdir sites-enabled +ln -s /usr/local/nginx /usr/local/bin/nginx + echo "" echo "----------------" echo "Installation abgeschlossen!" diff --git a/make_cert b/make_cert new file mode 100644 index 0000000..924b734 --- /dev/null +++ b/make_cert @@ -0,0 +1,7 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + echo "Die Domain darf nicht leer sein!" +else + letsencrypt certonly -d $1 --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx" +fi \ No newline at end of file