Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update letsencrypt-auto with CentOS6 SCL for python 2.7 #1172

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion bootstrap/centos.sh

This file was deleted.

27 changes: 27 additions & 0 deletions bootstrap/centos.sh
@@ -0,0 +1,27 @@
#!/bin/sh

# Tested with:
# - CentOS 6.7 (x64)


if [ `lsb_release -rs | cut -f1 -d.` -eq 6 ]
then
# Setup SCL Repo - https://wiki.centos.org/AdditionalResources/Repositories/SCL
yum -y install centos-release-SCL

# Now install Deps
yum -y install \
git-core \
python27 \
python27-python-devel \
python27-python-virtualenv \
gcc \
dialog \
augeas-libs \
openssl-devel \
libffi-devel \
ca-certificates

else
source $BOOTSTRAP/_rpm_common.sh
fi
27 changes: 21 additions & 6 deletions letsencrypt-auto
Expand Up @@ -12,6 +12,7 @@ XDG_DATA_HOME=${XDG_DATA_HOME:-~/.local/share}
VENV_NAME="letsencrypt"
VENV_PATH=${VENV_PATH:-"$XDG_DATA_HOME/$VENV_NAME"}
VENV_BIN=${VENV_PATH}/bin
PYTHON_VER="python2"

if test "`id -u`" -ne "0" ; then
SUDO=sudo
Expand Down Expand Up @@ -46,7 +47,16 @@ then
$SUDO $BOOTSTRAP/manjaro.sh
elif [ -f /etc/redhat-release ] ; then
echo "Bootstrapping dependencies for RedHat-based OSes..."
$SUDO $BOOTSTRAP/_rpm_common.sh
if [ `lsb_release -is` == "CentOS" ]; then
$SUDO $BOOTSTRAP/centos.sh
if [ `lsb_release -rs | cut -f1 -d.` -eq 6 ]; then
source /opt/rh/python27/enable
PYTHON_VER="python2.7"
SCL="scl enable python27 "
fi
else
$SUDO $BOOTSTRAP/_rpm_common.sh
fi
elif uname | grep -iq FreeBSD ; then
echo "Bootstrapping dependencies for FreeBSD..."
$SUDO $BOOTSTRAP/freebsd.sh
Expand All @@ -62,11 +72,12 @@ then
echo "for more info"
fi

echo "Creating virtual environment..."

echo "Creating virtual environment...$VENV_PATH"
if [ "$VERBOSE" = 1 ] ; then
virtualenv --no-site-packages --python python2 $VENV_PATH
virtualenv --no-site-packages --python $PYTHON_VER $VENV_PATH
else
virtualenv --no-site-packages --python python2 $VENV_PATH > /dev/null
virtualenv --no-site-packages --python $PYTHON_VER $VENV_PATH > /dev/null
fi
fi

Expand Down Expand Up @@ -99,5 +110,9 @@ fi

# Explain what's about to happen, for the benefit of those getting sudo
# password prompts...
echo "Running with virtualenv:" $SUDO $VENV_BIN/letsencrypt "$@"
$SUDO $VENV_BIN/letsencrypt "$@"
if [ -z "$SCL" ] ; then
echo "Running with virtualenv:" $SUDO $VENV_BIN/letsencrypt "$@"
$SUDO $VENV_BIN/letsencrypt "$@"
else
echo "Now run: $SUDO $SCL \"$VENV_BIN/letsencrypt $@\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

letsencrypt-auto should call the wrapped command rather than asking user to copy paste it and run themselves

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I agree, however I couldn't figure it out.

My original go had $SUDO $SCL $VENV_BIN/letsencrypt "$@" (i.e. without the echo) but it fails. I tried escaping the quotes but to no avail. $SCL sets up the correct python ENV variables but something goes amiss when called in the script with SUDO... works fine if the user copy/paste.

Any idea on what I'm missing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun times. Try this:

$SUDO $SCL \\"$VENV_BIN/letsencrypt $@\\"

The theory is that the double escapes protect the quotes through the current shell, and the sudo layer, reconstructing them for the scl command. I don't have a Centos system to test on, but I tested in with a shell script that tries to run an analogous command through sudo bash -c \\"$@\\"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if people use "$@" rather than $@ it should be $SUDO $SCL \\"$VENV_BIN/letsencrypt "$@"\\", though I think that just defers expansion of shell arguments until further down the stack?

fi