Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ###VARS###
- LETSENCRYPT_PATH='/srv/letsencrypt/'
- CF_USERNAME="mail@example.com"
- CF_TOKEN="TOKEN"
- LOGFILE='/srv/letsencrypt/cron.error.log'
- TIMEFORMAT="[$(date +"%y-%m-%d %H-%M")]"
- #Please don't change
- ERROR="true"
- ###COMMANDS###
- if [[ "$CF_USERNAME" == "" || "$CF_TOKEN" == "" ]]; then
- echo "$TIMEFORMAT Please check file vars" >> $LOGFILE
- exit 1
- fi
- export PROVIDER=cloudflare
- export LEXICON_CLOUDFLARE_USERNAME=$CF_USERNAME
- export LEXICON_CLOUDFLARE_TOKEN=$CF_TOKEN
- $LETSENCRYPT_PATH/dehydrated.sh --cron -f $LETSENCRYPT_PATH/config.sh && ERROR="false"
- if [ "$ERROR" == "true" ]; then
- echo "$TIMEFORMAT Renew fail please check your config" >> $LOGFILE
- unset PROVIDER
- unset LEXICON_CLOUDFLARE_USERNAME
- unset LEXICON_CLOUDFLARE_TOKEN
- exit 1
- else
- ERROR=true
- fi
- unset PROVIDER
- unset LEXICON_CLOUDFLARE_USERNAME
- unset LEXICON_CLOUDFLARE_TOKEN
- nginx -t && nginx -s reload && ERROR="false"
- if [ "$ERROR" == "true" ]; then
- echo "$TIMEFORMAT Nginx fail and it was not restarted" >> $LOGFILE
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement