]>
Commit | Line | Data |
---|---|---|
e6799a92 PG |
1 | #!/bin/sh |
2 | # | |
3 | # rdate This shell script takes care of setting date from ntp server on startup | |
4 | # | |
5 | # chkconfig: 2345 11 89 | |
6 | # description: set time with rdate | |
7 | # processname: rdate | |
8 | ||
9 | # Source function library. | |
10 | . /etc/rc.d/init.d/functions | |
11 | ||
12 | # Source networking configuration. | |
13 | . /etc/sysconfig/network | |
14 | ||
15 | # Check that networking is up. | |
16 | if is_no "${NETWORKING}"; then | |
17 | msg_network_down rdate | |
18 | exit 1 | |
19 | fi | |
20 | ||
ded742b0 | 21 | SET_TIME=no |
22 | ||
23 | # Get service config | |
24 | if [ -f /etc/sysconfig/rdate ] ; then | |
25 | . /etc/sysconfig/rdate | |
26 | fi | |
27 | ||
e6799a92 PG |
28 | # See how we were called. |
29 | case "$1" in | |
30 | start|restart) | |
e6799a92 PG |
31 | # Check if we have to do anything: |
32 | if [ "$SET_TIME" = "yes" ]; then | |
33 | if [ -n "$RDATE_SERVER" ]; then | |
9a58508b | 34 | run_cmd "Setting time from remote server: $RDATE_SERVER" rdate -s -l $RDATE_SERVER |
e6799a92 PG |
35 | fi |
36 | fi | |
37 | ;; | |
38 | stop) | |
39 | # nothing to do | |
40 | ;; | |
41 | status) | |
2a59d035 PG |
42 | if [ -n "$RDATE_SERVER" ]; then |
43 | rdate $RDATE_SERVER | |
44 | echo -n "Local time: " | |
45 | date | |
46 | echo -n "Local machine hardware clock: " | |
47 | clock --show | |
48 | fi | |
e6799a92 PG |
49 | ;; |
50 | *) | |
51 | msg_usage "$0 {start|stop|restart|status}" | |
52 | exit 1 | |
53 | esac |