]> git.pld-linux.org Git - packages/ntp.git/blob - ntpdate.init
ntpd requires libgcc_s.so.1
[packages/ntp.git] / ntpdate.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 # Source networking configuration.
12 . /etc/sysconfig/network
13
14 # if not specified in config
15 NTPDATE_USER="ntp"
16
17 # Source ntp configuration
18 . /etc/sysconfig/ntpdate
19
20 # Check that networking is up.
21 if is_yes "${NETWORKING}"; then
22         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
23                 msg_network_down "ntpdate"
24                 exit 1
25         fi
26 else
27         exit 0
28 fi
29
30 ntpdate_background() {
31         /usr/sbin/ntpdate -s ${NTPDATE_USER:+-U $NTPDATE_USER} $NTPDATE_OPTIONS $NTPDATE_SERVERS || return $?
32
33         if is_yes "$SYNC_HWCLOCK"; then
34                 /sbin/hwclock --systohc
35         fi
36 }
37
38 start() {
39         show "Syncing time with ntpdate (backgrounding)"
40         ntpdate_background &
41         touch /var/lock/subsys/ntpdate
42         ok
43 }
44
45 stop() {
46         rm -f /var/lock/subsys/ntpdate
47 }
48
49 RETVAL=0
50 # See how we were called.
51 case "$1" in
52   start)
53         start
54         ;;
55   stop)
56         stop
57         ;;
58   restart|force-reload)
59         stop
60         start
61         ;;
62   *)
63         msg_usage "$0 {start|restart|force-reload}"
64         exit 3
65 esac
66
67 exit $RETVAL
This page took 0.062402 seconds and 3 git commands to generate.