Browse Source

fix ifs err 20.01.25:17.06

root 2 months ago
parent
commit
4bcc70131b
1 changed files with 10 additions and 10 deletions
  1. 10 10
      avto4certbot.dev/avto4certbot.sh

+ 10 - 10
avto4certbot.dev/avto4certbot.sh

@@ -86,12 +86,12 @@ if [ ! -d $conf_dir ]; then
86 86
 fi
87 87
 
88 88
 ##
89
-if [[ $opt != "nginx" ]] || [[ "$opt" == "apache" ]]; then
89
+if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
90 90
   find $sites_apache/* -maxdepth 0 -type l -printf '%f\n' >$tmp_dir/active_sites.inf 2>/dev/null;
91 91
   get_tools[${#get_tools[@]}]="apache2";
92 92
   service="apache2";
93 93
 fi
94
-if [[ $opt != "apache" ]] || [[ "$opt" == "nginx" ]]; then
94
+if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
95 95
   find $sites_nginx/* -maxdepth 0 -type l -printf '%f\n' >$tmp_dir/active_sites.inf 2>/dev/null;
96 96
   get_tools[${#get_tools[@]}]="nginx";
97 97
   service="nginx";
@@ -129,12 +129,12 @@ function swSites(){
129 129
 if [ "$event_key" = "1" ]; then
130 130
 active_sites=( $(cat $tmp_dir/active_sites.inf) );
131 131
   for ((xd=0; xd != ${#active_sites[@]}; xd++)); do
132
-    if [[ $opt != "nginx" ]] || [[ "$opt" == "apache" ]] && [[ "$opt" != "" ]]; then
132
+    if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
133 133
       if [ -f $sites_apache/${active_sites[$xd]} ]; then
134 134
         rm $sites_apache/${active_sites[$xd]}
135 135
       fi
136 136
     fi
137
-    if [[ $opt != "apache" ]] || [[ "$opt" == "nginx" ]] && [[ "$opt" != "" ]]; then
137
+    if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
138 138
       if [ -f $sites_nginx/${active_sites[$xd]} ]; then
139 139
         rm $sites_nginx/${active_sites[$xd]}
140 140
       fi
@@ -144,21 +144,21 @@ fi
144 144
 ## restore active sites
145 145
 if [ "$event_key" = "0" ]; then
146 146
   # clear tmp configs
147
-  if [[ $opt != "nginx" ]] || [[ "$opt" == "apache" ]] && [[ "$opt" != "" ]]; then
147
+  if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
148 148
     rm $available_apache/*.conf
149 149
   fi
150
-  if [[ $opt != "apache" ]] || [[ "$opt" == "nginx" ]] && [[ "$opt" != "" ]]; then
150
+  if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
151 151
     rm $available_nginx/*.conf
152 152
   fi
153 153
   # restore active links
154 154
   active_sites=( $(cat $tmp_dir/active_sites.inf) );
155 155
   for ((xd=0; xd != ${#active_sites[@]}; xd++)); do
156
-    if [[ $opt != "nginx" ]] || [[ "$opt" == "apache" ]] && [[ "$opt" != "" ]]; then
156
+    if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
157 157
       if [ ! -f $sites_apache/${active_sites[$xd]} ]; then
158 158
         ln -s $available_apache/${active_sites[$xd]} $sites_apache/${active_sites[$xd]}
159 159
       fi
160 160
     fi
161
-    if [[ $opt != "apache" ]] || [[ "$opt" == "nginx" ]] && [[ "$opt" != "" ]]; then
161
+    if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
162 162
       if [ ! -f $sites_nginx/${active_sites[$xd]} ]; then
163 163
         ln -s $available_nginx/${active_sites[$xd]} $sites_apache/${active_sites[$xd]}
164 164
       fi
@@ -237,7 +237,7 @@ for ((xd=0; xd != ${#domains[@]}; xd++)); do
237 237
   site_owner="${site_data[1]}";
238 238
   site_port="${site_data[2]}";
239 239
   ## apache2 config
240
-  if [[ $opt != "nginx" ]] || [[ "$opt" == "apache" ]] && [[ "$opt" != "" ]] ; then
240
+  if [[ "$opt" != "" ]] && [[ $opt != "nginx" ]] && [[ "$opt" == "apache" ]]; then
241 241
     echo >$conf_dir/$site_name.conf;
242 242
     echo -e '<VirtualHost *:'"$site_port"'>' >>$conf_dir/$site_name.conf;
243 243
     echo -e '  ServerName '"$site_name"'' >>$conf_dir/$site_name.conf;
@@ -260,7 +260,7 @@ for ((xd=0; xd != ${#domains[@]}; xd++)); do
260 260
   fi
261 261
 
262 262
   ## nginx config
263
-  if [[ $opt != "apache" ]] || [[ "$opt" == "nginx" ]] && [[ "$opt" != "" ]]; then
263
+  if [[ "$opt" != "" ]] && [[ $opt != "apache" ]] && [[ "$opt" == "nginx" ]]; then
264 264
     echo >$conf_dir/$site_name.conf;
265 265
     echo -e 'server { listen 0.0.0.0:'"$site_port"';' >>$conf_dir/$site_name.conf;
266 266
     echo -e '  server_name '"$site_name"';' >>$conf_dir/$site_name.conf;