]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/setclock
Merge branch 'initscripts-cleanup' of git://git.ipfire.org/people/jschlag/ipfire...
[ipfire-2.x.git] / src / initscripts / system / setclock
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
18 CLOCKPARAMS=
19
20 case ${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 date
34
35 if [ -e /var/log/messages ]; then
36 LOGTIMESTAMP=`stat --format "%y" /var/log/messages`
37 LOGTIME=`date +%s -d "$LOGTIMESTAMP"`
38 SYSTIME=`date +%s`
39 if [ $SYSTIME -lt $LOGTIME ]; then
40 boot_mesg "Warning! clock runs later than last log access. Check battery/rtc!"
41 date -s "$LOGTIMESTAMP"
42 echo_warning;
43 else
44 echo_ok;
45 fi
46 fi
47 ;;
48
49 stop)
50 boot_mesg "Setting hardware clock..."
51 hwclock --systohc ${CLOCKPARAMS} &>/dev/null
52 evaluate_retval
53 ;;
54
55 *)
56 echo "Usage: ${0} {start} {stop}"
57 ;;
58
59 esac