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