From 836c80428d0a2ce39fb06a44c6afc24049d2e5dd Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Sun, 20 Oct 2019 22:59:45 +0200 Subject: [PATCH] Various corrections --- letsencrypt-auto-source/letsencrypt-auto | 1 - .../letsencrypt-auto.template | 1 - .../tests/oraclelinux6_tests.sh | 56 ++++++------------- 3 files changed, 17 insertions(+), 41 deletions(-) diff --git a/letsencrypt-auto-source/letsencrypt-auto b/letsencrypt-auto-source/letsencrypt-auto index 34d93789f..911243faa 100755 --- a/letsencrypt-auto-source/letsencrypt-auto +++ b/letsencrypt-auto-source/letsencrypt-auto @@ -1181,7 +1181,6 @@ if [ "$1" = "--le-auto-phase2" ]; then error "Skipping upgrade because new OS dependencies may need to be installed." error "This requires a manual user intervention." error "$INTERACTIVE_BOOTSTRAP_MESSAGE" - error # If this is because of the environment (eg. non interactive shell without # --non-interactive flag set), help the user in that direction. else diff --git a/letsencrypt-auto-source/letsencrypt-auto.template b/letsencrypt-auto-source/letsencrypt-auto.template index e710f490a..a6ae6484f 100755 --- a/letsencrypt-auto-source/letsencrypt-auto.template +++ b/letsencrypt-auto-source/letsencrypt-auto.template @@ -601,7 +601,6 @@ if [ "$1" = "--le-auto-phase2" ]; then error "Skipping upgrade because new OS dependencies may need to be installed." error "This requires a manual user intervention." error "$INTERACTIVE_BOOTSTRAP_MESSAGE" - error # If this is because of the environment (eg. non interactive shell without # --non-interactive flag set), help the user in that direction. else diff --git a/letsencrypt-auto-source/tests/oraclelinux6_tests.sh b/letsencrypt-auto-source/tests/oraclelinux6_tests.sh index 5355147df..45966e4e9 100644 --- a/letsencrypt-auto-source/tests/oraclelinux6_tests.sh +++ b/letsencrypt-auto-source/tests/oraclelinux6_tests.sh @@ -5,9 +5,6 @@ yum update -y >/dev/null LE_AUTO_PY_34="certbot/letsencrypt-auto-source/letsencrypt-auto_py_34" LE_AUTO="certbot/letsencrypt-auto-source/letsencrypt-auto" -# Last version of certbot-auto that was bootstraping Python 3.4 for CentOS 6 users -INITIAL_CERTBOT_VERSION_PY34="certbot 0.38.0" - # Check bootstrap from current letsencrypt-auto will fail, because SCL is not enabled. if ! "$LE_AUTO" 2>&1 | grep -q "Enable the SCL repository and try running Certbot again."; then echo "ERROR: bootstrap was not aborted although SCL was not installed!" @@ -29,53 +26,34 @@ fi echo "PASSED: bootstrap from old letsencrypt-auto succeeded and installed Python 3.4" -# Expect letsencrypt-auto to just fail to rebootstrap and start certbot in interactive -# shell since SCL is not installed. -if ! "$LE_AUTO" --version 2>&1 | grep -q "Enable the SCL repository and try running Certbot again."; then +# Expect letsencrypt-auto to skip rebootstrapping with a warning since SCL is not installed. +if ! "$LE_AUTO" --non-interactive --version 2>&1 | grep -q "Enable the SCL repository and try running Certbot again."; then echo "FAILED: Script letsencrypt-auto managed to start Certbot in interactive shell while SCL is not enabled!" exit 1 fi echo "PASSED: Script letsencrypt-auto did not rebootstrap." -# Expect letsencrypt-auto to not update certbot, but start it anyway in non-interactive -# shell since SCL is not installed. -# NB: Readline has an issue on all Python versions for OL 6, making `certbot --version` -# output an unprintable ASCII character on a new line at the end. -# So we take the second last line of the output. -version=$($LE_AUTO --version 2>/dev/null | tail -2 | head -1) - -if [ -z "$version" ]; then - echo "ERROR: Script letsencrypt-auto failed to start certbot in a non-interactive shell while SCL was not enabled." - exit 1 -fi - -if [ "$version" != "$INITIAL_CERTBOT_VERSION_PY34" ]; then - echo "ERROR: Script letsencrypt-auto upgraded certbot in a non-interactive shell while SCL was not enabled." - exit 1 -fi - -echo "PASSED: Script letsencrypt-auto did not upgrade certbot but started it successfully while SCL was not enabled." - # Enable SCL yum install -y oracle-softwarecollection-release-el6 >/dev/null -# Following test is exectued in a subshell, to not leak any environment variable -( - export VENV_PATH=$(mktemp -d) - # Expect letsencrypt-auto to bootstrap successfully since SCL is available - "$LE_AUTO" -n >/dev/null 2>/dev/null - - if [ "$($VENV_PATH/bin/python -V 2>&1 | cut -d" " -f2 | cut -d. -f1-2)" != "3.6" ]; then - echo "ERROR: Script letsencrypt-auto failed to bootstrap and install Python 3.6 while SCL is available." +# Expect letsencrypt-auto to bootstrap successfully since SCL is available, +# assert that there is no output since --quiet flag is set. +OUTPUT_LEN=$("$LE_AUTO" -n --quiet 2>&1 | wc -c) +if [ "$OUTPUT_LEN" != 0 ]; then + echo letsencrypt-auto produced unexpected output! exit 1 - fi +fi - if ! $VENV_PATH/bin/certbot --version > /dev/null 2> /dev/null; then - echo "ERROR: Script letsencrypt-auto did not install certbot correctly while SCL is enabled." - exit 1 - fi -) +if [ "$(/opt/eff.org/bin/python -V 2>&1 | cut -d" " -f2 | cut -d. -f1-2)" != "3.6" ]; then + echo "ERROR: Script letsencrypt-auto failed to bootstrap and install Python 3.6 while SCL is available." + exit 1 +fi + +if ! /opt/eff.org/bin/certbot --version > /dev/null 2> /dev/null; then + echo "ERROR: Script letsencrypt-auto did not install certbot correctly while SCL is enabled." + exit 1 +fi echo "PASSED: Script letsencrypt-auto correctly bootstraped Certbot using rh-python36 when SCL is available."