diff options
author | Mike Frysinger <vapier@gentoo.org> | 2004-08-31 02:00:57 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2004-08-31 02:00:57 +0000 |
commit | f3b9482d1ec1ec4e0b1a40a5e2a8c2a1d43fe087 (patch) | |
tree | 5dfdd9e294e2ac0a6d65e1f61bd25d18ec30a336 /net-misc/clockspeed/files | |
parent | ver bump #61768 (diff) | |
download | historical-f3b9482d1ec1ec4e0b1a40a5e2a8c2a1d43fe087.tar.gz historical-f3b9482d1ec1ec4e0b1a40a5e2a8c2a1d43fe087.tar.bz2 historical-f3b9482d1ec1ec4e0b1a40a5e2a8c2a1d43fe087.zip |
add more options to the wrapper script #61821
Diffstat (limited to 'net-misc/clockspeed/files')
-rw-r--r-- | net-misc/clockspeed/files/ntpclockset | 75 |
1 files changed, 49 insertions, 26 deletions
diff --git a/net-misc/clockspeed/files/ntpclockset b/net-misc/clockspeed/files/ntpclockset index 61efd48e928e..7240d793756b 100644 --- a/net-misc/clockspeed/files/ntpclockset +++ b/net-misc/clockspeed/files/ntpclockset @@ -1,33 +1,56 @@ #!/bin/bash +# $Header: /var/cvsroot/gentoo-x86/net-misc/clockspeed/files/ntpclockset,v 1.3 2004/08/31 02:00:57 vapier 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" -tmpfile=`mktemp` -#display how much your clock is off by -sntpclock $NTPSERVER > ${tmpfile} +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 ${tmpfile} | clockview -echo -echo -n ">>> Now setting clock..." +if [ ${quiet} -eq 0 ] ; then + echo ">>> Current clock sync:" + cat ${tmpfile} | clockview + echo + echo -n ">>> Now setting clock ..." +fi cat ${tmpfile} | 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 -rm ${tmpfile} +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} |