]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/init.d/ntp
0793927908f762bac2ace9a652793d7831b86c7e
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / ntp
1 #!/bin/sh
2 # Begin $rc_base/init.d/ntp
3
4 . /etc/sysconfig/rc
5 . $rc_functions
6
7 eval $(/usr/local/bin/readhash /var/ipfire/time/settings)
8
9 case "$1" in
10 start)
11 if [ "$ENABLESETONBOOT" == "on" ]; then
12 boot_mesg -n "Setting time on boot..."
13 pidof wpa_supplicant dhcpcd 2>&1 > /dev/null
14 if [ "${?}" == "0" ]; then
15 if [ ! -e /var/ipfire/red/active ]; then
16 boot_mesg ""
17 boot_mesg -n "Waiting for red connection"
18 for (( i=30; i>1; i-- )) do
19 if [ -e /var/ipfire/red/active ]; then
20 break;
21 fi
22 boot_mesg -n "."
23 sleep 2
24 done
25 sleep 5
26 fi
27 fi
28 if [ -e /var/ipfire/red/active ]; then
29 boot_mesg ""
30
31 host ping.ipfire.org > /dev/null 2>&1
32 if [ "${?}" != "0" ]; then
33 boot_mesg "DNS not work ... init with ntp.ipfire.org at 81.3.27.46 ..."
34 loadproc /usr/local/bin/settime 81.3.27.46
35 boot_mesg "Setting time on boot..."
36 fi
37
38 loadproc /usr/local/bin/settime $(cat /var/ipfire/time/settime.conf)
39 else
40 boot_mesg " ERROR! Not online!"
41 echo_warning
42 fi
43 fi
44
45 boot_mesg "Starting ntpd..."
46 loadproc /usr/bin/ntpd -Ap /var/run/ntpd.pid
47 ;;
48
49 stop)
50 boot_mesg "Stopping ntpd..."
51 killproc /usr/bin/ntpd
52 ;;
53
54 restart)
55 $0 stop
56 sleep 1
57 $0 start
58 ;;
59
60 status)
61 statusproc /usr/bin/ntpd
62 ;;
63
64 *)
65 echo "Usage: $0 {start|stop|restart|status}"
66 exit 1
67 ;;
68 esac
69
70 # End $rc_base/init.d/ntp