summaryrefslogtreecommitdiffstats
path: root/usr/local/sbin
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2012-05-16 10:48:26 -0400
committerjim-p <jimp@pfsense.org>2012-05-16 10:48:26 -0400
commit0b8e9d38d8bc8a53b4e6bb503f487dae425ca3fd (patch)
tree876c344332e9ed7c0f970e41f44aafeae455f14c /usr/local/sbin
parent11e069064b417cacbd56f7f557b131af3c10fb86 (diff)
downloadpfsense-0b8e9d38d8bc8a53b4e6bb503f487dae425ca3fd.zip
pfsense-0b8e9d38d8bc8a53b4e6bb503f487dae425ca3fd.tar.gz
On its own, ntpd does not sync fast enough at bootup, so bring back the ntpdate sync but improve it so it can't get stuck forever.
Diffstat (limited to 'usr/local/sbin')
-rwxr-xr-xusr/local/sbin/ntpdate_sync_once.sh27
1 files changed, 19 insertions, 8 deletions
diff --git a/usr/local/sbin/ntpdate_sync_once.sh b/usr/local/sbin/ntpdate_sync_once.sh
index 7aa20a8..f4a5256 100755
--- a/usr/local/sbin/ntpdate_sync_once.sh
+++ b/usr/local/sbin/ntpdate_sync_once.sh
@@ -1,19 +1,30 @@
#!/bin/sh
NOTSYNCED="true"
-SERVER=`cat /cf/conf/config.xml | grep timeservers | cut -d">" -f2 | cut -d"<" -f1`
-pkill -f ntpdate_sync_once.sh
+MAX_ATTEMPTS=3
+SERVER=`/bin/cat /cf/conf/config.xml | /usr/bin/grep timeservers | /usr/bin/cut -d">" -f2 | /usr/bin/cut -d"<" -f1`
+/bin/pkill -f ntpdate_sync_once.sh
-while [ "$NOTSYNCED" = "true" ]; do
+ATTEMPT=1
+# Loop until we're synchronized, but for a set number of attempts so we don't get stuck here forever.
+while [ "$NOTSYNCED" = "true" ] && [ ${ATTEMPT} -le ${MAX_ATTEMPTS} ]; do
# Ensure that ntpd and ntpdate are not running so that the socket we want will be free.
- killall ntpd 2>/dev/null
- killall ntpdate
+ /usr/bin/killall ntpd 2>/dev/null
+ /usr/bin/killall ntpdate 2>/dev/null
sleep 1
- ntpdate -s -t 5 $SERVER
+ /usr/sbin/ntpdate -s -t 5 ${SERVER}
if [ "$?" = "0" ]; then
NOTSYNCED="false"
+ else
+ sleep 5
+ ATTEMPT=`expr ${ATTEMPT} + 1`
fi
- sleep 5
done
-/usr/local/sbin/ntpd -g -c /var/etc/ntpd.conf \ No newline at end of file
+if [ "$NOTSYNCED" = "true" ]; then
+ echo "Giving up on time sync after ${MAX_ATTEMPTS} attempts." | /usr/bin/logger -t ntp;
+fi
+
+if [ -f /var/etc/ntpd.conf ]; then
+ /usr/sbin/ntpd -g -c /var/etc/ntpd.conf
+fi \ No newline at end of file
OpenPOWER on IntegriCloud