Browse Source

fix update services 27.11.24:03.06

root 1 year ago
parent
commit
d1e8696b34
1 changed files with 21 additions and 21 deletions
  1. 21 21
      avto4certbot/avto4certbot.sh

+ 21 - 21
avto4certbot/avto4certbot.sh

@@ -4,7 +4,7 @@
4
 # license: GPL 2.0
4
 # license: GPL 2.0
5
 # create 2022
5
 # create 2022
6
 #
6
 #
7
-version="0.3.3";
7
+version="0.3.5";
8
 sname="avto4certbot";
8
 sname="avto4certbot";
9
 # необходимы для работы: nginx,certbot (и если почтовый сервер то сервисы в restartMail)
9
 # необходимы для работы: nginx,certbot (и если почтовый сервер то сервисы в restartMail)
10
 # create new cert or update
10
 # create new cert or update
@@ -17,13 +17,18 @@ source "$path_script/avto4certbot.conf";
17
 ## - nginx
17
 ## - nginx
18
 nginx_enable="/etc/nginx/sites-enabled";
18
 nginx_enable="/etc/nginx/sites-enabled";
19
 nginx_available="/etc/nginx/sites-available";
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
 ##--@S static values
34
 ##--@S static values
@@ -49,8 +54,9 @@ opt=$2;
49
 #-list enable sites
54
 #-list enable sites
50
 scan_list=();
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
 #--@F Check the program dependency
60
 #--@F Check the program dependency
55
 function checkDep() {
61
 function checkDep() {
56
     # - msg debug
62
     # - msg debug
@@ -105,8 +111,7 @@ for ((dmn=0; dmn != ${#domains[@]}; dmn++))
105
     eval local dreg="(" $(echo -e ${domains[$dmn]}) ")";
111
     eval local dreg="(" $(echo -e ${domains[$dmn]}) ")";
106
      keydate=$(ls -l --time-style=long-iso $path_cert/${dreg[0]}/cert.pem |awk {'print$6'});
112
      keydate=$(ls -l --time-style=long-iso $path_cert/${dreg[0]}/cert.pem |awk {'print$6'});
107
      keytime=$(ls -l --time-style=long-iso $path_cert/${dreg[0]}/cert.pem |awk {'print$7'});
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
          ((valtrue++));
115
          ((valtrue++));
111
 		cat $path_cert/${dreg[0]}/privkey.pem > $path_ssl/private/privkey_${dreg[0]}.pem;
116
 		cat $path_cert/${dreg[0]}/privkey.pem > $path_ssl/private/privkey_${dreg[0]}.pem;
112
 		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/fullchain_${dreg[0]}.pem;
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
         echo "$(date) - $sname: update cert for  ${domains[$dmn]}">> $log;
126
         echo "$(date) - $sname: update cert for  ${domains[$dmn]}">> $log;
122
       fi
127
       fi
123
 done
128
 done
124
-if [ $valtrue != 0 ];
125
-   then
129
+if [ $valtrue != 0 ];then
126
      :>/etc/ssl/crt-list.txt
130
      :>/etc/ssl/crt-list.txt
127
         for ((icrt=0; icrt != ${#domains[@]}; icrt++))
131
         for ((icrt=0; icrt != ${#domains[@]}; icrt++))
128
          do
132
          do
@@ -151,8 +155,7 @@ if [ -d $path_cert ];
151
                 cd $path_ssl
155
                 cd $path_ssl
152
                 echo "$(date) - $sname: update certlist for  ${domains[$dmn]}">> $log;
156
                 echo "$(date) - $sname: update certlist for  ${domains[$dmn]}">> $log;
153
         done
157
         done
154
-        if [ $valtrue != 0 ];
155
-            then
158
+        if [ $valtrue != 0 ]; then
156
                 echo >/etc/ssl/crt-list.txt
159
                 echo >/etc/ssl/crt-list.txt
157
             for ((icrt=0; icrt != ${#domains[@]}; icrt++))
160
             for ((icrt=0; icrt != ${#domains[@]}; icrt++))
158
                 do
161
                 do
@@ -248,7 +251,6 @@ for ((scn=0; scn != ${#set_service[@]}; scn++))
248
 done
251
 done
249
 }
252
 }
250
 
253
 
251
-
252
 case "$cmd" in
254
 case "$cmd" in
253
 
255
 
254
 ## create cert
256
 ## create cert
@@ -273,15 +275,13 @@ fi
273
 downSite;
275
 downSite;
274
 upSite;
276
 upSite;
275
 renew;
277
 renew;
276
-toSSL;
277
 downSite;
278
 downSite;
278
-if [ "$opt" == "srv" ]; then
279
-restartService;
279
+if [[ "$opt" == "srv" ]] && [[ $valtrue != 0 ]]; then
280
+ restartService;
280
 else
281
 else
281
-restoreSite;
282
+ restoreSite;
282
 fi
283
 fi
283
 
284
 
284
-
285
 ;;
285
 ;;
286
 
286
 
287
 ## update cert force
287
 ## update cert force