Use set -e

This commit is contained in:
Adrien Ferrand 2020-01-02 23:23:21 +01:00
parent df7c54517b
commit 72ef8704e8

View file

@ -1,4 +1,5 @@
#!/bin/bash
set -e
# Start by making sure your system is up-to-date:
yum update -y > /dev/null
yum install -y centos-release-scl > /dev/null
@ -14,14 +15,10 @@ echo ""
export UNAME_FAKE_32BITS=true
if ! "$LE_AUTO" 2>&1 | grep -q "Certbot cannot be installed."; then
echo "On CentOS 32 bits, certbot-auto installed certbot."
touch .failed-test
exit
exit 1
fi
)
if [ -f .failed-test ]; then
exit 1
fi
echo "PASSED: On CentOS 6 32 bits, certbot-auto refused to install certbot."
# we're going to modify env variables, so do this in a subshell
@ -29,45 +26,33 @@ echo "PASSED: On CentOS 6 32 bits, certbot-auto refused to install certbot."
source /opt/rh/python27/enable
# ensure python 3 isn't installed
python3 --version 2> /dev/null
RESULT=$?
if [ $RESULT -eq 0 ]; then
if python3 --version 2> /dev/null; then
echo "Python3 is already installed."
touch .failed-test
exit
exit 1
fi
# ensure python2.7 is available
python2.7 --version 2> /dev/null
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "Python3 is not available."
touch .failed-test
exit
if ! python2.7 --version 2> /dev/null; then
echo "Python2.7 is not available."
exit 1
fi
# bootstrap, but don't install python 3.
"$LE_AUTO" --no-self-upgrade -n > /dev/null 2> /dev/null
"$LE_AUTO" --no-self-upgrade -n --version > /dev/null 2> /dev/null
# ensure python 3 isn't installed
python3 --version 2> /dev/null
RESULT=$?
if [ $RESULT -eq 0 ]; then
if python3 --version 2> /dev/null; then
echo "letsencrypt-auto installed Python3 even though Python2.7 is present."
touch .failed-test
exit
exit 1
fi
)
if [ -f .failed-test ]; then
exit 1
fi
echo "PASSED: Did not upgrade to Python3 when Python2.7 is present."
# ensure python2.7 isn't available
python2.7 --version 2> /dev/null
RESULT=$?
if [ $RESULT -eq 0 ]; then
if python2.7 --version 2> /dev/null; then
echo "Python2.7 is still available."
exit 1
fi
@ -79,12 +64,10 @@ if ! "$LE_AUTO" 2>&1 | grep -q "WARNING: couldn't find Python"; then
fi
# bootstrap, this time installing python3
"$LE_AUTO" --no-self-upgrade -n > /dev/null 2> /dev/null
"$LE_AUTO" --no-self-upgrade -n --version > /dev/null 2> /dev/null
# ensure python 3 is installed
python3 --version > /dev/null
RESULT=$?
if [ $RESULT -ne 0 ]; then
if ! python3 --version > /dev/null; then
echo "letsencrypt-auto failed to install Python3 when only Python2.6 is present."
exit 1
fi
@ -107,24 +90,17 @@ unset VENV_PATH
export UNAME_FAKE_32BITS=true
if ! "$LE_AUTO" --version > /dev/null 2> /dev/null; then
echo "On CentOS 6 32 bits, certbot-auto failed to run installed certbot instance."
touch .failed-test
exit
exit 1
fi
if ! "$LE_AUTO" --version 2>&1 | grep -q "Certbot will no longer receive updates."; then
echo "On CentOS 6 32 bits, certbot-auto upgraded installed certbot instance."
touch .failed-test
exit
exit 1
fi
if ! "$LE_AUTO" --install-only 2>&1 | grep -q "Certbot cannot be installed."; then
echo "On CentOS 6 32 bits, certbot-auto installed certbot again."
touch .failed-test
exit
fi
)
if [ -f .failed-test ]; then
exit 1
fi
)
# we're going to modify env variables, so do this in a subshell
(
@ -135,19 +111,14 @@ export VENV_PATH=~/.local/share/letsencrypt
export UNAME_FAKE_32BITS=true
if ! "$LE_AUTO" --version > /dev/null 2> /dev/null; then
echo "On CentOS 6 32 bits, certbot-auto failed to run installed certbot instance in the old venv path."
touch .failed-test
exit
exit 1
fi
if ! "$LE_AUTO" 2>&1 | grep -q "Certbot will no longer receive updates."; then
echo "On CentOS 6 32 bits, certbot-auto upgraded installed certbot in the old venv path."
touch .failed-test
exit
exit 1
fi
)
if [ -f .failed-test ]; then
exit 1
fi
echo "PASSED: On CentOS 6 32 bits, certbot-auto refused to install/upgrade certbot."
# test using python3