From 91af6eaabc132ccd0f1972f265b412666e40b25d Mon Sep 17 00:00:00 2001 From: Valder Gallo Date: Wed, 27 Jun 2018 20:13:11 -0300 Subject: [PATCH] update datetime --- scripts/entrypoint.sh | 11 +++++++++++ scripts/util.sh | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index b6445bf..0bc1011 100644 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -26,6 +26,17 @@ for f in /scripts/startup/*.sh; do done echo "Done with startup" +now=$(date) +last_sync_file="/etc/letsencrypt/last_sync.txt" + +if [[ ! -e "$last_sync_file" ]]; then + mkdir -p /Scripts + touch "$last_sync_file" +fi + +last_sync=$(stat -c %y "$last_sync_file") +updated_days=$(( ($(date -d now +%s) - $(date -d last_sync +%s) )/(60*60*24) )) + # Instead of trying to run `cron` or something like that, just leep and run `certbot`. while [ true ]; do # Sleep for 1 week diff --git a/scripts/util.sh b/scripts/util.sh index 4585fa9..7e44201 100644 --- a/scripts/util.sh +++ b/scripts/util.sh @@ -63,14 +63,14 @@ get_certificate() { STAGING_URL='https://acme-staging.api.letsencrypt.org/directory' if [[ ! "${IS_STAGING}" = "1" ]]; then - LETSENCRYPT_URL=STAGING_URL + letsencrypt_url=STAGING_URL echo "Staging on" else - LETSENCRYPT_URL=PRODUCTION_URL + letsencrypt_url=PRODUCTION_URL echo "Production on" fi certbot certonly --agree-tos --keep -n --text --email $2 --server \ - $LETSENCRYPT_URL -d $1 --http-01-port 1337 \ + $letsencrypt_url -d $1 --http-01-port 1337 \ --standalone --standalone-supported-challenges http-01 --debug }