]>
Commit | Line | Data |
---|---|---|
73d9a908 MT |
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} | |
73d9a908 MT |
17 | |
18 | CLOCKPARAMS= | |
19 | ||
73d9a908 MT |
20 | case ${1} in |
21 | start) | |
1313b031 | 22 | |
73d9a908 | 23 | boot_mesg "Setting system clock..." |
1313b031 AF |
24 | |
25 | # udev not create the rtc symlink if rtc is in the kernel | |
26 | if [ ! -e /dev/rtc ]; then | |
5292c03d AF |
27 | if [ -e /dev/rtc0 ]; then |
28 | ln -s rtc0 /dev/rtc | |
29 | fi | |
1313b031 AF |
30 | fi |
31 | ||
73d9a908 | 32 | hwclock --hctosys ${CLOCKPARAMS} &>/dev/null |
5292c03d AF |
33 | if [ ! ${?} == 0 ]; then |
34 | if [ ! -z /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 | |
73d9a908 MT |
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 | *) | |
0721f5a6 | 52 | echo "Usage: ${0} {start} {stop}" |
73d9a908 MT |
53 | ;; |
54 | ||
55 | esac |