]> git.pld-linux.org Git - packages/ntp.git/blob - ntp-client.init
- use functions
[packages/ntp.git] / ntp-client.init
1 #!/bin/sh
2 #
3 # ntp           This shell script synchronizes time with ntpdate (NTP client)
4 #
5 # chkconfig:    2345 55 10
6 # description:  ntp is the NTP client.
7
8 # Source function library.
9 . /etc/rc.d/init.d/functions
10
11 # Source networking configuration.
12 . /etc/sysconfig/network
13
14 # Source ntp configuration
15 . /etc/sysconfig/ntp
16
17 # Check that networking is up.
18 if is_yes "${NETWORKING}"; then
19         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
20                 msg_network_down ntp
21                 exit 1
22         fi
23 else
24         exit 0
25 fi
26
27 start() {
28         show "Syncing time with ntpdate (backgrounding)"
29         daemon --fork /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS
30         RETVAL=$?
31         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntp
32 }
33
34 stop() {
35         rm -f /var/lock/subsys/ntp
36 }
37
38 RETVAL=0
39 # See how we were called.
40 case "$1" in
41 start)
42         start
43         ;;
44 stop)
45         stop
46         ;;
47 restart|force-reload)
48         stop
49         start
50         ;;
51 cronsettime)
52         is_yes "$NTPDATE_CRON" && /usr/sbin/ntpdate -s $NTPDATE_OPTIONS $NTPDATE_SERVERS > /dev/null 2>&1
53         RETVAL=$?
54         ;;
55 *)
56         msg_usage "$0 {start|restart|force-reload}"
57         exit 3
58 esac
59
60 exit $RETVAL
This page took 0.036395 seconds and 4 git commands to generate.