mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
At startup there's a race situation where "chronyc waitsync" (and thus chrony-hotplug) will exit right away because it can't bind to loopback. This change tries quite hard to make chrony-hotplug wait for loopback to come up before running chronyc. Fixes #28434. Signed-off-by: Florian Wagner <florian@wagner-flo.de>
28 lines
778 B
Bash
28 lines
778 B
Bash
#!/bin/sh
|
|
|
|
# Find interface corresponding to lo device
|
|
IFACE=$(ubus call network.interface dump | \
|
|
jsonfilter -e '@.interface[@.device="lo"].interface')
|
|
|
|
# During boot network.interface dump can be empty; try UCI instead
|
|
if [ -z "${IFACE}" ]; then
|
|
. /lib/functions.sh
|
|
handle_interface () {
|
|
local iface="$1"
|
|
local device
|
|
config_get device "${iface}" device
|
|
[ "${device}" = "lo" ] && IFACE=${iface}
|
|
}
|
|
config_load network
|
|
config_foreach handle_interface interface
|
|
fi
|
|
|
|
[ -z "${IFACE}" ] || \
|
|
ubus -t 30 wait_for network.interface.${IFACE}
|
|
|
|
# Wait for sync for up to 5 minutes and notify other services
|
|
|
|
/usr/bin/chronyc waitsync 300 1 0.0 1 || exit 0
|
|
|
|
ubus call hotplug.ntp call '{ "env": [ "ACTION=stratum" ] }'
|