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