This commit is contained in:
Bruno Zell 2018-09-28 17:11:05 +02:00
parent 96897f8e37
commit 73851752f7
2 changed files with 9 additions and 9 deletions

View File

@ -23,15 +23,15 @@ for f in /scripts/startup/*.sh; do
done done
echo "Done with startup" echo "Done with startup"
last_sync_file="/etc/letsencrypt/last_sync.txt" last_renewal_file="/etc/letsencrypt/last_renewal.txt"
# Instead of trying to run `cron` or something like that, just sleep and run `certbot`. # Instead of trying to run `cron` or something like that, just sleep and run `certbot`.
while [ true ]; do while [ true ]; do
if [ is_sync_required $last_sync_file ]; then if [ is_renewal_required $last_renewal_file ]; then
# recreate the file to persist the last sync timestamp # Recreate the file to persist the last renewal timestamp
touch "$last_sync_file" touch "$last_renewal_file"
# run certbot to request all the ssl certs we can find # Run certbot to request all the ssl certs we can find
echo "Run certbot" echo "Run certbot"
/scripts/run_certbot.sh /scripts/run_certbot.sh
else else

View File

@ -76,15 +76,15 @@ get_certificate() {
--standalone --preferred-challenges http-01 --debug --standalone --preferred-challenges http-01 --debug
} }
is_sync_required() { is_renewal_required() {
if [ ! -e "$1" ]; then if [ ! -e "$1" ]; then
return true return true
fi fi
one_week_sec=604800 one_week_sec=604800
last_sync_sec=$(stat -c %Y "$1")
now_sec=$(date -d now +%s) now_sec=$(date -d now +%s)
last_sync_delta_sec=$(( ($now_sec - $last_sync_sec) )) last_renewal_sec=$(stat -c %Y "$1")
is_finshed_week_sec=$(( ($one_week_sec - $last_sync_delta_sec) )) last_renewal_delta_sec=$(( ($now_sec - $last_renewal_sec) ))
is_finshed_week_sec=$(( ($one_week_sec - $last_renewal_delta_sec) ))
return $is_finshed_week_sec -lt 0 return $is_finshed_week_sec -lt 0
} }