Browse Source

Don't check for updates, if -U parameter has been given

pull/107/head
Alexander Skwar 9 years ago
parent
commit
2e996d6c51
1 changed files with 27 additions and 12 deletions
  1. +27
    -12
      getssl

+ 27
- 12
getssl View File

@ -102,7 +102,7 @@
# 2016-08-25 updated defaults for ACME agreement (1.36) # 2016-08-25 updated defaults for ACME agreement (1.36)
# 2016-09-04 correct issue #101 when some domains already validated (1.37) # 2016-09-04 correct issue #101 when some domains already validated (1.37)
# 2016-09-12 Checks if which is installed (1.38) # 2016-09-12 Checks if which is installed (1.38)
# 2016-09-13 Only check for updates, if "-u" parameter has been given (1.39)
# 2016-09-13 Don't check for updates, if -U parameter has been given (1.39)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
PROGNAME=${0##*/} PROGNAME=${0##*/}
@ -133,6 +133,7 @@ _CHECK_ALL=0
_FORCE_RENEW=0 _FORCE_RENEW=0
_QUIET=0 _QUIET=0
_UPGRADE=0 _UPGRADE=0
_NO_UPGRADE_CHECK=0
# store copy of original command in case of upgrading script and re-running # store copy of original command in case of upgrading script and re-running
ORIGCMD="$0 $*" ORIGCMD="$0 $*"
@ -195,6 +196,8 @@ check_challenge_completion() { # checks with the ACME server if our challenge is
} }
check_getssl_upgrade() { # check if a more recent version of code is available available check_getssl_upgrade() { # check if a more recent version of code is available available
[[ $_NO_UPGRADE_CHECK -eq 0 ]] && return
latestcode=$(curl --silent "$CODE_LOCATION") latestcode=$(curl --silent "$CODE_LOCATION")
errcode=$? errcode=$?
if [ $errcode -eq 60 ]; then if [ $errcode -eq 60 ]; then
@ -209,14 +212,21 @@ check_getssl_upgrade() { # check if a more recent version of code is available a
debug "Most recent version is ${latestversion}" debug "Most recent version is ${latestversion}"
# use a default of 0 for cases where the latest code has not been obtained. # use a default of 0 for cases where the latest code has not been obtained.
if [ "${latestvdec:-0}" -gt "$localvdec" ]; then if [ "${latestvdec:-0}" -gt "$localvdec" ]; then
temp_upgrade="$(mktemp)"
echo "$latestcode" > "$temp_upgrade"
install "$0" "${0}.v${VERSION}"
install "$temp_upgrade" "$0"
rm -f "$temp_upgrade"
echo "Updated getssl from v${VERSION} to v${latestversion}"
eval "$ORIGCMD"
graceful_exit
if [ ${_UPGRADE} -eq 1 ]; then
temp_upgrade="$(mktemp)"
echo "$latestcode" > "$temp_upgrade"
install "$0" "${0}.v${VERSION}"
install "$temp_upgrade" "$0"
rm -f "$temp_upgrade"
echo "Updated getssl from v${VERSION} to v${latestversion}"
eval "$ORIGCMD"
graceful_exit
else
info ""
info "A more recent version (v${latestversion}) of getssl is available, please update"
info "the easiest way is to use the -u or --upgrade flag"
info ""
fi
fi fi
} }
@ -365,6 +375,7 @@ help_message() { # print out the help message
-a, --all Check all certificates -a, --all Check all certificates
-q, --quiet Quiet mode (only outputs on error, or succcess of new cert) -q, --quiet Quiet mode (only outputs on error, or succcess of new cert)
-u, --upgrade Upgrade getssl if a more recent version is available -u, --upgrade Upgrade getssl if a more recent version is available
-U, --nocheck Do not check if a more recent version is available
-w working_dir Working directory -w working_dir Working directory
_EOF_ _EOF_
@ -515,7 +526,7 @@ urlbase64() { # urlbase64: base64 encoded string with '+' replaced with '-' and
} }
usage() { # program usage usage() { # program usage
echo "Usage: $PROGNAME [-h|--help] [-d|--debug] [-c|--create] [-f|--force] [-a|--all] [-q|--quiet] [-u|--upgrade] [-w working_dir] domain"
echo "Usage: $PROGNAME [-h|--help] [-d|--debug] [-c|--create] [-f|--force] [-a|--all] [-q|--quiet] [-u|--upgrade] [-U|--nocheck] [-w working_dir] domain"
} }
write_domain_template() { # write out a template file for a domain. write_domain_template() { # write out a template file for a domain.
@ -659,6 +670,10 @@ while [[ -n $1 ]]; do
_QUIET=1 ;; _QUIET=1 ;;
-u | --upgrade) -u | --upgrade)
_UPGRADE=1 ;; _UPGRADE=1 ;;
-U | --nocheck)
_NO_UPGRADE_CHECK=1 ;;
-C | --check)
_ONLY_UPGRADE_CHECK=1 ;;
-w) -w)
shift; WORKING_DIR="$1" ;; shift; WORKING_DIR="$1" ;;
-* | --*) -* | --*)
@ -693,8 +708,8 @@ else
requires grep requires grep
fi fi
# Check if upgrades are available, if asked for
[[ $_UPGRADE -eq 1 ]] && check_getssl_upgrade
# Check if upgrades are available
check_getssl_upgrade
# get latest agreement from CA (as default) # get latest agreement from CA (as default)
AGREEMENT=$(curl -I ${CA}/terms 2>/dev/null | grep "Location:" | awk '{print $2}'|os_sed 's/\r//') AGREEMENT=$(curl -I ${CA}/terms 2>/dev/null | grep "Location:" | awk '{print $2}'|os_sed 's/\r//')


Loading…
Cancel
Save