Skip to content

Commit

Permalink
[fix] minor release - adds failsafe check before foreach loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault François committed Sep 18, 2020
1 parent b775daf commit 8d75995
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
alternc-nginx-ssl (3.3.4) oldstable; urgency=low

* adds a failsafe check before starting loop

-- Thibault Francois <[email protected]> Wed, 16 Sep 2020 11:11:00 +0200

alternc-nginx-ssl (3.3.3) oldstable; urgency=low

* fix the nginx template to ignore acme-challenge only, not all .well-known (fixes nextcloud caldav discovery for iOS)
Expand Down
34 changes: 18 additions & 16 deletions update_nginx-ssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -288,23 +288,25 @@ while (($c=readdir($d))!==false) {
}
closedir($d);
// compare that with the status list (both ways)
foreach($status["uninstall"] as $fqdn=>$ts) {
if (!in_array($fqdn,$badlist)) {
unset($status["uninstall"][$fqdn]);
}
}
foreach($badlist as $fqdn) {
if (!isset($status["uninstall"][$fqdn])) {
$status["uninstall"][$fqdn]=time();
} else {
// not new, therefore may be here since >2day ?
if ($status["uninstall"][$fqdn]<(time()-86400*2)) {
if (array_key_exists("uninstall", $status)) {
foreach($status["uninstall"] as $fqdn=>$ts) {
if (!in_array($fqdn,$badlist)) {
unset($status["uninstall"][$fqdn]);
// deleted since 2 days or more in a continuous way, let's delete cert & nginx conf
$reload=true;
unlink($nginxdir."/".$fqdn.".alternc.conf");
exec("rm -rf ".escapeshellarg($letsencryptdir."/live/$fqdn")." ".escapeshellarg($letsencryptdir."/archive/$fqdn")." ".escapeshellarg($letsencryptdir."/renewal/".$fqdn.".conf"));
syslog(LOG_INFO,"removed nginx conf & letsencrypt certificate for $fqdn");
}
}
foreach($badlist as $fqdn) {
if (!isset($status["uninstall"][$fqdn])) {
$status["uninstall"][$fqdn]=time();
} else {
// not new, therefore may be here since >2day ?
if ($status["uninstall"][$fqdn]<(time()-86400*2)) {
unset($status["uninstall"][$fqdn]);
// deleted since 2 days or more in a continuous way, let's delete cert & nginx conf
$reload=true;
unlink($nginxdir."/".$fqdn.".alternc.conf");
exec("rm -rf ".escapeshellarg($letsencryptdir."/live/$fqdn")." ".escapeshellarg($letsencryptdir."/archive/$fqdn")." ".escapeshellarg($letsencryptdir."/renewal/".$fqdn.".conf"));
syslog(LOG_INFO,"removed nginx conf & letsencrypt certificate for $fqdn");
}
}
}
}
Expand Down

0 comments on commit 8d75995

Please sign in to comment.