]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/ntp
ntp: init with hardcoded ip if dns not work
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / ntp
CommitLineData
91dc1bfc
MT
1#!/bin/sh
2# Begin $rc_base/init.d/ntp
3
91dc1bfc
MT
4. /etc/sysconfig/rc
5. $rc_functions
6
ed0a0ba8
CS
7eval $(/usr/local/bin/readhash /var/ipfire/time/settings)
8
91dc1bfc
MT
9case "$1" in
10 start)
ed0a0ba8 11 if [ "$ENABLESETONBOOT" == "on" ]; then
0a79ec45 12 boot_mesg -n "Setting time on boot..."
829435be
AF
13 pidof wpa_supplicant dhcpcd 2>&1 > /dev/null
14 if [ "${?}" == "0" ]; then
b3aa7a12
AF
15 if [ ! -e /var/ipfire/red/active ]; then
16 boot_mesg ""
96e31c98 17 boot_mesg -n "Waiting for red connection"
b3aa7a12
AF
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
0a79ec45
AF
27 fi
28 if [ -e /var/ipfire/red/active ]; then
29 boot_mesg ""
2d646e98
AF
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
0a79ec45
AF
38 loadproc /usr/local/bin/settime $(cat /var/ipfire/time/settime.conf)
39 else
b3aa7a12 40 boot_mesg " ERROR! Not online!"
0a79ec45
AF
41 echo_warning
42 fi
43 fi
ed0a0ba8 44
91dc1bfc 45 boot_mesg "Starting ntpd..."
6f300951 46 loadproc /usr/bin/ntpd -Ap /var/run/ntpd.pid
91dc1bfc
MT
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 ;;
68esac
69
70# End $rc_base/init.d/ntp