#!/bin/sh ######################################################################## # Begin $rc_base/init.d/setclock # # Description : Setting Linux Clock # # Authors : Gerard Beekmans - gerard@linuxfromscratch.org # # Version : 00.00 # # Notes : # ######################################################################## . /etc/sysconfig/rc . ${rc_functions} CLOCKPARAMS= case ${1} in start) boot_mesg "Setting system clock..." # udev not create the rtc symlink if rtc is in the kernel if [ ! -e /dev/rtc ]; then if [ -e /dev/rtc0 ]; then ln -s rtc0 /dev/rtc fi fi hwclock --hctosys ${CLOCKPARAMS} &>/dev/null if [ ! ${?} == 0 ]; then if [ -s /var/log/messages ]; then boot_mesg -n "No RTC found, set time to last log accesstime ... " DATE=`stat --format "%y" /var/log/messages | cut -d" " -f1` TIME=`stat --format "%y" /var/log/messages | sed -e "s|\..*||g" | cut -d" " -f2` date -s $DATE > /dev/null date -s $TIME fi fi evaluate_retval ;; stop) boot_mesg "Setting hardware clock..." hwclock --systohc ${CLOCKPARAMS} &>/dev/null evaluate_retval ;; *) echo "Usage: ${0} {start} {stop}" ;; esac