Hi, Mark Purcell hat am Sat 16. May, 14:57 (+1000) geschrieben: > This is a common problem on powerpc ibook's once the NVRAM battery goes flat. > > Apparently this has been discussed with upstream: > https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/23426/comments/18 > > Mark > > > This patch is a quick hack, but you get the idea: > > --- hwclockfirst.sh.orig 2009-05-16 14:26:54.000000000 +1000 > +++ hwclockfirst.sh 2009-05-16 14:23:11.000000000 +1000 > @@ -38,6 +38,12 @@ > . /lib/lsb/init-functions > verbose_log_action_msg() { [ "$VERBOSE" = no ] || log_action_msg "$@"; } > > + if `/sbin/hwclock | /bin/grep -q 1904`; then > + log_warning_msg "NVRAM Battery Clock flat (date 1904)" > + log_action_msg "Setting hwclock date to 2009-5-16" > + hwclock --set --date 2009-5-16 > + fi > +
I would much more prefer to get prompted for the correct time, because with a wrong time fsck fail due to the last fsck is in the future. But I don't know how to do prompting in init scripts correctly. And to guess if the hardware clock is wrong I think we can look at the installation time of the module directory of the kernel. /boot/vmlinux-$(uname -r) is possible, too. I propose this patch: --- /etc/init.d/hwclockfirst.sh 2009-04-18 01:03:46.000000000 +0200 +++ hwclockfirst.sh 2009-05-16 17:52:48.675695938 +0200 @@ -73,7 +73,17 @@ NOADJ="" fi - if [ "$FIRST" != yes ]; then + if [ "$FIRST" = yes ]; then + date_of_mod_dir=$(stat --format=%X /lib/modules/"$(uname -a)") + date_of_hwclock=$(date --date="$(hwclock --show $GMT \ + $HWCLOCKPARS $BADYEAR)" +%s) + if [ "$date_of_hwclock" -lt "$date_of_mod_dir" ]; then + log_begin_msg 'Please provide the current time as "yyyymmdd hhmm": ' + read time && \ + test -n "$time" && \ + hwclock --set --date="$time" $GMT $HWCLOCKPARS $NOADJ + fi + else # Uncomment the hwclock --adjust line below if you want # hwclock to try to correct systematic drift errors in the # Hardware Clock. Bye, Jörg. -- Manchmal denke ich, das sicherste Indiz dafür, daß anderswo im Universum intelligentes Leben existiert, ist, daß niemand versucht hat, mit uns Kontakt aufzunehmen. (Calvin und Hobbes)
signature.asc
Description: Digital signature http://en.wikipedia.org/wiki/OpenPGP