Check quiet mode

This commit is contained in:
Adrien Ferrand 2019-10-24 00:45:06 +02:00
parent a150ab63f1
commit 83ad28884d
2 changed files with 28 additions and 12 deletions

View file

@ -1156,7 +1156,7 @@ if [ "$1" = "--le-auto-phase2" ]; then
# If the selected Bootstrap function isn't a noop and it differs from the
# previously used version
if [ -n "$BOOTSTRAP_VERSION" -a "$BOOTSTRAP_VERSION" != "$PREV_BOOTSTRAP_VERSION" ]; then
# Check if we can rebootstrap without manual user intervention: this require that
# Check if we can rebootstrap without manual user intervention: this requires that
# certbot-auto is in non-interactive mode AND selected bootstrap does not claim to
# require a manual user intervention.
if [ "$NONINTERACTIVE" = 1 -a "$INTERACTIVE_BOOTSTRAP" != 1 ]; then
@ -1177,7 +1177,7 @@ if [ "$1" = "--le-auto-phase2" ]; then
RerunWithArgs "$@"
# Otherwise bootstrap needs to be done manually by the user.
else
# If it is because of the bootstrap, --non-interactive will be of no use.
# If it is because bootstrapping is interactive, --non-interactive will be of no use.
if [ "$INTERACTIVE_BOOTSTRAP" = 1 ]; then
error "Skipping upgrade because new OS dependencies may need to be installed."
error "This requires manual user intervention: please run this script again manually."

View file

@ -6,10 +6,17 @@ 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"
# Apply installation instructions from official documentation:
# https://certbot.eff.org/lets-encrypt/centosrhel6-other
cp "$LE_AUTO" /usr/local/bin/certbot-auto
chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto
LE_AUTO=/usr/local/bin/certbot-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.
# Check bootstrap from current certbot-auto will fail, because SCL is not enabled.
set +o pipefail
if ! "$LE_AUTO" -n 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!"
@ -30,13 +37,13 @@ fi
echo "PASSED: Bootstrap from old letsencrypt-auto succeeded and installed Python 3.4"
# Expect letsencrypt-auto to skip rebootstrapping with a warning since SCL is not installed.
# Expect certbot-auto to skip rebootstrapping with a warning since SCL is not installed.
if ! "$LE_AUTO" --non-interactive --version 2>&1 | grep -q "This requires manual user intervention"; then
echo "FAILED: Script letsencrypt-auto managed to start Certbot in interactive shell while SCL is not enabled!"
echo "FAILED: Script certbot-auto managed to start Certbot in interactive shell while SCL is not enabled!"
exit 1
fi
echo "PASSED: Script letsencrypt-auto did not rebootstrap."
echo "PASSED: Script certbot-auto did not rebootstrap."
# 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.
@ -44,26 +51,35 @@ echo "PASSED: Script letsencrypt-auto did not rebootstrap."
version=$($LE_AUTO --version 2>/dev/null | tail -2 | head -1)
if [ "$version" != "$INITIAL_CERTBOT_VERSION_PY34" ]; then
echo "ERROR: Script letsencrypt-auto upgraded certbot in a non-interactive shell while SCL was not enabled."
echo "ERROR: Script certbot-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."
echo "PASSED: Script certbot-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
# Expect letsencrypt-auto to bootstrap successfully since SCL is available.
# Expect certbot-auto to bootstrap successfully since SCL is available.
"$LE_AUTO" -n --version &>/dev/null
if [ "$(/opt/eff.org/certbot/venv/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."
echo "ERROR: Script certbot-auto failed to bootstrap and install Python 3.6 while SCL is available."
exit 1
fi
if ! /opt/eff.org/certbot/venv/bin/certbot --version > /dev/null 2> /dev/null; then
echo "ERROR: Script letsencrypt-auto did not install certbot correctly while SCL is enabled."
echo "ERROR: Script certbot-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."
echo "PASSED: Script certbot-auto correctly bootstraped Certbot using rh-python36 when SCL is available."
# Expect certbot-auto will be totally silent now that everything has been correctly boostraped.
OUTPUT_LEN=$("$LE_AUTO" --install-only --no-self-upgrade --quiet 2>&1 | wc -c)
if [ "$OUTPUT_LEN" != 0 ]; then
echo certbot-auto produced unexpected output!
exit 1
fi
echo "PASSED: Script certbot-auto did not print anything in quiet mode."