44 lines
832 B
Bash
Executable File
44 lines
832 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Called on ip-up-lan event on a LAN interface
|
|
# $LANID, LAN interface index
|
|
restart_ntp() {
|
|
# Sanity check on NTP command
|
|
local ntpcmd=/var/bewan/ntp.d/ntp.sh
|
|
[ ! -f $ntpcmd ] && return
|
|
|
|
# Sanity check on interface type
|
|
if [ "${Services_Time_NTPInterfaceType:-}" != "LANDevice" ]; then
|
|
return
|
|
fi
|
|
|
|
# Sanity check on interface
|
|
local lanid=${LANID:-}
|
|
if [ "$lanid" = '' ]; then
|
|
return
|
|
fi
|
|
|
|
# Specific wan interface ?
|
|
local iface=`cat /var/bewan/ntp.d/interface 2>/dev/null`
|
|
if [ "$iface" = '' ]; then
|
|
return
|
|
else
|
|
# Use specific interface
|
|
local found=0
|
|
local i
|
|
for i in `strip $iface`; do
|
|
if [ "$i" = "$lanid" ]; then
|
|
found=1
|
|
fi
|
|
done
|
|
if [ "$found" = 0 ]; then
|
|
return
|
|
fi
|
|
fi
|
|
|
|
# Execute NTP request in background
|
|
start-stop-daemon -S -b -x $ntpcmd -- lan $lanid
|
|
}
|
|
|
|
restart_ntp
|