From 2e996d6c5169ef84bc5ddde84d188730253e1a0a Mon Sep 17 00:00:00 2001 From: Alexander Skwar Date: Tue, 13 Sep 2016 10:27:01 +0200 Subject: [PATCH] Don't check for updates, if -U parameter has been given --- getssl | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/getssl b/getssl index 356973c..f4908ed 100755 --- a/getssl +++ b/getssl @@ -102,7 +102,7 @@ # 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-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##*/} @@ -133,6 +133,7 @@ _CHECK_ALL=0 _FORCE_RENEW=0 _QUIET=0 _UPGRADE=0 +_NO_UPGRADE_CHECK=0 # store copy of original command in case of upgrading script and re-running 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 + [[ $_NO_UPGRADE_CHECK -eq 0 ]] && return + latestcode=$(curl --silent "$CODE_LOCATION") errcode=$? 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}" # use a default of 0 for cases where the latest code has not been obtained. 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 } @@ -365,6 +375,7 @@ help_message() { # print out the help message -a, --all Check all certificates -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, --nocheck Do not check if a more recent version is available -w working_dir Working directory _EOF_ @@ -515,7 +526,7 @@ urlbase64() { # urlbase64: base64 encoded string with '+' replaced with '-' and } 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. @@ -659,6 +670,10 @@ while [[ -n $1 ]]; do _QUIET=1 ;; -u | --upgrade) _UPGRADE=1 ;; + -U | --nocheck) + _NO_UPGRADE_CHECK=1 ;; + -C | --check) + _ONLY_UPGRADE_CHECK=1 ;; -w) shift; WORKING_DIR="$1" ;; -* | --*) @@ -693,8 +708,8 @@ else requires grep 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) AGREEMENT=$(curl -I ${CA}/terms 2>/dev/null | grep "Location:" | awk '{print $2}'|os_sed 's/\r//')