echo "WARNING: No config file found, using default config!"
sleep 2
elif [[ -e "${CONFIG}" ]]; then
- echo "Using config file ${CONFIG}"
+ if [[ ! "${COMMAND}" = "env" ]]; then
+ echo "Using config file ${CONFIG}"
+ fi
BASEDIR="$(dirname "${CONFIG}")"
# shellcheck disable=SC1090
. "${CONFIG}"
fi
set_defaults
+ if [[ "${COMMAND}" = "env" ]]; then
+ return
+ fi
+
# Lockfile handling (prevents concurrent access)
set -o noclobber
if ! { date > "${LOCKFILE}"; } 2>/dev/null; then
register="1"
fi
fi
-
+
# Get public components from private key and calculate thumbprint
pubExponent64="$(printf "%06x" "$(openssl rsa -in "${PRIVATE_KEY}" -noout -text | grep publicExponent | head -1 | cut -d' ' -f2)" | hex2bin | urlbase64)"
pubMod64="$(printf '%s' "$(openssl rsa -in "${PRIVATE_KEY}" -noout -modulus | cut -d'=' -f2)" | hex2bin | urlbase64)"
echo
(
echo "Commands:"
- grep -e '# Usage:' -e '# Description:' -e '^command_.*()\s*{' "${0}" | while read -r usage; read -r description; read -r command; do
+ grep -e '^\s*# Usage:' -e '^\s*# Description:' -e '^command_.*()\s*{' "${0}" | while read -r usage; read -r description; read -r command; do
if [[ ! "${usage}" =~ Usage ]]; then
echo "Error generating help text."
exit 1
) | column -t -s $'\t' | sed 's/^---$//g'
}
+# Usage: --env (-e)
+# Description: Output configuration variables for use in other scripts
+command_env() {
+ echo "# letsencrypt.sh configuration"
+ typeset -p CA LICENSE BASEDIR WELLKNOWN PRIVATE_KEY KEYSIZE OPENSSL_CNF ROOTCERT HOOK RENEW_DAYS PRIVATE_KEY_RENEW CONTACT_EMAIL
+ exit 0
+}
+
args=""
# change long args to short args
# inspired by http://kirk.webfinish.com/?p=45
--revoke) args="${args}-r ";;
--privkey) args="${args}-p ";;
--config) args="${args}-f ";;
+ --env) args="${args}-e ";;
--*)
echo "Unknown parameter detected: ${arg}"
echo
fi
}
-while getopts ":hcr:s:f:p:" option; do
+while getopts ":hcer:s:f:p:" option; do
case "${option}" in
h)
command_help
c)
set_command cron
;;
+ e)
+ set_command env
+ ;;
r)
set_command revoke
check_parameters "${OPTARG:-}"
cron)
command_cron
;;
+ env)
+ command_env
+ ;;
sign)
command_sign ${sign_me}
;;