#!/bin/sh # rc.clock: Set or save the current system time. # Sanity check: if [ ! -x /sbin/hwclock ]; then exit 126; fi # Fix RTC clock on an ISA machine: fix_rtc_clock() { grep -qw rtc /proc/ioports || OPTION=--directisa } start() { fix_rtc_clock # Set the hardware clock to UTC or localtime: if grep -q ^UTC /etc/sysconfig/hardwareclock 2> /dev/null ; then echo "Setting time from the hardware clock (UTC)." /sbin/hwclock $OPTION --utc --hctosys else echo "Setting time from the hardware clock (localtime)." /sbin/hwclock $OPTION --localtime --hctosys fi } stop() { fix_rtc_clock # Set the hardware clock to UTC or localtime: if grep -q ^UTC /etc/sysconfig/hardwareclock 2> /dev/null ; then echo "Saving time from the system to the hardware clock (UTC)." /sbin/hwclock $OPTION --utc --systohc else echo "Saving time from the system to the hardware clock (localtime)." /sbin/hwclock $OPTION --localtime --systohc fi } # Options: case "$1" in start) start ;; stop) stop ;; *) echo "Usage: $0 start,stop" exit 1 ;; esac