summaryrefslogtreecommitdiff
blob: 21d00ae949cab49fd30187b552aeb0566a267bcb (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# /space/gentoo/cvsroot/gentoo-x86/net-misc/ntp/files/ntpd.rc6,v 1.3 2002/03/24 14:25:31 azarah Exp

depend() {
	need net
}

CFGFILE=/etc/chrony/chrony.conf

checkconfig() {

	# Note that /etc/chrony.keys is *NOT* checked. This
	# is because the user may have specified another key
	# file, and we don't want to force the user to use that
	# exact name for the key file.
	if [ ! -f $CFGFILE ]
	then
		eerror "Please create $cfgfile and the"
		eerror "chrony key file (usually /etc/chrony/chrony.keys)"
		eerror "by using the"
		eerror ""
		eerror "        chrony.conf.example"
		eerror "        chrony.keys.example"
		eerror ""
		eerror "files (from the documentation directory)"
		eerror "as templates."
		return 1
        else
                # Actually, I tried it, and chrony seems to ignore the pidfile
                # option. I'm going to leave it here anyway, since you never
                # know if it might be handy
                PIDFILE=`awk '/^ *pidfile/{print $2}' $CFGFILE`
	fi
	return 0
}

start() {
	checkconfig || return $?
	
	[ -n "$PIDFILE" ] || PIDFILE=/var/run/chronyd.pid
	
	ebegin "Starting chronyd"
	start-stop-daemon --start --quiet \
		--exec /usr/sbin/chronyd \
	        --pidfile $PIDFILE \
                -- -f $CFGFILE
	eend $? "Failed to start chronyd"
}

stop() {
	checkconfig || return $?
	
	[ -n "$PIDFILE" ] || PIDFILE=/var/run/chronyd.pid

	ebegin "Stopping chronyd"
	start-stop-daemon --stop --quiet \
		--pidfile $PIDFILE
	eend $? "Failed to stop chronyd"
}