Преглед на файлове

Shell scripts fix for HTTPS

Andrea Pollastri преди 5 години
родител
ревизия
a0e4003850
променени са 6 файла, в които са добавени 13 реда и са изтрити 31 реда
  1. 2 4
      app/Http/Controllers/ApplicationsController.php
  2. 1 0
      go.sh
  3. 0 4
      storage/app/scripts/hostadd.sh
  4. 0 7
      storage/app/scripts/hostdel.sh
  5. 9 2
      storage/app/scripts/install.sh
  6. 1 14
      storage/app/scripts/ssl.sh

+ 2 - 4
app/Http/Controllers/ApplicationsController.php

@@ -68,7 +68,7 @@ class ApplicationsController extends Controller {
             return redirect('/applications');
         }
         $ssh->setTimeout(360);
-        $response = $ssh->exec('echo '.$server->password.' | sudo -S sudo sh /cipi/host-add.sh -d '.$request->domain.' -u '.$user.' -p '.$pass.' -dbp '.$dbpass.' -b '.$base.' -a '.$appcode);
+        $response = $ssh->exec('echo '.$server->password.' | sudo -S sudo sh /cipi/host-add.sh -u '.$user.' -p '.$pass.' -dbp '.$dbpass.' -b '.$base.' -a '.$appcode);
         $response = explode('###CIPI###', $response);
         if(strpos($response[1], 'Ok') === false) {
             $request->session()->flash('alert-error', 'There was a problem with server scripts.');
@@ -104,12 +104,10 @@ class ApplicationsController extends Controller {
         }
         $ssh->setTimeout(60);
         foreach ($application->aliases as $alias) {
-            $ssh->exec('echo '.$application->server->password.' | sudo -S unlink /etc/cron.d/certbot_renew_'.$alias->domain.'.crontab');
-            $ssh->exec('echo '.$application->server->password.' | sudo -S unlink /cipi/certbot_renew_'.$alias->domain.'.sh');
             $ssh->exec('echo '.$application->server->password.' | sudo -S unlink /etc/nginx/sites-enabled/'.$alias->domain.'.conf');
             $ssh->exec('echo '.$application->server->password.' | sudo -S unlink /etc/nginx/sites-available/'.$alias->domain.'.conf');
         }
-        $ssh->exec('echo '.$application->server->password.' | sudo -S sudo sh /cipi/host-del.sh -u '.$application->username.' -d '.$application->domain);
+        $ssh->exec('echo '.$application->server->password.' | sudo -S sudo sh /cipi/host-del.sh -u '.$application->username);
         $application->delete();
         $request->session()->flash('alert-success', 'Application has been removed!');
         return redirect('/applications');

+ 1 - 0
go.sh

@@ -166,6 +166,7 @@ sudo ufw --force enable
 sudo ufw allow ssh
 sudo ufw allow http
 sudo ufw allow https
+sudo ufw allow "Nginx Full"
 
 echo "Firewall: OK!"
 sleep 3s

+ 0 - 4
storage/app/scripts/hostadd.sh

@@ -8,10 +8,6 @@ USER_SHELL=/bin/bash
 
 while [ -n "$1" ] ; do
     case $1 in
-    -d | --domain )
-        shift
-        DOMAIN=$1
-        ;;
     -u | --user )
         shift
         USER_NAME=$1

+ 0 - 7
storage/app/scripts/hostdel.sh

@@ -9,10 +9,6 @@ while [ -n "$1" ] ; do
         shift
         USER_NAME=$1
         ;;
-    -d | --domain* )
-        shift
-        DOMAIN=$1
-        ;;
     * )
         echo "ERROR: Unknown option: $1"
         exit -1
@@ -30,9 +26,6 @@ DROP DATABASE $USER_NAME;
 DROP USER '$USER_NAME'@'localhost';
 EOF
 
-#SSL & CRON
-sudo unlink /etc/cron.d/certbot_renew_$DOMAIN.crontab
-
 #NGINX
 sudo unlink /etc/nginx/sites-enabled/$USER_NAME.conf
 sudo unlink /etc/nginx/sites-available/$USER_NAME.conf

+ 9 - 2
storage/app/scripts/install.sh

@@ -221,6 +221,7 @@ sudo ufw --force enable
 sudo ufw allow ssh
 sudo ufw allow http
 sudo ufw allow https
+sudo ufw allow "Nginx Full"
 
 echo "Firewall: OK!"
 sleep 3s
@@ -639,8 +640,14 @@ sleep 3s
 sudo apt-get upgrade -y
 sudo apt-get update
 
-crontab -l | { cat; echo "5 4 * * sun DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" dist-upgrade
-* 3 * * sun apt-get -y update"; } | crontab -
+TASK=/etc/cron.d/cipi.crontab
+touch $TASK
+cat > "$TASK" <<EOF
+0 5 * * 7 certbot renew --nginx --non-interactive --post-hook "systemctl restart nginx.service"
+5 4 * * sun DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" dist-upgrade
+* 3 * * sun apt-get -y update"
+EOF
+crontab $TASK
 
 sudo systemctl restart nginx.service
 

+ 1 - 14
storage/app/scripts/ssl.sh

@@ -17,20 +17,7 @@ while [ -n "$1" ] ; do
 done
 
 #SSL CERTIFICATE
-sudo certbot --nginx certonly --noninteractive --nginx --agree-tos --register-unsafely-without-email --expand -d $DOMAIN
-
-CRON=/cipi/certbot_renew_$DOMAIN.sh
-touch $CRON
-cat > "$CRON" <<EOF
-sudo certbot --nginx certonly --noninteractive --nginx --agree-tos --register-unsafely-without-email --expand -d $DOMAIN --post-hook "systemctl restart nginx.service"
-EOF
-TASK=/etc/cron.d/certbot_renew_$DOMAIN.crontab
-touch $TASK
-cat > "$TASK" <<EOF
-0 1 * * * $DOMAIN /cipi/certbot_renew_$DOMAIN.sh
-EOF
-crontab $TASK
-
+sudo certbot --nginx -d $DOMAIN --non-interactive
 sudo systemctl restart nginx.service
 
 #RESUME