]> git.ipfire.org Git - thirdparty/dehydrated.git/commitdiff
cleanup: also do cleanup if symlink is broken (closes #667)
authorArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Fri, 30 Aug 2019 15:02:56 +0000 (17:02 +0200)
committerLukas Schauer <lukas@schauer.so>
Thu, 10 Dec 2020 13:14:35 +0000 (14:14 +0100)
The cleanup command skips filetypes for which the symlink is broken or
doesn't exist. However, if dehydrated fails, we may end up in exactly
the situation that the symlink doesn't exist (yet). If dehydrated fails
repeatedly, we may end up with a lot of old cert.csr, cert.pem and
privkey.pem files, so we really want to be able to clean them up.

Remove all files if the symlink is broken/missing, instead of skipping
those files.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
dehydrated

index 097c9110693a78c48d397d47513abc8bd7154778..8d277a3430ad76ebe8d0b6239fc7bcd65dbd33e0 100755 (executable)
@@ -1879,11 +1879,13 @@ command_cleanup() {
 
     # Loop over file-types (certificates, keys, signing-requests, ...)
     for filetype in cert.csr cert.pem chain.pem fullchain.pem privkey.pem ocsp.der; do
-      # Skip if symlink is broken
-      [[ -r "${certdir}/${filetype}" ]] || continue
-
-      # Look up current file in use
-      current="$(basename "$(readlink "${certdir}/${filetype}")")"
+      # Delete all if symlink is broken
+      if [[ -r "${certdir}/${filetype}" ]]; then
+        # Look up current file in use
+        current="$(basename "$(readlink "${certdir}/${filetype}")")"
+      else
+        current=""
+      fi
 
       # Split filetype into name and extension
       filebase="$(echo "${filetype}" | cut -d. -f1)"