void-packages/templates/ntp/files/ntpd.cron-hourly

13 lines
243 B
Bash

#!/bin/sh
#
# Restarts ntpd if no connected peers are found.
#
ntpq_cmd=/usr/bin/ntpq
ntpd_initd=/etc/init.d/ntpd
if [ ! -x $ntpq_cmd -o ! -x $ntpd_initd ]; then
exit 0
fi
$ntpq_cmd -np | grep '^\*' >/dev/null || (/etc/init.d/ntpd restart)