Advertisement
claudio4

Nginx, Dehydrated cron script

Oct 2nd, 2016
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.03 KB | None | 0 0
  1. #!/bin/bash
  2. ###VARS###
  3. LETSENCRYPT_PATH='/srv/letsencrypt/'
  4. CF_USERNAME="mail@example.com"
  5. CF_TOKEN="TOKEN"
  6. LOGFILE='/srv/letsencrypt/cron.error.log'
  7. TIMEFORMAT="[$(date +"%y-%m-%d %H-%M")]"
  8. #Please don't change
  9. ERROR="true"
  10. ###COMMANDS###
  11. if [[ "$CF_USERNAME" == "" || "$CF_TOKEN" == "" ]]; then
  12.   echo "$TIMEFORMAT Please check file vars" >> $LOGFILE
  13.   exit 1
  14. fi
  15. export PROVIDER=cloudflare
  16. export LEXICON_CLOUDFLARE_USERNAME=$CF_USERNAME
  17. export LEXICON_CLOUDFLARE_TOKEN=$CF_TOKEN
  18. $LETSENCRYPT_PATH/dehydrated.sh --cron -f $LETSENCRYPT_PATH/config.sh && ERROR="false"
  19. if [ "$ERROR" == "true" ]; then
  20.   echo "$TIMEFORMAT Renew fail please check your config" >> $LOGFILE
  21.   unset PROVIDER
  22.   unset LEXICON_CLOUDFLARE_USERNAME
  23.   unset LEXICON_CLOUDFLARE_TOKEN  
  24.   exit 1
  25. else
  26.   ERROR=true
  27. fi
  28. unset PROVIDER
  29. unset LEXICON_CLOUDFLARE_USERNAME
  30. unset LEXICON_CLOUDFLARE_TOKEN
  31. nginx -t && nginx -s reload && ERROR="false"
  32. if [ "$ERROR" == "true" ]; then
  33.   echo "$TIMEFORMAT Nginx fail and it was not restarted" >> $LOGFILE
  34.   exit 1
  35. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement