2020-09-19 04:20:19 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# ntp hotplug script for travelmate
|
2022-08-20 15:51:01 +00:00
|
|
|
# Copyright (c) 2020-2022 Dirk Brenken (dev@brenken.org)
|
2020-09-19 04:20:19 +00:00
|
|
|
# This is free software, licensed under the GNU General Public License v3.
|
|
|
|
|
|
|
|
# set (s)hellcheck exceptions
|
2021-07-25 19:41:58 +00:00
|
|
|
# shellcheck disable=3023
|
2020-09-19 04:20:19 +00:00
|
|
|
|
|
|
|
trm_init="/etc/init.d/travelmate"
|
|
|
|
trm_ntpfile="/var/state/travelmate.ntp"
|
|
|
|
trm_logger="$(command -v logger)"
|
|
|
|
|
2021-07-25 19:41:58 +00:00
|
|
|
if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && "${trm_init}" enabled; then
|
2020-11-26 21:39:15 +00:00
|
|
|
{
|
2021-07-25 19:41:58 +00:00
|
|
|
if flock -xn 1001; then
|
|
|
|
"${trm_logger}" -p "info" -t "trm-ntp [${$}]" "get ntp time sync" 2>/dev/null
|
2020-11-26 21:39:15 +00:00
|
|
|
"${trm_init}" restart
|
|
|
|
fi
|
|
|
|
} 1001>"${trm_ntpfile}"
|
2020-09-19 04:20:19 +00:00
|
|
|
fi
|