aboutsummaryrefslogtreecommitdiff
path: root/net/travelmate/files/travelmate_ntp.hotplug
diff options
context:
space:
mode:
authorDirk Brenken <dev@brenken.org>2020-11-26 22:39:15 +0100
committerDirk Brenken <dev@brenken.org>2020-11-26 22:39:15 +0100
commit84f20951b32b8652c3fce37c23d795583718ac84 (patch)
tree7d6f58fa83953febf670ae7460c992590ba1e488 /net/travelmate/files/travelmate_ntp.hotplug
parent6dc567270e896c15e05e4b7b736c6e26f7e3b896 (diff)
travelmate: fix possible race condition
* prevent possible duplicate script execution due to multiple ntp events in parallel Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'net/travelmate/files/travelmate_ntp.hotplug')
-rwxr-xr-xnet/travelmate/files/travelmate_ntp.hotplug14
1 files changed, 9 insertions, 5 deletions
diff --git a/net/travelmate/files/travelmate_ntp.hotplug b/net/travelmate/files/travelmate_ntp.hotplug
index 4a31d5946..2a215e4ba 100755
--- a/net/travelmate/files/travelmate_ntp.hotplug
+++ b/net/travelmate/files/travelmate_ntp.hotplug
@@ -22,10 +22,14 @@ f_log()
fi
}
-if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && \
- [ "$("${trm_init}" enabled; printf "%u" ${?})" = "0" ]
+if [ "${ACTION}" = "stratum" ] && [ ! -f "${trm_ntpfile}" ] && [ "$("${trm_init}" enabled; printf "%u" ${?})" = "0" ]
then
- > "${trm_ntpfile}"
- f_log "info" "get ntp time sync"
- "${trm_init}" restart
+ {
+ flock -xn 1001
+ if [ "$?" = "0" ]
+ then
+ f_log "info" "get ntp time sync"
+ "${trm_init}" restart
+ fi
+ } 1001>"${trm_ntpfile}"
fi