Commit | Line | Data |
---|---|---|
23240f04 SM |
1 | #!/bin/sh |
2 | ||
3 | # 2014/04/10 Lisa | |
4 | # Modified this script to use the usn pool from pool.ntp.org. More | |
5 | # Info on this can be found at the project page: http://www.pool.ntp.org/zone/us | |
6 | ||
7 | if [ -d /proc/sys/xen ]; then | |
8 | echo 1 > /proc/sys/xen/independent_wallclock; | |
9 | fi | |
10 | ||
11 | servers='0.us.pool.ntp.org 1.us.pool.ntp.org 2.us.pool.ntp.org 3.us.pool.ntp.org' | |
12 | ||
13 | ||
14 | /usr/sbin/ntpdate $servers >/dev/null 2>&1 | |
15 | rc="$?" | |
16 | ||
17 | if [ $rc -ne 0 ] ; then | |
18 | /usr/sbin/ntpdate $servers 2>&1 \ | |
19 | | grep -q ': the NTP socket is in use, exiting$' | |
20 | if [ $? -eq 0 ] ; then | |
21 | exit 0 # machine is running NTP daemon | |
22 | fi | |
23 | for backoff in 15 30 60 300 ; do | |
24 | sleep $backoff | |
25 | /usr/sbin/ntpdate $servers >/dev/null 2>&1 | |
26 | rc="$?" | |
27 | [ $rc -eq 0 ] && break | |
28 | done | |
29 | fi | |
30 | ||
31 | if [ $rc -ne 0 ] ; then | |
32 | echo "ntpdate failed, trying again" | |
33 | # try again, and be verbose | |
34 | date | |
35 | ping -c 3 $servers | |
36 | /usr/sbin/ntpdate $servers 2>&1 | |
37 | if [ $? -ne 0 ] ; then | |
38 | # DNS failure? | |
39 | sleep 300 | |
40 | date | |
41 | ping -c 3 $servers | |
42 | /usr/sbin/ntpdate $server 2>&1 | |
43 | if [ $? -ne 0 ] ; then | |
44 | exit | |
45 | fi | |
46 | fi | |
47 | fi | |
48 | ||
49 | if [ -e /dev/rtc ]; then | |
50 | /sbin/hwclock -w | |
51 | fi |