blob: 3d1878925423101ded98a425c5060a661639a760 (
plain) (
blame)
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
46
47
48
49
50
51
52
53
54
55
56
|
#!/bin/bash
. `dirname $0`/functions
option config standard_option /etc/ntp/ntp.conf
option keys standard_option /etc/ntp/ntp.keys
option pidfile reserved_option /var/run/ntp.pid
option hard_sync boolean_option
option force_sync boolean_option
option sync_servers long_option
option procname reserved_option ntpd
option bin reserved_option /usr/sbin/ntpd
option cmdline reserved_option '$bin -c $opt_config -p $pidfile -k $opt_keys'
# assign values after all the options have been read
function fct_end_section {
if [ -z "$opt_sync_servers" ]; then
valueof $opt_config server > /dev/null
opt_sync_servers=$REPLY
fi
}
# perform a forced synchronisation before starting the daemon
function fct_pre_start {
local driftfile
valueof $opt_config driftfile > /dev/null 2>&1 ; driftfile=$REPLY
if [ -n "$driftfile" -a ! -e "${driftfile%/*}" ] ; then
mkdir -p ${driftfile%/*}
fi
if [ "$opt_force_sync" = "1" -a "$opt_sync_servers" ]; then
ntpdate -u -t 2 $opt_sync_servers
fi
if [ "$opt_hardsync" = "1" ]; then
/sbin/hwclock -w --noadjfile --localtime
fi
}
# perform a forced synchronisation before stopping the daemon
function fct_pre_stop {
if [ "$opt_hardsync" = "1" ]; then
/sbin/hwclock -w --noadjfile --localtime
fi
}
# execute a forced resynchronisation to sync servers
function do_update {
if [ "$opt_sync_servers" ]; then
ntpdate -t 2 -u $opt_sync_servers
/sbin/hwclock -w --noadjfile --localtime
fi
}
load_config
|