Advertisement
Guest User

letsencrypt-auto.diff

a guest
Nov 4th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.88 KB | None | 0 0
  1. --- letsencrypt-auto.orig   2015-11-04 12:38:30.000000000 +0100
  2. +++ letsencrypt-auto    2015-11-04 17:23:59.728223639 +0100
  3. @@ -12,6 +12,8 @@
  4.  VENV_NAME="letsencrypt"
  5.  VENV_PATH=${VENV_PATH:-"$XDG_DATA_HOME/$VENV_NAME"}
  6.  VENV_BIN=${VENV_PATH}/bin
  7. +VENV_LASTUPDATE=${VENV_PATH}/.lastupdate
  8. +VENV_UPDATEINTERVAL=86400   # 1 day
  9.  
  10.  if test "`id -u`" -ne "0" ; then
  11.    SUDO=sudo
  12. @@ -73,31 +75,45 @@
  13.    fi
  14.  fi
  15.  
  16. -printf "Updating letsencrypt and virtual environment dependencies..."
  17. -if [ "$VERBOSE" = 1 ]  ; then
  18. -  echo
  19. -  $VENV_BIN/pip install -U setuptools
  20. -  $VENV_BIN/pip install -U pip
  21. -  $VENV_BIN/pip install -U letsencrypt letsencrypt-apache
  22. -  # nginx is buggy / disabled for now, but upgrade it if the user has
  23. -  # installed it manually
  24. -  if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
  25. -    $VENV_BIN/pip install -U letsencrypt letsencrypt-nginx
  26. -  fi
  27. +# Find last time of env update (if any)
  28. +if [ -e "${VENV_LASTUPDATE}" ]; then
  29. +  VENV_LASTUPDATED=$(( `date +%s` - `stat -L --format %Y "${VENV_LASTUPDATE}"` ))
  30.  else
  31. -  $VENV_BIN/pip install -U setuptools > /dev/null
  32. -  printf .
  33. -  $VENV_BIN/pip install -U pip > /dev/null
  34. -  printf .
  35. -  # nginx is buggy / disabled for now...
  36. -  $VENV_BIN/pip install -U letsencrypt > /dev/null
  37. -  printf .
  38. -  $VENV_BIN/pip install -U letsencrypt-apache > /dev/null
  39. -  if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
  40. +  VENV_LASTUPDATED=${VENV_UPDATEINTERVAL}
  41. +fi
  42. +
  43. +# Update letsencrypt and virtual environment dependencies if not done within
  44. +# the last $VENV_UPDATEINTERVAL seconds (default: not more often than once per day)
  45. +if [ ${VENV_LASTUPDATED} -lt ${VENV_UPDATEINTERVAL} ]; then
  46. +  printf "Skipping update check. Remove '${VENV_LASTUPDATE}' to enforce."
  47. +else
  48. +  printf "Updating letsencrypt and virtual environment dependencies..."
  49. +  if [ "$VERBOSE" = 1 ]  ; then
  50. +    echo
  51. +    $VENV_BIN/pip install -U setuptools
  52. +    $VENV_BIN/pip install -U pip
  53. +    $VENV_BIN/pip install -U letsencrypt letsencrypt-apache
  54. +    # nginx is buggy / disabled for now, but upgrade it if the user has
  55. +    # installed it manually
  56. +    if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
  57. +      $VENV_BIN/pip install -U letsencrypt letsencrypt-nginx
  58. +    fi
  59. +  else
  60. +    $VENV_BIN/pip install -U setuptools > /dev/null
  61. +    printf .
  62. +    $VENV_BIN/pip install -U pip > /dev/null
  63.      printf .
  64. -    $VENV_BIN/pip install -U letsencrypt-nginx > /dev/null
  65. +    # nginx is buggy / disabled for now...
  66. +    $VENV_BIN/pip install -U letsencrypt > /dev/null
  67. +    printf .
  68. +    $VENV_BIN/pip install -U letsencrypt-apache > /dev/null
  69. +    if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
  70. +      printf .
  71. +      $VENV_BIN/pip install -U letsencrypt-nginx > /dev/null
  72. +    fi
  73. +    echo
  74.    fi
  75. -  echo
  76. +  touch ${VENV_LASTUPDATE}
  77.  fi
  78.  
  79.  # Explain what's about to happen, for the benefit of those getting sudo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement