summaryrefslogtreecommitdiffstats
path: root/sbin/init.d/ntp
blob: 87353481b9ed69341c2d68e05c58c3dd2c50a772 (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
#!/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	# not used anymore
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
}

# execute a forced resynchronisation to sync servers
function do_update {
    if [ "$opt_sync_servers" ]; then
	ntpdate -t 2 -u $opt_sync_servers
    fi
}

load_config