[Lunar-commits] CVS: moonbase/net/ntp POST_INSTALL,1.5,1.6

Jerry Lundström prox at lunar-linux.org
Fri Aug 20 10:27:14 GMT 2004


Update of /var/cvs/lunar/moonbase/net/ntp
In directory dbguin.lunar-linux.org:/tmp/cvs-serv3331

Modified Files:
	POST_INSTALL 
Log Message:
reworked code, added check for ping since perldude has lost his ping =)

Index: POST_INSTALL
===================================================================
RCS file: /var/cvs/lunar/moonbase/net/ntp/POST_INSTALL,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- POST_INSTALL	28 Mar 2004 13:56:50 -0000	1.5
+++ POST_INSTALL	20 Aug 2004 10:27:12 -0000	1.6
@@ -1,43 +1,52 @@
 if ! grep -q server /etc/ntp.conf; then
-  SRV_LIST=$(mktemp -p /tmp -t "ntp.$$.candidates.XXXXXXX")
-  cat > $SRV_LIST << EOF 
-time.nrc.ca
-timelord.uregina.ca
-ntp.tuxfamily.net
-ntp1.tuxfamily.net
-ntp2.tuxfamily.net
-ntp.univ-lyon1.fr
-zg2.ntp.carnet.hr
-st.ntp.carnet.hr
-ri.ntp.carnet.hr
-os.ntp.carnet.hr
-fartein.ifi.uio.no
-ntp.shim.org
-time.ijs.si
-time.ijs.si
-ntp2a.mcc.ac.uk
-ntp2b.mcc.ac.uk
-time-server.ndo.com
-clock.sjc.he.net
-ntp1.linuxmedialabs.com
-ntp-1.cso.uiuc.edu
-ntp-2.cso.uiuc.edu
-gilbreth.ecn.purdue.edu
-harbor.ecn.purdue.edu
-clock.psu.edu
-ntp-2.ece.cmu.edu
-ntp-1.vt.edu
-EOF
-  
-  for i in `cat $SRV_LIST`; do 
-    echo -n $i;  ping -c 2 $i | sed 's/time=//' | grep octet |          \
-    gawk '{sum += $7} END {avg=sum/FNR; printf "%20.6f \n", avg}';      \
-  done |                                                                \
-  grep -v '0\.0' | sort -n +1 | head -4 |                               \
-  gawk '{printf "server %s\n", $1}' >> /etc/ntp.conf 
-  rm -f $SRV_LIST
-  
-  echo "low ping time servers have been added to  /etc/ntp.conf "
-else
-  echo "no servers added to /etc/ntp.conf"
+
+  SRV_LIST="time.nrc.ca \
+timelord.uregina.ca \
+ntp.tuxfamily.net \
+ntp1.tuxfamily.net \
+ntp2.tuxfamily.net \
+ntp.univ-lyon1.fr \
+zg2.ntp.carnet.hr \
+st.ntp.carnet.hr \
+ri.ntp.carnet.hr \
+os.ntp.carnet.hr \
+fartein.ifi.uio.no \
+ntp.shim.org \
+time.ijs.si \
+time.ijs.si \
+ntp2a.mcc.ac.uk \
+ntp2b.mcc.ac.uk \
+time-server.ndo.com \
+clock.sjc.he.net \
+ntp1.linuxmedialabs.com \
+ntp-1.cso.uiuc.edu \
+ntp-2.cso.uiuc.edu \
+gilbreth.ecn.purdue.edu \
+harbor.ecn.purdue.edu \
+clock.psu.edu \
+ntp-2.ece.cmu.edu \
+ntp-1.vt.edu \
+ntp1.sth.netnod.se \
+ntp2.sth.netnod.se \
+ntp1.gbg.netnod.se \
+ntp2.gbg.netnod.se \
+ntp1.mmo.netnod.se \
+ntp2.mmo.netnod.se"
+
+  if which ping >/dev/null 2>&1; then
+    echo -n "Checking for low ping ntp servers:"  
+    for srv in $SRV_LIST; do
+      roundtrip=`ping -c 2 $srv | grep round-trip | sed -re 's%.*= *[0-9\.]+/([0-9\.]+)/.*%\1%'`
+      echo "$roundtrip $srv"
+    done | sort -n -t ' ' -k 1 | head -n 5 | while read roundtrip srv; do
+      echo -n " $srv($roundtrip ms)"
+      echo "server $srv" >> /etc/ntp.conf
+    done
+  else
+    echo "Unable to check for lowest ping ntp servers, adding all"
+    for srv in $SRV_LIST; do
+      echo "server $srv" >> /etc/ntp.conf
+    done
+  fi
+
 fi



More information about the Lunar-commits mailing list