blob: 631370cf3e5db4c056794b79159a7536050e5b59 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
NTPDATE_CONF=/etc/default/ntpdate
NTPDATE_DHCP_CONF=/var/lib/ntpdate/default.dhcp
ntp_servers_setup_remove() {
rm -f $NTPDATE_DHCP_CONF
}
ntp_servers_setup_add() {
if [ -e $NTPDATE_DHCP_CONF ] && [ "$new_ntp_servers" = "$old_ntp_servers" ]; then
return
fi
if [ -z "$new_ntp_servers" ]; then
ntp_servers_setup_remove
return
fi
tmp=$(mktemp "$NTPDATE_DHCP_CONF.XXXXXX") || return
chmod --reference=$NTPDATE_CONF $tmp
chown --reference=$NTPDATE_CONF $tmp
(
echo "# NTP server entries received from DHCP server"
echo "NTPSERVERS='$new_ntp_servers'"
) >>$tmp
mv $tmp $NTPDATE_DHCP_CONF
}
ntp_servers_setup() {
case $reason in
BOUND|RENEW|REBIND|REBOOT)
ntp_servers_setup_add
;;
EXPIRE|FAIL|RELEASE|STOP)
ntp_servers_setup_remove
;;
esac
}
ntp_servers_setup
|