]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame_incremental - src/initscripts/init.d/setclock
udev: remove /var/run mount from initskript.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / setclock
... / ...
CommitLineData
1#!/bin/sh
2########################################################################
3# Begin $rc_base/init.d/setclock
4#
5# Description : Setting Linux Clock
6#
7# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8#
9# Version : 00.00
10#
11# Notes :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
17
18CLOCKPARAMS=
19
20case ${1} in
21 start)
22
23 boot_mesg "Setting system clock..."
24
25 # udev not create the rtc symlink if rtc is in the kernel
26 if [ ! -e /dev/rtc ]; then
27 if [ -e /dev/rtc0 ]; then
28 ln -s rtc0 /dev/rtc
29 fi
30 fi
31
32 hwclock --hctosys ${CLOCKPARAMS} &>/dev/null
33 if [ ! ${?} == 0 ]; then
34 if [ -s /var/log/messages ]; then
35 boot_mesg -n "No RTC found, set time to last log accesstime ... "
36 DATE=`stat --format "%y" /var/log/messages | cut -d" " -f1`
37 TIME=`stat --format "%y" /var/log/messages | sed -e "s|\..*||g" | cut -d" " -f2`
38 date -s $DATE > /dev/null
39 date -s $TIME
40 fi
41 fi
42 evaluate_retval
43 ;;
44
45 stop)
46 boot_mesg "Setting hardware clock..."
47 hwclock --systohc ${CLOCKPARAMS} &>/dev/null
48 evaluate_retval
49 ;;
50
51 *)
52 echo "Usage: ${0} {start} {stop}"
53 ;;
54
55esac