* [gentoo-embedded] sysvinit: sanetime for boards without an rtc?
@ 2011-07-23 17:10 Christopher Friedt
2011-07-28 7:56 ` Peter Volkov
0 siblings, 1 reply; 4+ messages in thread
From: Christopher Friedt @ 2011-07-23 17:10 UTC (permalink / raw
To: gentoo-embedded
[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]
Hi folks,
I have a couple of boards that ship by default without RTC devices and
boot time always incurs the following nasty messages in multiplicity.
...
* One of the files in /etc/{conf.d,init.d} or /etc/rc.conf
* has a modification time in the future!
* One of the files in /etc/{conf.d,init.d} or /etc/rc.conf
* has a modification time in the future!
...
A very simple solution was be to maintain an /etc/sanetime file that
would set a time other than the epoch at boot. Something within the
last day, month, year, or decade even ;-)
There's a fallback sanetime in /etc/init.d/sanetime just in case
/etc/sanetime doesn't exist, and it works naturally because time is
monotonically increasing (last I checked).
Also, it would seem that /etc/clock doesn't fail gracefully when there
is no rtc, even when there are provisions to 'fakeit' for other
reasons.
...
* Cannot access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.Can
not access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.
* Failed to set clock You will need to set the clock yourself
[ !! ]
...
It was just a matter of adding an /etc/init.d/sanetime script,
slightly patching /etc/init.d/clock & /sbin/rc (AFAIK this only works
for sysvinit, not openrc).
See the attached files.
Cheers,
C
PS: I was going to file a bug report, but it seems that the
certificate for bugs.gentoo.org has become invalid ATM.
[-- Attachment #2: add-sanetime-to-sbin-rc.patch --]
[-- Type: application/octet-stream, Size: 385 bytes --]
--- /sbin/rc_orig 2011-07-23 12:52:40.908885277 -0400
+++ /sbin/rc 2011-07-23 12:52:51.276070368 -0400
@@ -166,7 +166,7 @@
CRITICAL_SERVICES="${CRITICAL_SERVICES} ${x##*/}"
done
else
- CRITICAL_SERVICES="checkroot modules checkfs localmount clock bootmisc"
+ CRITICAL_SERVICES="checkroot modules checkfs localmount sanetime clock bootmisc"
fi
export CRITICAL_SERVICES
[-- Attachment #3: add-sanetime-to-etc-init.d-clock.patch --]
[-- Type: application/octet-stream, Size: 548 bytes --]
--- /etc/init.d/clock_orig 2011-07-23 12:58:07.447945952 -0400
+++ /etc/init.d/clock 2011-07-23 12:59:29.072944745 -0400
@@ -5,7 +5,7 @@
opts="save"
depend() {
- need localmount
+ need sanetime localmount
}
setupopts() {
@@ -79,7 +79,8 @@
setupopts
if [[ ${fakeit} -ne 1 && -e /proc/modules && ! -e /dev/rtc ]] ; then
- modprobe rtc &> /dev/null || modprobe genrtc &> /dev/null
+ modprobe rtc &> /dev/null || modprobe genrtc &> /dev/null \
+ || fakeit=1
fi
ebegin "Setting system clock using the hardware clock [${TBLURB}]"
[-- Attachment #4: sanetime --]
[-- Type: application/octet-stream, Size: 878 bytes --]
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# get this number with 'date +%s' - it's just a fallback sanetime
# but really anything is better than the epoch
SANETIME="1310410279"
SANETIME_FILE=/etc/sanetime
depend() {
need localmount
}
write_sanetime() {
mkdir -p $(dirname $SANETIME_FILE)
echo "$1" > $SANETIME_FILE
}
dofunc() {
local Now Then
Now="$(date +%s 2>&1)"
if [ -e $SANETIME_FILE ]; then
Then="$(cat $SANETIME_FILE)"
else
Then=$SANETIME
fi
if [ $Now -gt $Then ]; then
write_sanetime $Now
else
write_sanetime $Then
date -s @$Then >/dev/null 2>&1
fi
}
start() {
ebegin "Initializing sanetime"
(
dofunc start
)
eend $? "Error initializing sanetime"
}
stop() {
ebegin "Saving sanetime"
(
dofunc stop
)
eend $? "Failed to save sanetime"
}
# vim:ts=4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-embedded] sysvinit: sanetime for boards without an rtc?
2011-07-23 17:10 [gentoo-embedded] sysvinit: sanetime for boards without an rtc? Christopher Friedt
@ 2011-07-28 7:56 ` Peter Volkov
2011-07-28 13:28 ` Christopher Friedt
0 siblings, 1 reply; 4+ messages in thread
From: Peter Volkov @ 2011-07-28 7:56 UTC (permalink / raw
To: gentoo-embedded
Hi Christopher.
В Сбт, 23/07/2011 в 13:10 -0400, Christopher Friedt пишет:
> I have a couple of boards that ship by default without RTC devices
>
> PS: I was going to file a bug report, but it seems that the
> certificate for bugs.gentoo.org has become invalid ATM.
Please open a bug report. Certificates should be valid now. Probably
it's good idea to show this problem to openrc guys, so they could
review/suggest solution.
--
Peter.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-embedded] sysvinit: sanetime for boards without an rtc?
2011-07-28 7:56 ` Peter Volkov
@ 2011-07-28 13:28 ` Christopher Friedt
2011-07-29 15:35 ` Ed W
0 siblings, 1 reply; 4+ messages in thread
From: Christopher Friedt @ 2011-07-28 13:28 UTC (permalink / raw
To: gentoo-embedded
Done [1]!
It was google chrome that wouldn't give me the option to continue with
the bug report, so I just used a different browser.
Apparently though, a similar mechanism already exists for OpenRC
called swclock instead of hwclock, and they said I should just do
this:
rc-update del hwclock boot
rc-update add swclock boot
Still, that only exists for OpenRC, AFAIK, not the regular baselayout,
so any images that don't use OpenRC would need to be updated.
Thanks,
C
[1] https://bugs.gentoo.org/show_bug.cgi?id=376249
On Thu, Jul 28, 2011 at 3:56 AM, Peter Volkov <pva@gentoo.org> wrote:
> Hi Christopher.
>
> В Сбт, 23/07/2011 в 13:10 -0400, Christopher Friedt пишет:
>> I have a couple of boards that ship by default without RTC devices
>>
>> PS: I was going to file a bug report, but it seems that the
>> certificate for bugs.gentoo.org has become invalid ATM.
>
> Please open a bug report. Certificates should be valid now. Probably
> it's good idea to show this problem to openrc guys, so they could
> review/suggest solution.
>
> --
> Peter.
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-embedded] sysvinit: sanetime for boards without an rtc?
2011-07-28 13:28 ` Christopher Friedt
@ 2011-07-29 15:35 ` Ed W
0 siblings, 0 replies; 4+ messages in thread
From: Ed W @ 2011-07-29 15:35 UTC (permalink / raw
To: gentoo-embedded
On 28/07/2011 14:28, Christopher Friedt wrote:
> Apparently though, a similar mechanism already exists for OpenRC
> called swclock instead of hwclock, and they said I should just do
> this:
>
> rc-update del hwclock boot
> rc-update add swclock boot
You beat me too it!
Yes, this just bumps the clock forward monotonically. Usually this is a
useful improvement, but you may also need a cron job to touch your clock
file if you don't expect the shutdown script to run...
Openrc has quite a few nice tweaks tucked away in it. Worth looking
through the more obscure options
Cheers
Ed W
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-07-29 15:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-23 17:10 [gentoo-embedded] sysvinit: sanetime for boards without an rtc? Christopher Friedt
2011-07-28 7:56 ` Peter Volkov
2011-07-28 13:28 ` Christopher Friedt
2011-07-29 15:35 ` Ed W
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox