Browse Source

add restart services 26.01.25:22.49

root 2 months ago
parent
commit
e2ce98cd94
1 changed files with 26 additions and 17 deletions
  1. 26 17
      dev/avto4certbot.sh

+ 26 - 17
dev/avto4certbot.sh

@@ -1,4 +1,4 @@
1
-#!/bin/bash -x
1
+#!/bin/bash
2
 #
2
 #
3
 # author: Koshuba V.O.
3
 # author: Koshuba V.O.
4
 # license: GPL 2.0
4
 # license: GPL 2.0
@@ -12,7 +12,7 @@ path_script=$( cd -- $( dirname -- "${BASH_SOURCE[0]}" ) &> /dev/null && pwd );
12
 source "$path_script/avto4certbot.conf";
12
 source "$path_script/avto4certbot.conf";
13
 
13
 
14
 # service LAMP
14
 # service LAMP
15
-service="";
15
+web_service="";
16
 
16
 
17
 # new certificate or renewal event
17
 # new certificate or renewal event
18
 event_sw=0;
18
 event_sw=0;
@@ -102,12 +102,12 @@ fi
102
 if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
102
 if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
103
   find $sites_apache/* -maxdepth 0 -type l -printf '%f\n' >$tmp_dir/active_sites.inf 2>/dev/null;
103
   find $sites_apache/* -maxdepth 0 -type l -printf '%f\n' >$tmp_dir/active_sites.inf 2>/dev/null;
104
   get_tools[${#get_tools[@]}]="apache2";
104
   get_tools[${#get_tools[@]}]="apache2";
105
-  service="$apache2_service";
105
+  web_service="$apache2_service";
106
 fi
106
 fi
107
 if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
107
 if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
108
   find $sites_nginx/* -maxdepth 0 -type l -printf '%f\n' >$tmp_dir/active_sites.inf 2>/dev/null;
108
   find $sites_nginx/* -maxdepth 0 -type l -printf '%f\n' >$tmp_dir/active_sites.inf 2>/dev/null;
109
   get_tools[${#get_tools[@]}]="nginx";
109
   get_tools[${#get_tools[@]}]="nginx";
110
-  service="nginx";
110
+  web_service="nginx";
111
 fi
111
 fi
112
 }
112
 }
113
 
113
 
@@ -299,7 +299,16 @@ for ((xd=0; xd != ${#domains[@]}; xd++)); do
299
 done
299
 done
300
 }
300
 }
301
 
301
 
302
-##--@F create configs
302
+##--@F restart services
303
+function updateScs(){
304
+if [[ "${services[@]}" != "" ]] && [[ "${#services[@]}" != "0" ]]; then
305
+  for ((scn=0; scn != ${#services[@]}; scn++)); do
306
+     systemctl restart ${services[$scn]};
307
+  done
308
+fi
309
+}
310
+
311
+##--@F help
303
 function pHelp(){
312
 function pHelp(){
304
 echo "$sname:$version"
313
 echo "$sname:$version"
305
 echo "please input pameters: avto4certbot.sh --create [apache & nginx]| --update [apache & nginx] | --flist [apache & nginx]";
314
 echo "please input pameters: avto4certbot.sh --create [apache & nginx]| --update [apache & nginx] | --flist [apache & nginx]";
@@ -320,16 +329,16 @@ if [ "$opt" != "" ]; then
320
     getInfo;
329
     getInfo;
321
     checkDep;
330
     checkDep;
322
     event_key="1";
331
     event_key="1";
323
-    systemctl stop $service;
332
+    systemctl stop $web_service;
324
     swSites;
333
     swSites;
325
     createConf;
334
     createConf;
326
-    systemctl start $service;
327
-    #createCert;
328
-    #scanSSL;
335
+    systemctl start $web_service;
336
+    createCert;
337
+    scanSSL;
329
     event_key="0";
338
     event_key="0";
330
-    systemctl stop $service;
339
+    systemctl stop $web_service;
331
     swSites;
340
     swSites;
332
-    systemctl start $service;
341
+    systemctl start $web_service;
333
 else
342
 else
334
     pHelp;
343
     pHelp;
335
 fi
344
 fi
@@ -341,16 +350,16 @@ if [ "$opt" != "" ]; then
341
    getInfo;
350
    getInfo;
342
    checkDep;
351
    checkDep;
343
    event_key="1";
352
    event_key="1";
344
-   systemctl stop $service;
353
+   systemctl stop $web_service;
345
    swSites;
354
    swSites;
346
    createConf;
355
    createConf;
347
-   systemctl start $service;
348
-   #certbot -n renew;
349
-   #scanSSL;
356
+   systemctl start $web_service;
357
+   certbot -n renew;
358
+   scanSSL;
350
    event_key="0";
359
    event_key="0";
351
-   systemctl stop $service;
360
+   systemctl stop $web_service;
352
    swSites;
361
    swSites;
353
-   systemctl start $service;
362
+   systemctl start $web_service;
354
 else
363
 else
355
     pHelp;
364
     pHelp;
356
 fi
365
 fi