summaryrefslogtreecommitdiffstats
path: root/debian/chrony.dhcp
blob: f3dacd71cdbfbf3ca432abcd7c698e82899c6944 (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
CHRONY_SOURCEDIR=/run/chrony-dhcp
SERVERFILE=$CHRONY_SOURCEDIR/$interface.sources

chrony_config() {
    rm -f "$SERVERFILE"
    mkdir -p "$CHRONY_SOURCEDIR"
    for server in $new_ntp_servers; do
        echo "server $server iburst" >> "$SERVERFILE"
    done
    /usr/bin/chronyc reload sources > /dev/null 2>&1 || :
}

chrony_restore() {
    if [ -f "$SERVERFILE" ]; then
        rm -f "$SERVERFILE"
        /usr/bin/chronyc reload sources > /dev/null 2>&1 || :
    fi
}

case $reason in
    BOUND|RENEW|REBIND|REBOOT)
        chrony_config
        ;;
    EXPIRE|FAIL|RELEASE|STOP)
        chrony_restore
        ;;
esac