Hallo,
ich habe ein Skript zusammengestellt (hauptsächlich aus Bestandteilen von Matthias Schwarzott - gentoo). Damit wird beim Shutdown der nächste wakeup gesetzt. Das Besondere:
- die Aufwachzeit wird nur gesetzt, wenn diese noch nicht von VDR gesetzt wurde (d.h. wenn man über LIRC bzw. svdrpsend.pl hitk power beendet werden diese Zeiten nich nochmal geschrieben)
- es werden die Konfigurationsdateien /etc/conf.d/vdr.shutdown (z.b.) eingelesen und ausgewertet
- man kann über die Variable BootBeforeREC einstellen, wie lange vor der Aufnahme der VDR gebootet werden soll (in Sekunden ohne Einheit)
- Aufwachzeiten werden automatisch für rtc, acpi und nvram Methoden unterstützt
Wichtig dabei ist nur, dass das Skript VOR vdr beendet wird, damit svdrpsend.pl noch den Timer abfragen kann.
Aja, das Skript wurde für Gentoo geschrieben. Man kann es aber mit ein paar Kenntnissen leicht an seine eigene Distribution anpassen.
edit: das skipt muss nun nicht mehr vor vdr gestartet werden. Wenn vdr schon beendet ist, dann wird die timers.conf direkt ausgelesen.
edit2: kleinere Änderungen am Skript. Bei den If-Anweisungen für rtc- und acpi-wakup
Schöner gruß
noname_gentoo
#!/sbin/runscript
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: based on acpi-wakeup.sh and rtc-wakeup by Matthias Schwarzott <zzam at gmx dot de>$
opts="${opts} start stop"
depend() {
after vdr
}
#[ -r /etc/conf.d/vdr.shutdown ] && source /etc/conf.d/vdr.shutdown
: ${TIMERS_CONF:="/etc/vdr/timers.conf"}
checkUTC() {
unset clock
unset CLOCK
local f
for f in /etc/conf.d/hwclock /etc/conf.d/clock /etc/rc.conf; do
if [ -f "${f}" ]; then
. "${f}"
break
fi
done
clock="${clock:-${CLOCK}}"
[ "${clock}" = "UTC" ]
}
wakeup() {
[ -r /usr/share/vdr/inc/shutdown-functions.sh ] && source /usr/share/vdr/inc/shutdown-functions.sh
: ${RTC_ALARM:="/sys/class/rtc/rtc0/wakealarm"}
: ${PROC_ALARM:="/proc/acpi/alarm"}
: ${NVRAM_WAKEUP:="/usr/bin/nvram-wakeup"}
: ${NONE_WAKEUP_IGNORE_TIMER:="no"}
checkUTC && dateparam="-u"
method="${1}"
timestamp="${2}"
clock_timestamp="$(date ${dateparam} -d @${timestamp} +%T)"
date_timestamp="$(date ${dateparam} -d @${timestamp} +%F)"
case "${method}" in
"rtc")
if [ -w "${RTC_ALARM}" ] ; then
if ! grep -q "\(alrm_time...${clock_timestamp}\)" /proc/driver/rtc || \
! grep -q "\(alrm_date...${date_timestamp}\)" /proc/driver/rtc || \
! grep -q "\(alarm_IRQ...yes\)" /proc/driver/rtc
then
# clear old time
echo 0 > "${RTC_ALARM}"
if [ "${Next}" != 0 ]; then
# maybe this needs to be adjusted if bios time is not in UTC
echo "${timestamp}" > "${RTC_ALARM}"
einfo " rtc: Wakeup time set to ${date_timestamp} ${clock_timestamp}"
fi
else
einfo " rtc: Wakeup time already set to ${date_timestamp} ${clock_timestamp}"
fi
else
ewarn " rtc: ERROR Can not access acpi-rtc-clock."
fi
;;
"acpi")
if [ -w "${PROC_ALARM}" ] ; then
if ! grep -q "\(alrm_time...${clock_timestamp}\)" /proc/driver/rtc || \
! grep -q "\(alrm_date...${date_timestamp}\)" /proc/driver/rtc || \
! grep -q "\(alarm_IRQ...yes\)" /proc/driver/rtc
then
# write time to RTC now, as it may disable wakeup if done after writing alarm time
if [ -x /etc/init.d/hwclock ]; then
/etc/init.d/hwclock --quiet save
else
/etc/init.d/clock --quiet save
fi
if [ "${Next}" != 0 ]; then
# This hopefully deactivates wakeup
echo "2003-10-20 99:00:00" > "${PROC_ALARM}"
fi
checkUTC && dateparam="-u"
timestr=$(date ${dateparam} --date="1970-01-01 UTC ${timestamp} seconds" +"%Y-%m-%d %H:%M:00")
[ -z "${timestr}" ] && ewarn " acpi: ERROR date did not return a string"
# write 2 times (some bioses need this)
echo "${timestr}" > "${PROC_ALARM}"
echo "${timestr}" > "${PROC_ALARM}"
einfo " acpi: Wakeup time set to ${date_timestamp} ${clock_timestamp}"
else
einfo " acpi: Wakeup time already set to ${date_timestamp} ${clock_timestamp}"
fi
else
ewarn " acpi: ERROR Can not access ${PROC_ALARM}."
fi
;;
"nvram")
if [ ! -x "${NVRAM_WAKEUP}" ]; then
ewarn " nvram: no nvram-wakeup installed"
else
CMD="${NVRAM_WAKEUP} --syslog"
[ -n "${NVRAM_CONFIG}" ] && CMD="${CMD} -C ${NVRAM_CONFIG}"
[ -n "${NVRAM_EXTRA_OPTIONS}" ] && CMD="${CMD} ${NVRAM_EXTRA_OPTIONS}"
CMD="${CMD} -s ${timestamp}"
${CMD}
# analyse
case $PIPESTATUS in
0)
einfo " nvram: Wakeup time set to ${date_timestamp} ${clock_timestamp}"
;;
1)
# all went ok - new date and time set.
#
# *** but we need to reboot. ***
einfo " nvram: Wakeup time set to ${date_timestamp} ${clock_timestamp}"
printf "" > "${shutdown_data_dir}"/shutdown-need-reboot
;;
2)
# something went wrong
ewarn " nvram: Something went wrong, please check your config files of nvram-wakeup"
;;
*)
# should not happen anyway.
ewarn " nvram: Something went wrong, should never happen"
;;
esac
fi
;;
"none")
if [ "${Next}" != 0 ]; then
# it is not possible to wakeup the system!
if yesno "${NONE_WAKEUP_IGNORE_TIMER}"; then
# ignoring set timers
:
else
# Aborting
ewarn " none: You have some timer set. System will not wakeup on its own!"
fi
fi
;;
esac
}
start() {
#be very quiet
:
}
stop() {
ebegin "VDR: setting wakeup time"
if service_started vdr; then
# time the system should be up
Next="$(/usr/bin/svdrpsend.pl -d localhost NEXT abs|grep 250 |cut -f3 -d' '|tr -d '\r')"
else
# time the system should be up
next_timersconf=$(sort -k 3,4 -t : ${TIMERS_CONF} | head -n 1 | cut -d':' -f3,4)
checkUTC || dateparam="-u"
Next=$(date ${dateparam} --date "${next_timersconf/:/ }" +%s)
fi
# boot 5min (=300s) before recording
: ${BootBeforeREC:="300"}
timestamp=$(($Next-$BootBeforeREC))
WAKEUP_METHOD="${WAKEUP_METHOD:-rtc acpi nvram none}"
for method in ${WAKEUP_METHOD} ; do
wakeup "${method}" "${timestamp}"
done
eend $?
}
Alles anzeigen