diff options
author | Christian Hesse <mail@eworm.de> | 2020-02-26 14:19:54 +0100 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2020-02-26 14:19:54 +0100 |
commit | ceaa83b83edb069ecf1cca181ec461519f0cc020 (patch) | |
tree | 1c48dd40fcdc3cd59a184a81acf8e6161e98d159 /check-certificates | |
parent | 6036edb506a7101d95eb293d0509b4ff178d7191 (diff) |
global-functions: merge $LogAnd{Error,Put} to $LogPrintExit ...
... and fix logging.
Logging with severity from variable (:log $severity ...) is not
possible, this is considered a syntax error. Also the 'workaround' with
parsing code failed with missing message in log.
The reliable code is a lot longer, so merge the two functions to save a
lot of duplicate code.
Diffstat (limited to 'check-certificates')
-rw-r--r-- | check-certificates | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/check-certificates b/check-certificates index 56e9537..d94c330 100644 --- a/check-certificates +++ b/check-certificates @@ -14,8 +14,7 @@ :global TimeIsSync; :global UrlEncode; :global WaitForFile; -:global LogAndError; -:global LogAndPut; +:global LogPrintExit; :local FormatExpire do={ :global CharacterReplace; @@ -23,7 +22,7 @@ } :if ($TimeIsSync = false) do={ - $LogAndError warning "Time is not yet synchronized."; + $LogPrintExit warning "Time is not yet synchronized." true; } :foreach Cert in=[ / certificate find where !revoked !ca expires-after<3w ] do={ @@ -31,7 +30,7 @@ :do { :if ([ :len $CertRenewUrl ] = 0) do={ - $LogAndError warning "No CertRenewUrl given."; + $LogPrintExit warning "No CertRenewUrl given." true; } :foreach Type in={ ".pem"; ".p12" } do={ @@ -86,7 +85,7 @@ "Issuer: " . ([ $ParseKeyValueStore ($CertNewVal->"issuer") ]->"CN") . "\n" . \ "Validity: " . ($CertNewVal->"invalid-before") . " to " . ($CertNewVal->"invalid-after") . "\n" . \ "Expires in: " . [ $FormatExpire ($CertNewVal->"expires-after") ]) "" "true"; - $LogAndPut info ("The certificate " . ($CertVal->"name") . " has been renewed."); + $LogPrintExit info ("The certificate " . ($CertVal->"name") . " has been renewed.") false; } on-error={ :log debug ("Could not renew certificate " . ($CertVal->"name") . "."); } @@ -110,6 +109,6 @@ "Issuer: " . ($CertVal->"ca") . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\n" . \ "Validity: " . ($CertVal->"invalid-before") . " to " . ($CertVal->"invalid-after") . "\n" . \ "Expires in: " . $ExpiresAfter); - $LogAndPut warning ("The certificate " . ($CertVal->"name") . " " . $State . \ - ", it is invalid after " . ($CertVal->"invalid-after") . "."); + $LogPrintExit warning ("The certificate " . ($CertVal->"name") . " " . $State . \ + ", it is invalid after " . ($CertVal->"invalid-after") . ".") false; } |