Browse Source

fix safe links sites-enabled 12.03.23

root 2 years ago
parent
commit
55e7dbb04a
1 changed files with 16 additions and 4 deletions
  1. 16 4
      avto4certbot/avto4certbot.sh

+ 16 - 4
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.1";
7
+version="0.3.2";
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
@@ -48,7 +48,8 @@ opt=$2;
48
 #-list enable sites
48
 #-list enable sites
49
 scan_list=();
49
 scan_list=();
50
 #
50
 #
51
-
51
+eval enable_www="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n') ")";
52
+#
52
 #--@F Check the program dependency
53
 #--@F Check the program dependency
53
 function checkDep() {
54
 function checkDep() {
54
     # - msg debug
55
     # - msg debug
@@ -166,8 +167,8 @@ fi
166
 
167
 
167
 function downSite(){
168
 function downSite(){
168
 sudo systemctl stop nginx.service;
169
 sudo systemctl stop nginx.service;
169
-
170
 eval list_www="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n') ")";
170
 eval list_www="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n') ")";
171
+
171
 if [ ${#list_www[@]} != 0 ]; then
172
 if [ ${#list_www[@]} != 0 ]; then
172
 for ((dwx=0; dwx != ${#list_www[@]}; dwx++))
173
 for ((dwx=0; dwx != ${#list_www[@]}; dwx++))
173
     do
174
     do
@@ -193,6 +194,14 @@ done
193
 sudo systemctl start nginx.service;
194
 sudo systemctl start nginx.service;
194
 }
195
 }
195
 
196
 
197
+function restoreSite() {
198
+sudo systemctl stop nginx.service;
199
+for ((dwx=0; dwx != ${#enable_www[@]}; dwx++))
200
+    do
201
+	ln -s $nginx_available/${enable_www[dwx]} $nginx_enable/${enable_www[dwx]};
202
+done
203
+sudo systemctl start nginx.service;
204
+}
196
 
205
 
197
 function createConf(){
206
 function createConf(){
198
 if [ ! -d $path_tmp ];
207
 if [ ! -d $path_tmp ];
@@ -251,6 +260,8 @@ toSSL;
251
 downSite;
260
 downSite;
252
 if [ "$opt" == "mail" ]; then
261
 if [ "$opt" == "mail" ]; then
253
 restartMail;
262
 restartMail;
263
+else
264
+restoreSite;
254
 fi
265
 fi
255
 
266
 
256
 ;;
267
 ;;
@@ -265,6 +276,8 @@ toSSL;
265
 downSite;
276
 downSite;
266
 if [ "$opt" == "mail" ]; then
277
 if [ "$opt" == "mail" ]; then
267
 restartMail;
278
 restartMail;
279
+else
280
+restoreSite;
268
 fi
281
 fi
269
 
282
 
270
 
283
 
@@ -277,7 +290,6 @@ if [ "$opt" == "mail" ]; then
277
 restartMail;
290
 restartMail;
278
 fi
291
 fi
279
 
292
 
280
-
281
 ;;
293
 ;;
282
 
294
 
283
 ## start defaults
295
 ## start defaults