[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

New hwclock.sh for powerpc



I worked this script out to address the problem we have on powerpc with the different hardware clock programs.
This should use `clock' on Power Macs and `hwclock' on CHRP.
Please test it so I can add it to 'powerpc-utils' if it works.

For those who care, my plan is to have powerpc-utils divert the hwclock.sh that util-linux installs.

(I suggest renaming the old /etc/init.d/hwclock.sh out of the way before copying this one in its place.)

--- cut here ---
#
# hwclock.sh	Set and adjust the hardware clock, according to the UTC
#		setting in /etc/default/rcS (see also rcS(5)).
#

. /etc/default/rcS
case "$UTC" in
       no|"") UTCARG=no  ;;
       yes)   UTCARG=yes ;;
       *)     echo "$0: unknown UTC setting: \"$UTC\"" >&2 ;;
esac

Arch=$(awk '/machine/ {print $3}' /proc/cpuinfo)

case "$Arch" in
    CHRP)
	CLOCKPROG=hwclock
	ADJUSTARG=--adjust
	WRITEARG=--systohc
	SHOWARG=--show
	[ "$UTCARG" = yes ] && UTCARG="--utc"
    ;;
    PowerMac*|iMac*|Power[Bb]ook*)
	CLOCKPROG=clock
	ADJUSTARG=-a
	WRITEARG=-w
	SHOWARG=-r
	[ "$UTCARG" = yes ] && UTCARG="-u"
    ;;
    *)
    	exit 0
    ;;
esac

case "$1" in
	start)
		if [ ! -f /etc/adjtime ]
		then
			echo "0.0 0 0.0" > /etc/adjtime
		fi
		$CLOCKPROG $ADJUSTARG $UTCARG
		[ "$CLOCKPROG" = hwclock ] && $CLOCKPROG --hctosys
		#
		#	Now that /usr/share/zoneinfo should be available,
		#	announce the local time.
		#
		if [ "$VERBOSE" != no ]
		then
			echo
			echo "Local time: `date`"
			echo
		fi
		;;
	stop|restart|reload)
		$CLOCKPROG $WRITEARG $UTCARG
		if [ "$VERBOSE" != no ]
		then
			echo "Hardware clock updated to `date`."
		fi
		;;
	show)
		$CLOCKPROG $SLOWARG $UTCARG
		;;
	*)
		echo "Usage: hwclock.sh {start|stop|reload|show}" >&2
		echo " start sets kernel clock from hardware clock" >&2
echo " stop and reload set hardware clock from kernel clock" >&2
		echo " show displays the time from the hardware clock" >&2
		exit 1
		;;
esac
--
Joel Klecker (aka Espy)                    Debian GNU/Linux Developer
<URL:mailto:jk@espy.org>                 <URL:mailto:espy@debian.org>
<URL:http://web.espy.org/>               <URL:http://www.debian.org/>


Reply to: