Using sequencer configuration handling and making it more foolproof

This commit is contained in:
2020-06-04 15:20:37 +02:00
parent 7a61dcd718
commit a7a632523d
2 changed files with 16 additions and 19 deletions

View File

@@ -8,18 +8,15 @@ toolName=certbot
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
CONFIG_FILE="$WDIR/${toolName}.cfg"
CONFIG_FILE_DEFAULT="${CONFIG_FILE}.example"
CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE}.example"
step_config() {
if [ ! -s "$CONFIG_FILE" ] && [ ! -s "$CONFIG_FILE_DEFAULT" ] ; then
echoerr " [E] No configuration \"$CONFIG_FILE_DEFAULT\" or \"$CONFIG_FILE\" found"
exit 1;
fi
if [ -s "$CONFIG_FILE" ] ; then
. "$CONFIG_FILE"
else
echoerr " [E] No user configuration \"$CONFIG_FILE\" found. (See template $CONFIG_FILE_DEFAULT)"
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
local confReturn=$?
if [ $confReturn -eq 0 ] ; then
CONFIG=1
fi
}
@@ -74,13 +71,13 @@ step_1() {
step_2_info() { echo "Create or update letsencrypt certificate"; }
step_2_alias() { ALIAS="update"; }
step_2() {
endCheckEmpty CERTBOT_DOMAINS "Invalid domain list"
endCheckEmpty CERTBOT_WEBROOT "Invalid web root"
endCheckEmpty CERTBOT_MAIL "Invalid mail address"
endCheckEmpty CERTBOT_DOMAINS "No domain list found. Check configuration"
endCheckEmpty CERTBOT_WEBROOT "Invalid web root. Check configuration"
endCheckEmpty CERTBOT_MAIL "Invalid mail address. Check configuration"
exe certbot certonly --webroot -w "$CERTBOT_WEBROOT" --rsa-key-size 4096 --expand --agree-tos \
-m "$CERTBOT_MAIL" ${CERTBOT_DOMAINS[@]/#/-d }
}
VERSION_SEQREV=8
VERSION_SEQREV=11
. /usr/local/bin/sequencer.sh