summaryrefslogtreecommitdiffstats
path: root/net/chrony/files/chrony.ntp-hotplug
blob: 06cf6e579efb9936289a0834a0e0b16d3117f401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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" ] }'