mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-07-10 23:22:44 +02:00
fancy autogenerated help text
This commit is contained in:
+43
-12
@@ -371,7 +371,8 @@ sign_domain() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# --cron / -c
|
# Usage: --cron (-c)
|
||||||
|
# Description: Sign/renew non-existant/changed(TODO)/expiring certificates.
|
||||||
command_cron() {
|
command_cron() {
|
||||||
# Generate certificates for all domains found in domains.txt. Check if existing certificate are about to expire
|
# Generate certificates for all domains found in domains.txt. Check if existing certificate are about to expire
|
||||||
<"${DOMAINS_TXT}" sed 's/^\s*//g;s/\s*$//g' | grep -v '^#' | grep -v '^$' | while read -r line; do
|
<"${DOMAINS_TXT}" sed 's/^\s*//g;s/\s*$//g' | grep -v '^#' | grep -v '^$' | while read -r line; do
|
||||||
@@ -397,7 +398,8 @@ command_cron() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# --sign / -s domain.tld
|
# Usage: --sign (-s) domain.tld
|
||||||
|
# Description: Force-sign specific certificate from domains.txt, even if not yet expiring or changed.
|
||||||
command_sign() {
|
command_sign() {
|
||||||
# Generate certificates for all domains found in domains.txt. Check if existing certificate are about to expire
|
# Generate certificates for all domains found in domains.txt. Check if existing certificate are about to expire
|
||||||
<"${DOMAINS_TXT}" sed 's/^\s*//g;s/\s*$//g' | grep -E "^${1}($|\s)" | head -1 | while read -r line; do
|
<"${DOMAINS_TXT}" sed 's/^\s*//g;s/\s*$//g' | grep -E "^${1}($|\s)" | head -1 | while read -r line; do
|
||||||
@@ -414,7 +416,8 @@ command_sign() {
|
|||||||
done || (echo "No entry for ${1} found in ${DOMAINS_TXT}."; exit 1)
|
done || (echo "No entry for ${1} found in ${DOMAINS_TXT}."; exit 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
# --revoke / -r path/to/cert.pem
|
# Usage: --revoke (-r) path/to/cert.pem
|
||||||
|
# Description: Revoke specified certificate
|
||||||
command_revoke() {
|
command_revoke() {
|
||||||
cert="${1}"
|
cert="${1}"
|
||||||
echo "Revoking ${cert}"
|
echo "Revoking ${cert}"
|
||||||
@@ -431,17 +434,41 @@ command_revoke() {
|
|||||||
mv -f "${cert}" "${cert}-revoked"
|
mv -f "${cert}" "${cert}-revoked"
|
||||||
}
|
}
|
||||||
|
|
||||||
# --help / -h
|
# Usage: --help (-h)
|
||||||
|
# Description: Show help text
|
||||||
command_help() {
|
command_help() {
|
||||||
echo "Usage: ${0} [-h] [[-c|-s|-r] [parameter]] [-p keyfile] [-f configfile]"
|
echo "Usage: ${0} [-h] [command [argument]] [parameter [argument]] [parameter [argument]] ..."
|
||||||
echo
|
echo
|
||||||
echo "Mode:"
|
echo "Default command: cron"
|
||||||
echo " --help (-h) show this help"
|
echo
|
||||||
echo " --cron (-c) (default) cron-mode, renews all nearly expired or non-existing certificates found in domains.txt"
|
(
|
||||||
echo " --sign (-s) domain.tld force-sign a specific certificate using domains.txt entry"
|
echo "Commands:"
|
||||||
echo " --revoke (-r) path/to/cert.pem revoke given certificate file (uses account key by default)"
|
grep -e '# Usage:' -e '# Description:' -e '^command_.*()\s*{' letsencrypt.sh | while read -r usage; read -r description; read -r command; do
|
||||||
echo " --privkey (-p) path/to/key.pem use given private key for specified command (useful for revocation)"
|
if [[ ! "${usage}" =~ Usage ]]; then
|
||||||
echo " --config (-f) path/to/config.sh use given config file"
|
echo "Error generating help text."
|
||||||
|
exit 1
|
||||||
|
elif [[ ! "${description}" =~ Description ]]; then
|
||||||
|
echo "Error generating help text."
|
||||||
|
exit 1
|
||||||
|
elif [[ ! "${command}" =~ ^command_ ]]; then
|
||||||
|
echo "Error generating help text."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf " %s\t%s\n" "${usage##"# Usage: "}" "${description##"# Description: "}"
|
||||||
|
done
|
||||||
|
echo "---"
|
||||||
|
echo "Parameters:"
|
||||||
|
grep -E -e '^\s*# PARAM_Usage:' -e '^\s*# PARAM_Description:' letsencrypt.sh | while read -r usage; read -r description; do
|
||||||
|
if [[ ! "${usage}" =~ Usage ]]; then
|
||||||
|
echo "Error generating help text."
|
||||||
|
exit 1
|
||||||
|
elif [[ ! "${description}" =~ Description ]]; then
|
||||||
|
echo "Error generating help text."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf " %s\t%s\n" "${usage##"# PARAM_Usage: "}" "${description##"# PARAM_Description: "}"
|
||||||
|
done
|
||||||
|
) | column -t -s $'\t' | sed 's/^---$//g'
|
||||||
}
|
}
|
||||||
|
|
||||||
args=""
|
args=""
|
||||||
@@ -508,10 +535,14 @@ while getopts ":hcr:s:f:p:" option; do
|
|||||||
sign_me="${OPTARG}"
|
sign_me="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
f)
|
f)
|
||||||
|
# PARAM_Usage: --config (-f) path/to/config.sh
|
||||||
|
# PARAM_Description: Use specified config file
|
||||||
check_parameters "${OPTARG:-}"
|
check_parameters "${OPTARG:-}"
|
||||||
CONFIG="${OPTARG}"
|
CONFIG="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
|
# PARAM_Usage: --privkey (-p) path/to/key.pem
|
||||||
|
# PARAM_Description: Use specified private key instead of account key (useful for revocation)
|
||||||
check_parameters "${OPTARG:-}"
|
check_parameters "${OPTARG:-}"
|
||||||
USEPRIVATEKEY="${OPTARG}"
|
USEPRIVATEKEY="${OPTARG}"
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user