/usr/share/vdr/shutdown-hooks/S90.nvram-wakeup is in nvram-wakeup 1.1-4+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #
# VDR shutdown hook for nvram-wakeup - Tobias Grimm <tg@e-tobi.net>
# ----------------------------------
#
# This shutdown hook sets the wakeup time for the next timer using
# nvram-wakeup. If necessary the shutdown command is modified to
# use a special shutdown strategy.
#
NVRAMCMD=/usr/sbin/nvram-wakeup
# read arguments for nvram-wakeup from conf-file
. /etc/vdr/vdr-nvram-wakeup.conf
# Defaults:
[ -z "$ENABLED" ] && export ENABLED="no"
[ -z "$COMMANDLINE" ] && export COMMANDLINE=""
[ -z "$SPECIALSHUTDOWN" ] && export SPECIALSHUTDOWN=""
[ -z "$REGULAR_DAYS" ] && export REGULAR_DAYS=0
[ -z "$REGULAR_TIME" ] && export REGULAR_TIME=0
[ -z "$FORCE_REBOOT" ] && export FORCE_REBOOT="no"
LOG="logger -t vdr-nvram-wakeup"
if [ $ENABLED = "no" ] ; then
$LOG "nvram-wakeup functionality is disabled"
exit 0
fi
request_reboot()
{
if [ -z "$SPECIALSHUTDOWN" ] ; then
$LOG "nvram-wakeup: A special shutdown strategy is required but not configured."
echo "ABORT_MESSAGE=\"no special shutdown configured\""
exit 1
else
echo "SHUTDOWNCMD=\"$SPECIALSHUTDOWN\""
exit 0
fi
}
# calculate, at what time the machine should be powered on:
TIMER=$1
if [ $REGULAR_DAYS -gt 0 ]; then
REGULAR_TIMER=$((`date -d "$REGULAR_TIME" +%s` + $REGULAR_DAYS * 24 * 60 * 60))
# when no vdr timer is set or vdr timer starts later than regular timer:
if [ $TIMER -eq 0 ] || [ $TIMER -gt 0 -a $REGULAR_TIMER -lt $TIMER ] ; then
TIMER=$REGULAR_TIMER
fi
fi
# set wakeup time and check nvram-wakeup and check result:
$LOG "$NVRAMCMD -ls $TIMER $COMMANDLINE"
$NVRAMCMD -ls $TIMER $COMMANDLINE
case $? in
0) # all went ok - new date and time set
$LOG "nvram-wakeup: everything ok"
if [ $FORCE_REBOOT = "yes" ] ; then
$LOG "nvram-wakeup: reboot not needed but forced"
request_reboot
fi
exit 0
;;
1) # all went ok - new date and time set.
#
# *** but we need to reboot. ***
#
# for some boards this is needed after every change.
#
# for some other boards, we only need this after changing the
# status flag, i.e. from enabled to disabled or the other way.
# For plan A - (Plan A is not supported anymore---see README)
#
# For plan B - (don't forget to install the modified kernel image first)
#
$LOG "nvram-wakeup: everything ok - need to reboot first"
request_reboot
;;
*) # something went wrong
# don't do anything - just exit with status 1
$LOG "nvram-wakeup: could not set time, shutdown will be aborted"
echo "ABORT_MESSAGE=\"nvram-wakeup could not set time\""
exit 1
;;
esac
|