Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- letsencrypt-auto.orig 2015-11-04 12:38:30.000000000 +0100
- +++ letsencrypt-auto 2015-11-04 17:23:59.728223639 +0100
- @@ -12,6 +12,8 @@
- VENV_NAME="letsencrypt"
- VENV_PATH=${VENV_PATH:-"$XDG_DATA_HOME/$VENV_NAME"}
- VENV_BIN=${VENV_PATH}/bin
- +VENV_LASTUPDATE=${VENV_PATH}/.lastupdate
- +VENV_UPDATEINTERVAL=86400 # 1 day
- if test "`id -u`" -ne "0" ; then
- SUDO=sudo
- @@ -73,31 +75,45 @@
- fi
- fi
- -printf "Updating letsencrypt and virtual environment dependencies..."
- -if [ "$VERBOSE" = 1 ] ; then
- - echo
- - $VENV_BIN/pip install -U setuptools
- - $VENV_BIN/pip install -U pip
- - $VENV_BIN/pip install -U letsencrypt letsencrypt-apache
- - # nginx is buggy / disabled for now, but upgrade it if the user has
- - # installed it manually
- - if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
- - $VENV_BIN/pip install -U letsencrypt letsencrypt-nginx
- - fi
- +# Find last time of env update (if any)
- +if [ -e "${VENV_LASTUPDATE}" ]; then
- + VENV_LASTUPDATED=$(( `date +%s` - `stat -L --format %Y "${VENV_LASTUPDATE}"` ))
- else
- - $VENV_BIN/pip install -U setuptools > /dev/null
- - printf .
- - $VENV_BIN/pip install -U pip > /dev/null
- - printf .
- - # nginx is buggy / disabled for now...
- - $VENV_BIN/pip install -U letsencrypt > /dev/null
- - printf .
- - $VENV_BIN/pip install -U letsencrypt-apache > /dev/null
- - if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
- + VENV_LASTUPDATED=${VENV_UPDATEINTERVAL}
- +fi
- +
- +# Update letsencrypt and virtual environment dependencies if not done within
- +# the last $VENV_UPDATEINTERVAL seconds (default: not more often than once per day)
- +if [ ${VENV_LASTUPDATED} -lt ${VENV_UPDATEINTERVAL} ]; then
- + printf "Skipping update check. Remove '${VENV_LASTUPDATE}' to enforce."
- +else
- + printf "Updating letsencrypt and virtual environment dependencies..."
- + if [ "$VERBOSE" = 1 ] ; then
- + echo
- + $VENV_BIN/pip install -U setuptools
- + $VENV_BIN/pip install -U pip
- + $VENV_BIN/pip install -U letsencrypt letsencrypt-apache
- + # nginx is buggy / disabled for now, but upgrade it if the user has
- + # installed it manually
- + if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
- + $VENV_BIN/pip install -U letsencrypt letsencrypt-nginx
- + fi
- + else
- + $VENV_BIN/pip install -U setuptools > /dev/null
- + printf .
- + $VENV_BIN/pip install -U pip > /dev/null
- printf .
- - $VENV_BIN/pip install -U letsencrypt-nginx > /dev/null
- + # nginx is buggy / disabled for now...
- + $VENV_BIN/pip install -U letsencrypt > /dev/null
- + printf .
- + $VENV_BIN/pip install -U letsencrypt-apache > /dev/null
- + if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
- + printf .
- + $VENV_BIN/pip install -U letsencrypt-nginx > /dev/null
- + fi
- + echo
- fi
- - echo
- + touch ${VENV_LASTUPDATE}
- fi
- # Explain what's about to happen, for the benefit of those getting sudo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement