Merge pull request #2466 from erikrose/shelly-fixes

le-auto shell style improvements
This commit is contained in:
Peter Eckersley
2016-02-13 10:37:58 -08:00
2 changed files with 50 additions and 44 deletions
+25 -22
View File
@@ -25,18 +25,24 @@ LE_AUTO_VERSION="0.5.0.dev0"
# additionally responds to --verbose (more output) and --debug (allow support # additionally responds to --verbose (more output) and --debug (allow support
# for experimental platforms) # for experimental platforms)
for arg in "$@" ; do for arg in "$@" ; do
# This first clause is redundant with the third, but hedging on portability case "$arg" in
if [ "$arg" = "-v" ] || [ "$arg" = "--verbose" ] || echo "$arg" | grep -E -- "-v+$" ; then --debug)
VERBOSE=1 DEBUG=1;;
elif [ "$arg" = "--no-self-upgrade" ] ; then --os-packages-only)
# Do not upgrade this script (also prevents client upgrades, because each OS_PACKAGES_ONLY=1;;
# copy of the script pins a hash of the python client) --no-self-upgrade)
NO_SELF_UPGRADE=1 # Do not upgrade this script (also prevents client upgrades, because each
elif [ "$arg" = "--os-packages-only" ] ; then # copy of the script pins a hash of the python client)
OS_PACKAGES_ONLY=1 NO_SELF_UPGRADE=1;;
elif [ "$arg" = "--debug" ]; then --verbose)
DEBUG=1 VERBOSE=1;;
fi [!-]*|-*[!v]*|-)
# Anything that isn't -v, -vv, etc.: that is, anything that does not
# start with a -, contains anything that's not a v, or is just "-"
;;
*) # -v+ remains.
VERBOSE=1;;
esac
done done
# letsencrypt-auto needs root access to bootstrap OS dependencies, and # letsencrypt-auto needs root access to bootstrap OS dependencies, and
@@ -91,18 +97,15 @@ ExperimentalBootstrap() {
} }
DeterminePythonVersion() { DeterminePythonVersion() {
if command -v python2.7 > /dev/null ; then for LE_PYTHON in "$LE_PYTHON" python2.7 python27 python2 python; do
export LE_PYTHON=${LE_PYTHON:-python2.7} # Break (while keeping the LE_PYTHON value) if found.
elif command -v python27 > /dev/null ; then command -v "$LE_PYTHON" > /dev/null && break
export LE_PYTHON=${LE_PYTHON:-python27} done
elif command -v python2 > /dev/null ; then if [ "$?" != "0" ]; then
export LE_PYTHON=${LE_PYTHON:-python2} echo "Cannot find any Pythons; please install one!"
elif command -v python > /dev/null ; then
export LE_PYTHON=${LE_PYTHON:-python}
else
echo "Cannot find any Pythons... please install one!"
exit 1 exit 1
fi fi
export LE_PYTHON
PYVER=`"$LE_PYTHON" -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//'` PYVER=`"$LE_PYTHON" -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//'`
if [ "$PYVER" -lt 26 ]; then if [ "$PYVER" -lt 26 ]; then
@@ -25,18 +25,24 @@ LE_AUTO_VERSION="{{ LE_AUTO_VERSION }}"
# additionally responds to --verbose (more output) and --debug (allow support # additionally responds to --verbose (more output) and --debug (allow support
# for experimental platforms) # for experimental platforms)
for arg in "$@" ; do for arg in "$@" ; do
# This first clause is redundant with the third, but hedging on portability case "$arg" in
if [ "$arg" = "-v" ] || [ "$arg" = "--verbose" ] || echo "$arg" | grep -E -- "-v+$" ; then --debug)
VERBOSE=1 DEBUG=1;;
elif [ "$arg" = "--no-self-upgrade" ] ; then --os-packages-only)
# Do not upgrade this script (also prevents client upgrades, because each OS_PACKAGES_ONLY=1;;
# copy of the script pins a hash of the python client) --no-self-upgrade)
NO_SELF_UPGRADE=1 # Do not upgrade this script (also prevents client upgrades, because each
elif [ "$arg" = "--os-packages-only" ] ; then # copy of the script pins a hash of the python client)
OS_PACKAGES_ONLY=1 NO_SELF_UPGRADE=1;;
elif [ "$arg" = "--debug" ]; then --verbose)
DEBUG=1 VERBOSE=1;;
fi [!-]*|-*[!v]*|-)
# Anything that isn't -v, -vv, etc.: that is, anything that does not
# start with a -, contains anything that's not a v, or is just "-"
;;
*) # -v+ remains.
VERBOSE=1;;
esac
done done
# letsencrypt-auto needs root access to bootstrap OS dependencies, and # letsencrypt-auto needs root access to bootstrap OS dependencies, and
@@ -91,18 +97,15 @@ ExperimentalBootstrap() {
} }
DeterminePythonVersion() { DeterminePythonVersion() {
if command -v python2.7 > /dev/null ; then for LE_PYTHON in "$LE_PYTHON" python2.7 python27 python2 python; do
export LE_PYTHON=${LE_PYTHON:-python2.7} # Break (while keeping the LE_PYTHON value) if found.
elif command -v python27 > /dev/null ; then command -v "$LE_PYTHON" > /dev/null && break
export LE_PYTHON=${LE_PYTHON:-python27} done
elif command -v python2 > /dev/null ; then if [ "$?" != "0" ]; then
export LE_PYTHON=${LE_PYTHON:-python2} echo "Cannot find any Pythons; please install one!"
elif command -v python > /dev/null ; then
export LE_PYTHON=${LE_PYTHON:-python}
else
echo "Cannot find any Pythons... please install one!"
exit 1 exit 1
fi fi
export LE_PYTHON
PYVER=`"$LE_PYTHON" -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//'` PYVER=`"$LE_PYTHON" -V 2>&1 | cut -d" " -f 2 | cut -d. -f1,2 | sed 's/\.//'`
if [ "$PYVER" -lt 26 ]; then if [ "$PYVER" -lt 26 ]; then