@@ -1166,13 +1166,15 @@ function update($event_name, $data) {
11661166 $ bundle_tmp_file = "/etc/letsencrypt/live/ " .$ domain ."/chain.pem " ;
11671167 $ webroot = $ data ['new ' ]['document_root ' ]."/web " ;
11681168
1169+ $ wk_dir_existed = false ;
1170+ if (is_dir ($ webroot . '/.well-known ' )) $ wk_dir_existed = true ;
11691171 //* check if we have already a Let's Encrypt cert
11701172 if (!file_exists ($ crt_tmp_file ) && !file_exists ($ key_tmp_file )) {
11711173 $ app ->log ("Create Let's Encrypt SSL Cert for: $ domain " , LOGLEVEL_DEBUG );
11721174
1173- if (is_dir ($ webroot . "/.well-known/ " )) {
1175+ if (is_dir ($ webroot . "/.well-known/acme-challenge/ " )) {
11741176 $ app ->log ("Remove old challenge directory " , LOGLEVEL_DEBUG );
1175- $ this ->_exec ("rm -rf " . $ webroot . "/.well-known/ " );
1177+ $ this ->_exec ("rm -rf " . $ webroot . "/.well-known/acme-challenge/ " );
11761178 }
11771179
11781180 $ app ->log ("Create challenge directory " , LOGLEVEL_DEBUG );
@@ -1187,7 +1189,12 @@ function update($event_name, $data) {
11871189 if (file_exists ("/root/.local/share/letsencrypt/bin/letsencrypt " )) {
11881190 $ this ->_exec ("/root/.local/share/letsencrypt/bin/letsencrypt auth --text --agree-tos --authenticator webroot --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --email postmaster@ $ domain --domains $ lddomain --webroot-path " . escapeshellarg ($ webroot ));
11891191 }
1190- };
1192+ }
1193+ if ($ wk_dir_existed == false && is_dir ($ webroot . '/.well-known ' )) {
1194+ $ this ->_exec ("rm -rf " . $ webroot . "/.well-known " );
1195+ } elseif (is_dir ($ webroot . "/.well-known/acme-challenge/ " )) {
1196+ $ this ->_exec ("rm -rf " . $ webroot . "/.well-known/acme-challenge/ " );
1197+ }
11911198
11921199 //* check is been correctly created
11931200 if (file_exists ($ crt_tmp_file ) OR file_exists ($ key_tmp_file )) {
0 commit comments