]> git.ipfire.org Git - thirdparty/dehydrated.git/commitdiff
added hook to run before cron command (fixes #371)
authorLukas Schauer <lukas@schauer.so>
Mon, 10 Jul 2017 19:36:10 +0000 (21:36 +0200)
committerLukas Schauer <lukas@schauer.so>
Mon, 10 Jul 2017 19:36:10 +0000 (21:36 +0200)
dehydrated
docs/examples/hook.sh

index d1224c79b2d56f7b364d03665c9ee1c42ec70793..e9e730eafb9539f7ad0577d8844311a044531cf2 100755 (executable)
@@ -889,6 +889,7 @@ command_account() {
 # Description: Sign/renew non-existent/changed/expiring certificates.
 command_sign_domains() {
   init_system
+  [[ -n "${HOOK}" ]] && "${HOOK}" "startup_hook"
 
   if [[ -n "${PARAM_DOMAIN:-}" ]]; then
     DOMAINS_TXT="$(_mktemp)"
index 32e291bd1da6b6e74a3dcc6babb460a713dd2434..ccf731fc001f491f9e2b5987afd3da21b386f0a3 100755 (executable)
@@ -105,14 +105,21 @@ request_failure() {
     #   The kind of request that was made (GET, POST...)
 }
 
+startup_hook() {
+  # This hook is called before the cron command to do some initial tasks
+  # (e.g. starting a webserver).
+
+  :
+}
+
 exit_hook() {
-  # This hook is called at the end of a dehydrated command and can be used
-  # to do some final (cleanup or other) tasks.
+  # This hook is called at the end of the cron command and can be used to
+  # do some final (cleanup or other) tasks.
 
   :
 }
 
 HANDLER="$1"; shift
-if [[ "${HANDLER}" =~ ^(deploy_challenge|clean_challenge|deploy_cert|unchanged_cert|invalid_challenge|request_failure|exit_hook)$ ]]; then
+if [[ "${HANDLER}" =~ ^(deploy_challenge|clean_challenge|deploy_cert|unchanged_cert|invalid_challenge|request_failure|startup_hook|exit_hook)$ ]]; then
   "$HANDLER" "$@"
 fi