* Fixed problem when BASEDIR paths were given without a trailing '/'.
[linux_from_scratch.git] / bootscripts / contrib / new-boot-0.2 / sbin / init.d / runlevel.1 / setclock
blobb66c375583dfd3f843068aa802cacb86270b658c
1 #!/bin/sh
3 # init system time from RTC value
5 # NOTES:
6 # To adjust for the drift of the RTC, you have to issue the command
7 # hwclock --set --date=<exacttime>
8 # manually 2 times with a considerable time (several days) in between.
9 # The more drift you let accumulate the better hwclock can compute the
10 # drift.
12 #locate and source functions script
13 source `PATH=$INIT_D/:/sbin/init.d:/etc/init.d:/etc/rc.d type -p functions`
15 #in sysconfig, env. variable UTC is set to yes/true/1 if RTC set to GMT
16 source $sysconfig_clock
18 case "$1" in
19 start)
20 #need to write /etc/adjtime
21 #I guess setting clock will work even if /etc/adjtime can't be written,
22 #so don't exit_if_any_error
23 need $mounted_filesystems
25 echo 'Adjusting RTC and setting system time...'
26 CLOCKPARAMS="--hctosys"
27 case "$UTC" in
28 yes|true|1)
29 CLOCKPARAMS="$CLOCKPARAMS --utc"
31 *)
32 CLOCKPARAMS="$CLOCKPARAMS --localtime"
34 esac
35 hwclock --adjust && hwclock $CLOCKPARAMS
36 up_evaluate_retval || exit_if_any_error
38 stop)
41 exit 1
43 esac
45 exit 0