Commit 1ab6a436 authored by Lukas Schauer's avatar Lukas Schauer

allow export of config variables for use in other scripts

parent 5120dfb5
......@@ -52,7 +52,9 @@ init_system() {
echo "WARNING: No config file found, using default config!"
sleep 2
elif [[ -e "${CONFIG}" ]]; then
if [[ ! "${COMMAND}" = "env" ]]; then
echo "Using config file ${CONFIG}"
fi
BASEDIR="$(dirname "${CONFIG}")"
# shellcheck disable=SC1090
. "${CONFIG}"
......@@ -71,6 +73,10 @@ init_system() {
fi
set_defaults
if [[ "${COMMAND}" = "env" ]]; then
return
fi
# Lockfile handling (prevents concurrent access)
set -o noclobber
if ! { date > "${LOCKFILE}"; } 2>/dev/null; then
......@@ -462,7 +468,7 @@ command_help() {
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
......@@ -490,6 +496,14 @@ command_help() {
) | 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
......@@ -501,6 +515,7 @@ for arg; do
--revoke) args="${args}-r ";;
--privkey) args="${args}-p ";;
--config) args="${args}-f ";;
--env) args="${args}-e ";;
--*)
echo "Unknown parameter detected: ${arg}"
echo
......@@ -534,7 +549,7 @@ check_parameters() {
fi
}
while getopts ":hcr:s:f:p:" option; do
while getopts ":hcer:s:f:p:" option; do
case "${option}" in
h)
command_help
......@@ -543,6 +558,9 @@ while getopts ":hcr:s:f:p:" option; do
c)
set_command cron
;;
e)
set_command env
;;
r)
set_command revoke
check_parameters "${OPTARG:-}"
......@@ -584,6 +602,9 @@ case "${COMMAND}" in
cron)
command_cron
;;
env)
command_env
;;
sign)
command_sign ${sign_me}
;;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment