From ef6adba1a6e8b5cb6829a362e16500747b9d2c7a Mon Sep 17 00:00:00 2001
From: David Kilias <david.kilias@gmail.com>
Date: Thu, 11 Feb 2021 23:20:48 +0100
Subject: [PATCH] add default values "" for hook scripts

---
 roles/dehydrated-domains/templates/hook.sh.j2 | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/roles/dehydrated-domains/templates/hook.sh.j2 b/roles/dehydrated-domains/templates/hook.sh.j2
index 69b92d6..ebd8bbd 100644
--- a/roles/dehydrated-domains/templates/hook.sh.j2
+++ b/roles/dehydrated-domains/templates/hook.sh.j2
@@ -25,7 +25,7 @@ deploy_challenge() {
 
     # Simple example: Use nsupdate with local named
     # printf 'server 127.0.0.1\nupdate add _acme-challenge.%s 300 IN TXT "%s"\nsend\n' "${DOMAIN}" "${TOKEN_VALUE}" | nsupdate -k /var/run/named/session.key
-    {{ item.deploy_challenge_hook }}
+    {{ item.deploy_challenge_hook|default("") }}
 }
 
 clean_challenge() {
@@ -39,7 +39,7 @@ clean_challenge() {
 
     # Simple example: Use nsupdate with local named
     # printf 'server 127.0.0.1\nupdate delete _acme-challenge.%s TXT "%s"\nsend\n' "${DOMAIN}" "${TOKEN_VALUE}" | nsupdate -k /var/run/named/session.key
-    {{ item.clean_challenge_hook }}
+    {{ item.clean_challenge_hook|default("") }}
 }
 
 sync_cert() {
@@ -66,7 +66,7 @@ sync_cert() {
 
     # Simple example: sync the files before symlinking them
     # sync "${KEYFILE}" "${CERTFILE}" "${FULLCHAINFILE}" "${CHAINFILE}" "${REQUESTFILE}"
-    {{ item.sync_cert_hook }}
+    {{ item.sync_cert_hook|default("") }}
 }
 
 deploy_cert() {
@@ -94,7 +94,7 @@ deploy_cert() {
     # Simple example: Copy file to nginx config
     # cp "${KEYFILE}" "${FULLCHAINFILE}" /etc/nginx/ssl/; chown -R nginx: /etc/nginx/ssl
     # systemctl reload nginx
-    {{ item.deploy_cert_hook }}
+    {{ item.deploy_cert_hook|default("") }}
 }
 
 deploy_ocsp() {
@@ -116,7 +116,7 @@ deploy_ocsp() {
     # Simple example: Copy file to nginx config
     # cp "${OCSPFILE}" /etc/nginx/ssl/; chown -R nginx: /etc/nginx/ssl
     # systemctl reload nginx
-    {{ item.deploy_ocsp_hook }}
+    {{ item.deploy_ocsp_hook|default("") }}
 }
 
 
@@ -138,7 +138,7 @@ unchanged_cert() {
     #   The path of the file containing the full certificate chain.
     # - CHAINFILE
     #   The path of the file containing the intermediate certificate(s).
-    {{ item.unchanged_cert_hook }}
+    {{ item.unchanged_cert_hook|default("") }}
 }
 
 invalid_challenge() {
@@ -156,7 +156,7 @@ invalid_challenge() {
 
     # Simple example: Send mail to root
     # printf "Subject: Validation of ${DOMAIN} failed!\n\nOh noez!" | sendmail root
-    {{ item.invalid_challenge_hook }}
+    {{ item.invalid_challenge_hook|default("") }}
 }
 
 request_failure() {
@@ -179,7 +179,7 @@ request_failure() {
 
     # Simple example: Send mail to root
     # printf "Subject: HTTP request failed failed!\n\nA http request failed with status ${STATUSCODE}!" | sendmail root
-    {{ item.request_failure_hook }}
+    {{ item.request_failure_hook|default("") }}
 }
 
 generate_csr() {
@@ -205,14 +205,14 @@ generate_csr() {
     # if [ -e "${CERTDIR}/pre-generated.csr" ]; then
     #   cat "${CERTDIR}/pre-generated.csr"
     # fi
-    {{ item.startup_hook }}
+    {{ item.startup_hook|default("") }}
 
 }
 
 startup_hook() {
   # This hook is called before the cron command to do some initial tasks
   # (e.g. starting a webserver).
-  {{ item.startup_hook }}
+  {{ item.startup_hook|default("") }}
   :
 }
 
@@ -224,7 +224,7 @@ exit_hook() {
   # Parameters:
   # - ERROR
   #   Contains error message if dehydrated exits with error
-  {{ item.exit_hook }}
+  {{ item.exit_hook|default("") }}
 }
 
 HANDLER="$1"; shift