modernize multiple seqs and fix deprecated use of endCheckEmpty
This commit is contained in:
@@ -3,21 +3,20 @@
|
||||
# Certbot installation and creation supporting Raspbian and Ubuntu.
|
||||
# Certificate can be created/updated as "certonly" only.
|
||||
|
||||
toolName=certbot
|
||||
readonly toolName=certbot
|
||||
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
|
||||
CONFIG=0
|
||||
CONFIG_FILE_NAME="${toolName}.cfg"
|
||||
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
||||
sq_aptOpt=
|
||||
|
||||
seq_config() {
|
||||
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
local confReturn=$?
|
||||
if [ $confReturn -eq 0 ] ; then
|
||||
CONFIG=1
|
||||
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
||||
# End if no configuration file exists
|
||||
dry || return 1
|
||||
fi
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
interactive || sq_aptOpt="-y"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
step_1_info() { echo "Install $toolName for letsencrypt"; }
|
||||
@@ -41,24 +40,17 @@ step_1() {
|
||||
|
||||
echo " [I] Detected OS: $osName $distName"
|
||||
|
||||
local aptOption=
|
||||
if quiet ; then
|
||||
aptOption="-y"
|
||||
else
|
||||
aptOption=""
|
||||
fi
|
||||
|
||||
if [ "$osName" == "Ubuntu" ] ; then
|
||||
exe apt-get update
|
||||
exe apt-get install software-properties-common $aptOption
|
||||
exe apt-get install software-properties-common ${sq_aptOpt}
|
||||
saveReturn $?
|
||||
exe add-apt-repository universe $aptOption
|
||||
exe add-apt-repository universe ${sq_aptOpt}
|
||||
saveReturn $?
|
||||
exe add-apt-repository ppa:certbot/certbot $aptOption
|
||||
exe add-apt-repository ppa:certbot/certbot ${sq_aptOpt}
|
||||
saveReturn $?
|
||||
exe apt-get update
|
||||
|
||||
exe apt-get install $toolName $aptOption
|
||||
exe apt-get install $toolName ${sq_aptOpt}
|
||||
saveReturn $?
|
||||
endReturn "$toolName installation for $osName failed"
|
||||
elif [ "$osName" == "Raspbian" ] ; then
|
||||
@@ -71,13 +63,15 @@ step_1() {
|
||||
step_2_info() { echo "Create or update letsencrypt certificate"; }
|
||||
step_2_alias() { echo "update"; }
|
||||
step_2() {
|
||||
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"
|
||||
endIfEmpty CERTBOT_DOMAINS "No domain list found. Check configuration"
|
||||
endIfEmpty CERTBOT_WEBROOT "Invalid web root. Check configuration"
|
||||
endIfEmpty 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 }
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
Reference in New Issue
Block a user