summaryrefslogtreecommitdiffstats
path: root/contrib/ken_gillett_1
blob: 48b7999541af1f5fea9672a5077a5d846674241e (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
#
# chronyd      This shell script takes care of starting and stopping
#              chronyd (NTP daemon).
#
# chkconfig: 45 80 20
# description: chronyd is the NTP daemon.

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

PREDIR="/usr/local"
CHRONYD=$PREDIR"/sbin/chronyd"
CHRONYC=$PREDIR"/bin/chronyc"

[ -x $CHRONYD -a -x $CHRONYC -a -f /etc/chrony.conf ] || exit 0

dochrony() {
	if [ -z "$(pidofproc chronyd)" ]; then
		echo -e "\n\tchronyd not running\n\n"
		exit 2
	fi
	KEY=`awk '$1 == "commandkey" {print $2; exit}' /etc/chrony.conf`
	PASSWORD=`awk '$1 == '$KEY' {print $2; exit}' /etc/chrony/keys`

	$CHRONYC <<- EOF
		password $PASSWORD
		$@
		quit
	EOF
}

# make the first parameter' lower case
set - `echo $1 | awk '{print tolower($1)}';shift;echo "$@"`

# Expand any shortcuts.
case "$1" in
   on|1)
	set - "online"
	;;
   off|0)
	set - "offline"
esac

# See how we were called.
case "$1" in
   start)
         # Start daemons.
         echo -n "Starting chronyd: "
         daemon $CHRONYD
	if [ $? -eq 0 ]; then
		echo $(pidofproc chronyd) > /var/run/chronyd.pid
		touch /var/lock/subsys/chronyd
	fi
         echo
         ;;
   stop)
         # Stop daemons.
         echo -n "Shutting down chronyd: "
	killproc chronyd
         echo
         rm -f /var/lock/subsys/chronyd
         ;;
   status)
	status chronyd
	;;
   restart|reload)
	$0 stop
	$0 start
	;;
   condrestart)
	if [ -f /var/lock/subsys/chronyd ]; then
		$0 stop
		$0 start
	fi
	;;
   "")
	echo "Usage: chronyd 
{start|stop|restart|reload|condrestart|status|[on|off]line etc}"
	exit 1
	;;
 
accheck|cmdaccheck|clients|manual|rtcdata|sources|sourcestats|tracking|clients)
	dochrony "$@"
	;;
   *)
         echo -n "Chrony $1: "
	dochrony "$@" > /dev/null
	[ $? -eq 0 ] && echo_success || echo_failure
	echo
esac

exit 0