dyndns cron: validate that we're connected to the internet before triggering yunohost dyndns update

This commit is contained in:
Alexandre Aubin 2021-10-13 15:37:39 +02:00
parent c7038b0e59
commit 55bacd7405

View file

@ -105,7 +105,12 @@ EOF
if ls -l /etc/yunohost/dyndns/K*.private 2>/dev/null; then
cat >$pending_dir/etc/cron.d/yunohost-dyndns <<EOF
SHELL=/bin/bash
*/10 * * * * root : YunoHost DynDNS update; sleep \$((RANDOM\\%60)); test -e /var/run/moulinette_yunohost.lock || yunohost dyndns update >> /dev/null
# Every 10 minutes,
# - (sleep random 60 is here to spread requests over a 1-min window)
# - if ip.yunohost.org answers ping (basic check to validate that we're connected to the internet and yunohost infra aint down)
# - and if lock ain't already taken by another command
# - trigger yunohost dyndns update
*/10 * * * * root : YunoHost DynDNS update; sleep \$((RANDOM\\%60)); ! ping -q -W5 -c1 ip.yunohost.org >/dev/null 2>&1 || test -e /var/run/moulinette_yunohost.lock || yunohost dyndns update >> /dev/null
EOF
fi