Browse Source

fix update certs 01.12.23

root 1 year ago
parent
commit
789a790721
1 changed files with 11 additions and 7 deletions
  1. 11 7
      avto4certbot/avto4certbot.sh

+ 11 - 7
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.7";
7
+version="0.3.9";
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
@@ -122,17 +122,19 @@ for ((dmn=0; dmn != ${#domains[@]}; dmn++))
122
      keytime=$(ls -l --time-style=long-iso $path_cert/${dreg[0]}/cert.pem |awk {'print$7'});
122
      keytime=$(ls -l --time-style=long-iso $path_cert/${dreg[0]}/cert.pem |awk {'print$7'});
123
      if [[ "$keydate" = "$rdate" ]] && [[ "$keytime" = "$rtime" ]]; then
123
      if [[ "$keydate" = "$rdate" ]] && [[ "$keytime" = "$rtime" ]]; then
124
          ((valtrue++));
124
          ((valtrue++));
125
+		if [ -d $path_cert/${dreg[0]} ]; then
125
 		cat $path_cert/${dreg[0]}/privkey.pem > $path_ssl/private/privkey_${dreg[0]}.pem;
126
 		cat $path_cert/${dreg[0]}/privkey.pem > $path_ssl/private/privkey_${dreg[0]}.pem;
126
 		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/fullchain_${dreg[0]}.pem;
127
 		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/fullchain_${dreg[0]}.pem;
127
     		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/${dreg[0]}.pem;
128
     		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/${dreg[0]}.pem;
128
     		cat $path_cert/${dreg[0]}/privkey.pem >> $path_ssl/private/${dreg[0]}.pem;
129
     		cat $path_cert/${dreg[0]}/privkey.pem >> $path_ssl/private/${dreg[0]}.pem;
129
 #
130
 #
130
-        cp -f $path_ssl/private/${dreg[0]}.pem $path_ssl/certs/${dreg[0]}.pem
131
-        cd $path_ssl/certs
132
-        chmod 600 ${dreg[0]}.pem
133
-        ln -sf ${dreg[0]}.pem `openssl x509 -noout -hash < ${dreg[0]}.pem`.0
134
-        cd $path_ssl
135
-        echo "$(date) - $sname: update cert for  ${domains[$dmn]}">> $log;
131
+    		cp -f $path_ssl/private/${dreg[0]}.pem $path_ssl/certs/${dreg[0]}.pem
132
+    		cd $path_ssl/certs
133
+    		chmod 600 ${dreg[0]}.pem
134
+    		ln -sf ${dreg[0]}.pem `openssl x509 -noout -hash < ${dreg[0]}.pem`.0
135
+    		cd $path_ssl
136
+    		echo "$(date) - $sname: update cert for  ${domains[$dmn]}">> $log;
137
+		fi
136
       fi
138
       fi
137
 done
139
 done
138
 if [ $valtrue != 0 ];then
140
 if [ $valtrue != 0 ];then
@@ -152,6 +154,7 @@ if [ -d $path_cert ];
152
             do
154
             do
153
                 eval local dreg="(" $(echo -e ${domains[$dmn]}) ")";
155
                 eval local dreg="(" $(echo -e ${domains[$dmn]}) ")";
154
                 ((valtrue++));
156
                 ((valtrue++));
157
+		if [ -d $path_cert/${dreg[0]} ]; then
155
 		cat $path_cert/${dreg[0]}/privkey.pem > $path_ssl/private/privkey_${dreg[0]}.pem;
158
 		cat $path_cert/${dreg[0]}/privkey.pem > $path_ssl/private/privkey_${dreg[0]}.pem;
156
 		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/fullchain_${dreg[0]}.pem;
159
 		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/fullchain_${dreg[0]}.pem;
157
     		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/${dreg[0]}.pem;
160
     		cat $path_cert/${dreg[0]}/fullchain.pem > $path_ssl/private/${dreg[0]}.pem;
@@ -163,6 +166,7 @@ if [ -d $path_cert ];
163
                 ln -sf ${dreg[0]}.pem `openssl x509 -noout -hash < ${dreg[0]}.pem`.0
166
                 ln -sf ${dreg[0]}.pem `openssl x509 -noout -hash < ${dreg[0]}.pem`.0
164
                 cd $path_ssl
167
                 cd $path_ssl
165
                 echo "$(date) - $sname: update certlist for  ${domains[$dmn]}">> $log;
168
                 echo "$(date) - $sname: update certlist for  ${domains[$dmn]}">> $log;
169
+		fi
166
         done
170
         done
167
         if [ $valtrue != 0 ]; then
171
         if [ $valtrue != 0 ]; then
168
                 echo >/etc/ssl/crt-list.txt
172
                 echo >/etc/ssl/crt-list.txt