Control: tag -1 + patch pending
[Petter Reinholdtsen]
> We could use something like this to set it:
>
> echo 0 > /sys/class/rtc/rtc0/wakealarm
> date -u --date "Jul 1, 2008 10:32:00" +%s > /sys/class/rtc/rtc0/wakealarm
I've commited this patch to fix it. Need to test it a bit before
uploading.
Index: shutdown-at-night
===================================================================
--- shutdown-at-night (revision 81777)
+++ shutdown-at-night (revision 81778)
@@ -37,12 +37,17 @@
return 1
}
+whentowakeup() {
+ wakeuptime=$1
+ # Spread the BIOS wakeup time across a 20 minute period, to avoid
+ # all of them waking up at the same time, killing a fuse.
+ echo $(( $(date -u +%s -d "tomorrow $wakeuptime") - 600 + $RANDOM % 1200))
+}
+
nvramwakeup() {
#
http://www.vdr-portal.de/board/thread.php?threadid=75582&sid=b7aced20e710aef12ffa56b5197fe168
wakeuptime=$1
- # Spread the BIOS wakeup time across a 20 minute period, to avoid all of
them
- # waking up at the same time, killing a fuse.
- when=$(( $(date +%s -d "tomorrow $wakeuptime") - 600 + $RANDOM % 1200))
+ when=$(whentowakeup $wakeuptime)
# Make sure HW clock is correct, as it is used to decide when to
# wake up.
@@ -60,6 +65,25 @@
fi
}
+# This method might not work if the hardware clock is updated during
+# shutdown. Changing /etc/default/hwclock to list HWCLOCKACCESS=yes
+# to disable it.
+acpiwakeup() {
+ wakeuptime="$1"
+ if [ -e /sys/class/rtc/rtc0/wakealarm ] ; then
+ when=$(whentowakeup $wakeuptime)
+
+ # First reset alarm
+ echo 0 > /sys/class/rtc/rtc0/wakealarm
+
+ # Next, set it to our selected time
+ echo $when > /sys/class/rtc/rtc0/wakealarm
+ return 0
+ else
+ return 1
+ fi
+}
+
prepare_wakeonlan() {
interface="$(/sbin/route -n | awk '/^0\.0\.0\.0 / { print $8 }')"
ethtool -s $interface wol g
@@ -97,6 +121,7 @@
if type nvram-wakeup >/dev/null 2>&1 ; then
nvramwakeup $wakeuptime
fi
+ acpiwakeup $waketime
prepare_wakeonlan || fatal "unable to enable wake-on-lan - aborting
shutdown."
shutdown -h 5 "Unused host being turned off for the night (cron)." <
/dev/null > /dev/null 2>&1 &
else
--
Happy hacking
Petter Reinholdtsen
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]