mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-03-23 01:29:07 +01:00
Use case statement instead of many if's
@@ -14,30 +14,24 @@ This hook script uses the nsupdate utility from the bind package to solve dns-01
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
umask 077
|
||||
|
||||
NSUPDATE="nsupdate -k /path/to/Kdnsupdatekey.private"
|
||||
done="no"
|
||||
|
||||
if [[ "$1" = "deploy_challenge" ]]; then
|
||||
printf "update add _acme-challenge.%s. 300 in TXT \"%s\"\n\n" "${2}" "${4}" | $NSUPDATE
|
||||
done="yes"
|
||||
fi
|
||||
|
||||
if [[ "$1" = "clean_challenge" ]]; then
|
||||
printf "update delete _acme-challenge.%s. 300 in TXT \"%s\"\n\n" "${2}" "${4}" | $NSUPDATE
|
||||
done="yes"
|
||||
fi
|
||||
|
||||
if [[ "${1}" = "deploy_cert" ]]; then
|
||||
# do nothing for now
|
||||
done="yes"
|
||||
fi
|
||||
|
||||
if [[ ! "${done}" = "yes" ]]; then
|
||||
echo Unkown hook "${1}"
|
||||
exit 1
|
||||
fi
|
||||
case "$1" in
|
||||
"deploy_challenge")
|
||||
printf "update add _acme-challenge.%s. 300 in TXT \"%s\"\n\n" "${2}" "${4}" | $NSUPDATE
|
||||
;;
|
||||
"clean_challenge")
|
||||
printf "update delete _acme-challenge.%s. 300 in TXT \"%s\"\n\n" "${2}" "${4}" | $NSUPDATE
|
||||
;;
|
||||
"deploy_cert")
|
||||
# do nothing for now
|
||||
;;
|
||||
*)
|
||||
echo Unkown hook "${1}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
```
|
||||
Reference in New Issue
Block a user