From 47eaf297fba19668d7c5e483ec7abaa6085eafad Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Wed, 14 Oct 2015 15:57:09 -0700 Subject: [PATCH] Start a letsencrypt-auto script Which handles all venv-related tasks for installing from pip, and gives us auto-updating. --- letsencrypt-auto | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 letsencrypt-auto diff --git a/letsencrypt-auto b/letsencrypt-auto new file mode 100755 index 000000000..82720a3fc --- /dev/null +++ b/letsencrypt-auto @@ -0,0 +1,45 @@ +#!/bin/bash -e +# +# Installs and updates the letencrypt virtualenv, and runs letsencrypt +# using that virtual environment. This allows the client to function decently +# without requiring specific versions of its dependencies from the operating +# system. + +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 + +for arg in "$@" ; do + if [ "$arg" = "-v" ] || [ "$arg" = "--verbose" ] ; then + VERBOSE=1 + fi +done + +# virtualenv call is not idempotent: it overwrites pip upgraded in +# later steps, causing "ImportError: cannot import name unpack_url" +if [ ! -d $VENV_PATH ] +then + echo "Creating virtual environment..." + if [ "$VERBOSE" = 1 ] ; then + virtualenv --no-site-packages --python python2 $VENV_PATH + else + virtualenv --no-site-packages --python python2 $VENV_PATH > /dev/null + fi +fi + +echo "Updating letsencrypt and virtual environment dependencies..." +if [ "$VERBOSE" = 1 ] ; then + $VENV_BIN/pip install -U setuptools + $VENV_BIN/pip install -U pip + $VENV_BIN/pip install -U letsencrypt letsencrypt-apache letsencrypt-nginx +else + $VENV_BIN/pip install -U setuptools > /dev/null + $VENV_BIN/pip install -U pip > /dev/null + $VENV_BIN/pip install -U letsencrypt letsencrypt-apache letsencrypt-nginx > /dev/null +fi + +# TODO: install apache and nginx plugins by default? +# --pre is not necessary for dev releases in more recent pip versions + +sudo $VENV_BIN/letsencrypt $@