summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-misc/clockspeed/files/ntpclockset')
-rw-r--r--net-misc/clockspeed/files/ntpclockset75
1 files changed, 50 insertions, 25 deletions
diff --git a/net-misc/clockspeed/files/ntpclockset b/net-misc/clockspeed/files/ntpclockset
index 6657da712b33..4f6e89fcc3c0 100644
--- a/net-misc/clockspeed/files/ntpclockset
+++ b/net-misc/clockspeed/files/ntpclockset
@@ -1,31 +1,56 @@
#!/bin/bash
+# $Header: /var/cvsroot/gentoo-x86/net-misc/clockspeed/files/ntpclockset,v 1.1.1.1 2005/11/30 09:54:59 chriswhite Exp $
-if [ -z "${1}" ]
-then
- NTPSERVER=132.163.135.130
-else
- NTPSERVER="${1}"
-fi
+# Updates by Sascha Silbe
+
+usage() {
+ cat << EOF
+Usage: ntpclockset [options] <NTP server>
+Example: ntpclockset -q 192.168.0.1
+
+Options:
+ --quiet (-q) be quiet (only show errors)
+ --help (-h) show this text and exit
+EOF
+ exit 1
+}
+
+quiet=0
+NTPSERVER="pool.ntp.org"
-#display how much your clock is off by
-sntpclock $NTPSERVER > /tmp/sntpclock
+for curArg in "$@" ; do
+ case "${curArg}" in
+ -q|--quiet) quiet=1;;
+ -h|--help) usage;;
+ -*) echo "Invalid option '${curArg}'"
+ usage;;
+ *) NTPSERVER="${curArg}";;
+ esac
+done
-if [ "${?}" != "0" ]
-then
- echo ">>> Could not contact NTP server: $NTPSERVER" >&2
- exit 1
+tmpfile="`mktemp`"
+# display how much your clock is off by
+if ! sntpclock $NTPSERVER > ${tmpfile} ; then
+ echo "!!! Could not contact NTP server: $NTPSERVER" >&2
+ exit 2
fi
-echo ">>> Current clock sync:"
-cat /tmp/sntpclock | clockview
-echo
-echo -n ">>> Now setting clock..."
-cat /tmp/sntpclock | clockadd
-echo " done."
-#wite data to the hardware clock so it survives a reboot
-echo -n ">>> Writing time to hardware clock..."
-hwclock --systohc
-echo " done."
-echo
-echo ">>> New clock sync:"
-sntpclock $NTPSERVER | clockview
+if [ ${quiet} -eq 0 ] ; then
+ echo ">>> Current clock sync:"
+ cat ${tmpfile} | clockview
+ echo
+ echo -n ">>> Now setting clock ..."
+fi
+cat ${tmpfile} | clockadd
+if [ ${quiet} -eq 0 ] ; then
+ echo " [ok]"
+ echo -n ">>> Writing time to hardware clock ..."
+fi
+/sbin/hwclock --systohc
+if [ ${quiet} -eq 0 ] ; then
+ echo " [ok]"
+ echo
+ echo ">>> New clock sync:"
+ sntpclock $NTPSERVER | clockview
+fi
+rm -f ${tmpfile}