|
@@ -208,16 +208,17 @@ sudo systemctl start nginx.service;
|
208
|
208
|
}
|
209
|
209
|
|
210
|
210
|
function createConf(){
|
211
|
|
-if [ ! -d $path_tmp ];
|
212
|
|
- then
|
213
|
|
- mkdir -p $path_tmp;
|
214
|
|
-fi
|
|
211
|
+ if [ ! -d $path_tmp/conf ]; then
|
|
212
|
+ mkdir -p $path_tmp/conf;
|
|
213
|
+ fi
|
215
|
214
|
|
216
|
|
-if [ ! -d $www_root ];
|
217
|
|
- then
|
218
|
|
- mkdir -p $www_root/.well-known/acme-challenge;
|
219
|
|
-chown -R www-data:www-data $www_root;
|
220
|
|
-fi
|
|
215
|
+ if [ ! -d $www_root ]; then
|
|
216
|
+ mkdir -p $www_root/.well-known/acme-challenge;
|
|
217
|
+ chown -R www-data:www-data $www_root;
|
|
218
|
+ fi
|
|
219
|
+
|
|
220
|
+## apache2 config
|
|
221
|
+if [[ $opt != "nginx" ]] || [[ "$opt" == "apache" ]]; then
|
221
|
222
|
echo >$path_tmp/$sitename.conf;
|
222
|
223
|
echo -e 'server { listen 0.0.0.0:'"$siteport"';' >>$path_tmp/$sitename.conf;
|
223
|
224
|
echo -e '\n' >>$path_tmp/$sitename.conf;
|
|
@@ -240,15 +241,35 @@ fi
|
240
|
241
|
echo -e 'error_log /var/log/nginx/err-certbot.log;' >>$path_tmp/$sitename.conf;
|
241
|
242
|
echo -e 'access_log /var/log/nginx/access-certbot.log;' >>$path_tmp/$sitename.conf;
|
242
|
243
|
echo -e '}' >>$path_tmp/$sitename.conf;
|
243
|
|
-ln -s $path_tmp/$sitename.conf $nginx_enable/$sitename.conf
|
244
|
|
-}
|
|
244
|
+ ln -s $path_tmp/$sitename.conf $nginx_enable/$sitename.conf
|
|
245
|
+fi
|
245
|
246
|
|
246
|
|
-function restartService(){
|
247
|
|
-for ((scn=0; scn != ${#set_service[@]}; scn++))
|
248
|
|
- do
|
249
|
|
-/etc/init.d/${set_service[$scn]} restart;
|
250
|
|
-# systemctl restart ${set_services[$scn]};
|
251
|
|
-done
|
|
247
|
+## nginx config
|
|
248
|
+if [[ $opt != "apache" ]] || [[ "$opt" == "nginx" ]]; then
|
|
249
|
+ echo >$path_tmp/$sitename.conf;
|
|
250
|
+ echo -e 'server { listen 0.0.0.0:'"$siteport"';' >>$path_tmp/$sitename.conf;
|
|
251
|
+ echo -e '\n' >>$path_tmp/$sitename.conf;
|
|
252
|
+ echo -e 'server_name '"$sitename"';' >>$path_tmp/$sitename.conf;
|
|
253
|
+ echo -e '\n' >>$path_tmp/$sitename.conf;
|
|
254
|
+ echo -e 'location /.well-known/acme-challenge {' >>$path_tmp/$sitename.conf;
|
|
255
|
+ echo -e ' allow all;' >>$path_tmp/$sitename.conf;
|
|
256
|
+ echo -e ' autoindex off;' >>$path_tmp/$sitename.conf;
|
|
257
|
+ echo -e ' default_type "text/plain";' >>$path_tmp/$sitename.conf;
|
|
258
|
+ echo -e ' root '"$www_root"';' >>$path_tmp/$sitename.conf;
|
|
259
|
+ echo -e '}' >>$path_tmp/$sitename.conf;
|
|
260
|
+ echo -e '\n' >>$path_tmp/$sitename.conf;
|
|
261
|
+ echo -e 'location = /.well-known {' >>$path_tmp/$sitename.conf;
|
|
262
|
+ echo -e ' return 404;' >>$path_tmp/$sitename.conf;
|
|
263
|
+ echo -e '}' >>$path_tmp/$sitename.conf;
|
|
264
|
+ echo -e '\n' >>$path_tmp/$sitename.conf;
|
|
265
|
+ echo -e 'error_page 404 /404.html;' >>$path_tmp/$sitename.conf;
|
|
266
|
+ echo -e 'error_page 500 502 503 504 /50x.html;' >>$path_tmp/$sitename.conf;
|
|
267
|
+ echo -e '\n' >>$path_tmp/$sitename.conf;
|
|
268
|
+ echo -e 'error_log /var/log/nginx/err-certbot.log;' >>$path_tmp/$sitename.conf;
|
|
269
|
+ echo -e 'access_log /var/log/nginx/access-certbot.log;' >>$path_tmp/$sitename.conf;
|
|
270
|
+ echo -e '}' >>$path_tmp/$sitename.conf;
|
|
271
|
+ ln -s $path_tmp/$sitename.conf $nginx_enable/$sitename.conf
|
|
272
|
+fi
|
252
|
273
|
}
|
253
|
274
|
|
254
|
275
|
case "$cmd" in
|