]> git.pld-linux.org Git - packages/ntp.git/blame - ntp.init
- start with prio 16 (like rdate)
[packages/ntp.git] / ntp.init
CommitLineData
b9935303 1#!/bin/sh
2#
9862853a 3# ntpd This shell script takes care of starting and stopping
f0279210 4# ntp (NTP daemon).
b9935303 5#
6fccad43 6# chkconfig: 2345 55 10
9862853a 7# description: ntpd is the NTP daemon.
b9935303 8
9# Source function library.
10. /etc/rc.d/init.d/functions
11
12# Source networking configuration.
13. /etc/sysconfig/network
14
d9ddddbb
ER
15# default user if not overriden by config
16NTPD_USER="ntp"
17
5820dfda 18# Source ntp configuration
9862853a 19. /etc/sysconfig/ntpd
5820dfda 20
b9935303 21# Check that networking is up.
f0279210 22if is_yes "${NETWORKING}"; then
0284b494 23 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
d9ddddbb 24 msg_network_down "ntpd"
f0279210 25 exit 1
26 fi
27else
28 exit 0
29fi
b9935303 30
93c97cc8 31[ -f /etc/ntp/ntp.conf ] || exit 0
b9935303 32
365ec4e7 33start() {
b9935303 34 # Check if the service is already running?
9862853a 35 if [ ! -f /var/lock/subsys/ntpd ]; then
d9ddddbb
ER
36 msg_starting "ntpd"
37 daemon /usr/sbin/ntpd -c /etc/ntp/ntp.conf -p /var/run/ntpd.pid ${NTPD_USER:+-u $NTPD_USER} $NTPD_OPTIONS
966bd92b 38 RETVAL=$?
9862853a 39 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd
966bd92b 40 else
d9ddddbb 41 msg_already_running "ntpd"
b9935303 42 fi
365ec4e7
ER
43}
44
45stop() {
9862853a 46 if [ -f /var/lock/subsys/ntpd ]; then
d9ddddbb 47 msg_stopping "ntpd"
68000f77 48 killproc ntpd
9862853a 49 rm -f /var/lock/subsys/ntpd
966bd92b 50 else
d9ddddbb 51 msg_not_running "ntpd"
ee2f7289 52 fi
365ec4e7
ER
53}
54
3130aa68
ER
55condrestart() {
56 if [ -f /var/lock/subsys/ntpd ]; then
57 stop
58 start
59 else
d9ddddbb 60 msg_not_running "ntpd"
3130aa68
ER
61 RETVAL=$1
62 fi
63}
64
0d2671b6
JK
65upstart_controlled
66
365ec4e7
ER
67RETVAL=0
68# See how we were called.
69case "$1" in
70 start)
71 start
72 ;;
73 stop)
74 stop
ee2f7289 75 ;;
3130aa68
ER
76 restart)
77 stop
78 start
79 ;;
80 # NB! don't remove 'condrestart': dhcpcd calls this
81 try-restart|condrestart)
82 condrestart 0
83 ;;
84 force-reload)
85 condrestart 7
86 ;;
b9935303 87 status)
cea25d01 88 status ntpd
dfecda58 89 exit $?
b9935303 90 ;;
b9935303 91 *)
3130aa68 92 msg_usage "$0 {start|stop|restart|try-restart|force-reload|condrestart|status}"
dfecda58 93 exit 3
b9935303 94esac
95
f0279210 96exit $RETVAL
This page took 0.041497 seconds and 4 git commands to generate.