Browse Source

fix update cert sites & restore links 16.05.24:18.47

root 6 months ago
parent
commit
590fa07dac
1 changed files with 14 additions and 13 deletions
  1. 14 13
      avto4certbot/avto4certbot.sh

+ 14 - 13
avto4certbot/avto4certbot.sh

@@ -4,14 +4,14 @@
4 4
 # license: GPL 2.0
5 5
 # create 2022
6 6
 #
7
-version="0.3.9";
7
+version="0.4.1";
8 8
 sname="avto4certbot";
9 9
 # необходимы для работы: nginx,certbot (и если почтовый сервер то сервисы в restartMail)
10 10
 # create new cert or update
11 11
 path_ssl="/etc/ssl";
12 12
 path_cert="/etc/letsencrypt/live";
13 13
 # script path
14
-path_script="$(dirname $(readlink --canonicalize-existing "$0"))";
14
+path_script=$( cd -- $( dirname -- "${BASH_SOURCE[0]}" ) &> /dev/null && pwd );
15 15
 source "$path_script/avto4certbot.conf";
16 16
 
17 17
 ## - nginx
@@ -20,15 +20,8 @@ nginx_available="/etc/nginx/sites-available";
20 20
 
21 21
 ## - mail service or others
22 22
 set_service=( 
23
-  #"dbmail" 
24
-  #"opendkim" 
25
-  #"clamav-daemon" 
26
-  #"clamav-freshclam" 
27
-  #"clamsmtp" 
28
-  #"postfix" 
29
-  #"stunnel4" 
30
-  #"saslauthd" 
31
-  #"spamassassin"
23
+  #"postfix"
24
+  #"dbmail"
32 25
 );
33 26
 
34 27
 ##--@S static values
@@ -184,7 +177,7 @@ fi
184 177
 
185 178
 function downSite(){
186 179
 sudo systemctl stop nginx.service;
187
-eval list_www="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n') ")";
180
+eval list_www="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n' 2>/dev/null) ")";
188 181
 
189 182
 if [ ${#list_www[@]} != 0 ]; then
190 183
 for ((dwx=0; dwx != ${#list_www[@]}; dwx++))
@@ -196,7 +189,7 @@ fi
196 189
 
197 190
 function upSite(){
198 191
 sudo systemctl stop nginx.service;
199
-eval cert_bot="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n') ")";
192
+eval cert_bot="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n' 2>/dev/null) ")";
200 193
 for ((cr=0; cr != ${#cert_bot[@]}; cr++))
201 194
     do
202 195
       rm $nginx_enable/${cert_bot[cr]};
@@ -213,6 +206,14 @@ sudo systemctl start nginx.service;
213 206
 
214 207
 function restoreSite() {
215 208
 sudo systemctl stop nginx.service;
209
+eval list_www="(" $(find $nginx_enable/* -maxdepth 0 -type l -printf '%f\n' 2>/dev/null) ")";
210
+
211
+if [ ${#list_www[@]} != 0 ]; then
212
+for ((dwx=0; dwx != ${#list_www[@]}; dwx++))
213
+    do
214
+      rm $nginx_enable/${list_www[dwx]};
215
+done
216
+fi
216 217
 for ((dwx=0; dwx != ${#enable_www[@]}; dwx++))
217 218
     do
218 219
 	ln -s $nginx_available/${enable_www[dwx]} $nginx_enable/${enable_www[dwx]};