Просмотр исходного кода

fix update services 27.11.24:03.06

root 1 год назад
Родитель
Сommit
d1e8696b34
1 измененных файлов с 21 добавлено и 21 удалено
  1. 21 21
      avto4certbot/avto4certbot.sh

+ 21 - 21
avto4certbot/avto4certbot.sh

@@ -4,7 +4,7 @@
4 4
 # license: GPL 2.0
5 5
 # create 2022
6 6
 #
7
-version="0.3.3";
7
+version="0.3.5";
8 8
 sname="avto4certbot";
9 9
 # необходимы для работы: nginx,certbot (и если почтовый сервер то сервисы в restartMail)
10 10
 # create new cert or update
@@ -17,13 +17,18 @@ source "$path_script/avto4certbot.conf";
17 17
 ## - nginx
18 18
 nginx_enable="/etc/nginx/sites-enabled";
19 19
 nginx_available="/etc/nginx/sites-available";
20
-## - mail services
21
-set_service=(
22
-    ##"gogs"
23
-    "dbmail"
24
-    "postfix"
25
-    "stunnel4"
26
-    "rspamd"
20
+
21
+## - mail service or others
22
+set_service=( 
23
+  #"dbmail" 
24
+  #"opendkim" 
25
+  #"clamav-daemon" 
26
+  #"clamav-freshclam" 
27
+  #"clamsmtp" 
28
+  #"postfix" 
29
+  #"stunnel4" 
30
+  #"saslauthd" 
31
+  #"spamassassin"
27 32
 );
28 33
 
29 34
 ##--@S static values
@@ -49,8 +54,9 @@ opt=$2;
49 54
 #-list enable sites
50 55
 scan_list=();
51 56
 #
52
-eval enable_www="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n') ")";
57
+eval enable_www="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n' 2>/dev/null) ")";
53 58
 #
59
+
54 60
 #--@F Check the program dependency
55 61
 function checkDep() {
56 62
     # - msg debug
@@ -105,8 +111,7 @@ for ((dmn=0; dmn != ${#domains[@]}; dmn++))
105 111
     eval local dreg="(" $(echo -e ${domains[$dmn]}) ")";
106 112
      keydate=$(ls -l --time-style=long-iso $path_cert/${dreg[0]}/cert.pem |awk {'print$6'});
107 113
      keytime=$(ls -l --time-style=long-iso $path_cert/${dreg[0]}/cert.pem |awk {'print$7'});
108
-     if [ "$keydate" = "$rdate" ] && [ "$keytime" = "$rtime" ];
109
-        then
114
+     if [[ "$keydate" = "$rdate" ]] && [[ "$keytime" = "$rtime" ]]; then
110 115
          ((valtrue++));
111 116
 		cat $path_cert/${dreg[0]}/privkey.pem > $path_ssl/private/privkey_${dreg[0]}.pem;
112 117
 		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/fullchain_${dreg[0]}.pem;
@@ -121,8 +126,7 @@ for ((dmn=0; dmn != ${#domains[@]}; dmn++))
121 126
         echo "$(date) - $sname: update cert for  ${domains[$dmn]}">> $log;
122 127
       fi
123 128
 done
124
-if [ $valtrue != 0 ];
125
-   then
129
+if [ $valtrue != 0 ];then
126 130
      :>/etc/ssl/crt-list.txt
127 131
         for ((icrt=0; icrt != ${#domains[@]}; icrt++))
128 132
          do
@@ -151,8 +155,7 @@ if [ -d $path_cert ];
151 155
                 cd $path_ssl
152 156
                 echo "$(date) - $sname: update certlist for  ${domains[$dmn]}">> $log;
153 157
         done
154
-        if [ $valtrue != 0 ];
155
-            then
158
+        if [ $valtrue != 0 ]; then
156 159
                 echo >/etc/ssl/crt-list.txt
157 160
             for ((icrt=0; icrt != ${#domains[@]}; icrt++))
158 161
                 do
@@ -248,7 +251,6 @@ for ((scn=0; scn != ${#set_service[@]}; scn++))
248 251
 done
249 252
 }
250 253
 
251
-
252 254
 case "$cmd" in
253 255
 
254 256
 ## create cert
@@ -273,15 +275,13 @@ fi
273 275
 downSite;
274 276
 upSite;
275 277
 renew;
276
-toSSL;
277 278
 downSite;
278
-if [ "$opt" == "srv" ]; then
279
-restartService;
279
+if [[ "$opt" == "srv" ]] && [[ $valtrue != 0 ]]; then
280
+ restartService;
280 281
 else
281
-restoreSite;
282
+ restoreSite;
282 283
 fi
283 284
 
284
-
285 285
 ;;
286 286
 
287 287
 ## update cert force