From 6f3b4c5edc6dfdd301d80929cb35e316fa742144 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Tue, 3 Jul 2012 00:46:19 +0200 Subject: hwclock: warn on discrepancy between /etc/adjtime and /etc/rc.conf about the timezone of the RTC Also, move from /var/lib/hwclock/adjtime to /etc/adjtime. This must be fixed in util-linux too. Signed-off-by: Tom Gundersen --- rc.sysinit | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'rc.sysinit') diff --git a/rc.sysinit b/rc.sysinit index 1106503..13b2b22 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -50,16 +50,17 @@ esac if [[ $HWCLOCK_PARAMS ]]; then stat_busy "Adjusting system time and setting kernel timezone" - # Adjust the system time for timezone offset if rtc is not in UTC - # 1. Make creation time on device nodes sane (FS#8665) - # 2. Filesystem checks can depend on system time - # 3. This also sets the kernel time zone, used by e.g. vfat - # If TIMEZONE is not set in rc.conf, the timezone stored in /etc/localtime - # is used. If HARDWARECLOCK is not set in rc.conf, the value in - # /var/lib/hwclock/adjfile is used (in this case /var can not be a separate - # partition). + # Adjust the system time for timezone offset if rtc is not in UTC, as + # filesystem checks can depend on system time. This also sets the kernel + # time zone, used by e.g. vfat. + # If TIMEZONE is not set in rc.conf, the timezone stored in /etc/localtime + # is used. If HARDWARECLOCK is not set in rc.conf, the value in + # /etc/adjfile is used. + [[ $TIMEZONE ]] && export TZ=$TIMEZONE + hwclock $HWCLOCK_PARAMS && stat_done || stat_fail + unset TZ fi @@ -148,6 +149,20 @@ stat_busy "Saving dmesg Log" fi (( $? == 0 )) && stat_done || stat_fail +if [[ -f /etc/adjtime ]]; then + ( read ; read ; read ADJTIME) < /etc/adjtime + + if [[ $ADJTIME == 'LOCAL' ]]; then + if [[ $HARDWARECLOCK == 'UTC' ]]; then + printf "${C_FAIL}/etc/rc.conf says the RTC is in UTC, but /etc/adjtime says it is in localtime.\n${C_OTHER}." + fi + else + if [[ $HARDWARECLOCK == 'LOCALTIME' ]]; then + printf "${C_FAIL}/etc/rc.conf says the RTC is in localtime, but hwclock (/etc/adjtime) thinks it is in UTC.\n${C_OTHER}." + fi + fi +fi + run_hook sysinit_end # End of file -- cgit v1.2.3