call certbot only once
This commit is contained in:
parent
00d0b9b803
commit
f7668d4347
|
@ -24,38 +24,29 @@ done
|
||||||
echo "Done with startup"
|
echo "Done with startup"
|
||||||
|
|
||||||
last_sync_file="/etc/letsencrypt/last_sync.txt"
|
last_sync_file="/etc/letsencrypt/last_sync.txt"
|
||||||
|
|
||||||
if [ ! -e "$last_sync_file" ]; then
|
|
||||||
touch "$last_sync_file"
|
|
||||||
|
|
||||||
# run certbot to request all the ssl certs we can find
|
|
||||||
echo "Run first time certbot"
|
|
||||||
/scripts/run_certbot.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
one_week_sec=604800
|
one_week_sec=604800
|
||||||
|
|
||||||
# Instead of trying to run `cron` or something like that, just leep and run `certbot`.
|
# Instead of trying to run `cron` or something like that, just sleep and run `certbot`.
|
||||||
while [ true ]; do
|
while [ true ]; do
|
||||||
# Sleep for 1 week
|
|
||||||
sleep 604810 &
|
|
||||||
SLEEP_PID=$!
|
|
||||||
|
|
||||||
last_sync_sec=$(stat -c %Y "$last_sync_file")
|
last_sync_sec=$(stat -c %Y "$last_sync_file")
|
||||||
now_sec=$(date -d now +%s)
|
now_sec=$(date -d now +%s)
|
||||||
runned_sec=$(( ($now_sec - $last_sync_sec) ))
|
runned_sec=$(( ($now_sec - $last_sync_sec) ))
|
||||||
is_finshed_week_sec=$(( ($one_week_sec - $runned_sec) ))
|
is_finshed_week_sec=$(( ($one_week_sec - $runned_sec) ))
|
||||||
|
|
||||||
echo "Not run_certbot.sh"
|
echo "Not run_certbot.sh"
|
||||||
if [ $is_finshed_week_sec -lt 0 ]; then
|
if [ ! -e "$last_sync_file" ] || [ $is_finshed_week_sec -lt 0 ]; then
|
||||||
# recreate the file
|
# recreate the file
|
||||||
touch "$last_sync_file"
|
touch "$last_sync_file"
|
||||||
|
|
||||||
# re-run certbot
|
# 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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Sleep for 1 week
|
||||||
|
sleep 604810 &
|
||||||
|
SLEEP_PID=$!
|
||||||
|
|
||||||
# Wait on sleep so that when we get ctrl-c'ed it kills everything due to our trap
|
# Wait on sleep so that when we get ctrl-c'ed it kills everything due to our trap
|
||||||
wait "$SLEEP_PID"
|
wait "$SLEEP_PID"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue