Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] VDR wakeup (special solution)



Hi all,

I have installed nvram-wakeup now (thanks to Sergei Haller) and
have made some modifications to solve the following problems:

The wakeup feature of VDR was designed for a VDR-only system, but my
VDR box is also used as a "normal" pc (inet, mail, games for my kids).
If VDR decides to shutdown, all sessions of "normal" users are killed.
If a user shuts down the pc, VDR will never wake up again.

My way to go requires:
- A BIOS that needs no reboot after setting a timer
(see README of nvram-wakeup).
- Disabling acpi (starting with acpi=off and using apm),
if BIOS don't wake up after acpi power off.
- A patch to VDR (see below) to call the shutdown script (from -s option)
after timer changes to keep the wakeup timer up to date. At the beginning
of a recording the wakeup timer will be set to the next recording.
- A special version of vdrshutdown (not the original!!!) or my vdr_halt
(see below). VDR calls this script with a fifth parameter of "2" to
indicate "only set timer". The other behavior is unchanged.
My script don't shutdown, if any "normal" user is working.

Ok, this solution is not really safe. If a user stops the pc while VDR
is recording, the rest of that recording will be lost. If the user
stops between the wakeup time for a recording and the beginning of the
recording, VDR never wakes up automatically.

@Klaus / @Sergei: What do you mean?

I'm currently running VDR 1.1.20, but the modification of newer versions
should be quite easy...

diff timers.h.ori timers.h
86a87
> cTimer *GetActiveTimerAfterNow(void);

diff timers.c.ori timers.c
405a406,416
>
> cTimer *cTimers::GetActiveTimerAfterNow()
> {
> time_t Now = time(NULL);
> cTimer *t0 = NULL;
> for (cTimer *ti = First(); ti; ti = Next(ti)) {
> if (ti->Active() && (!t0 || *ti < *t0) && (ti->StartTime() > Now))
> t0 = ti;
> }
> return t0;
> }

diff vdr.c.ori vdr.c
424a425
> time_t oldNext = 0;
651a653,668
> if(!Menu) {
> cTimer *timer = Timers.GetActiveTimerAfterNow();
> time_t Next = timer ? timer->StartTime() : 0;
> if(Next != oldNext) {
> oldNext = Next;
> time_t Now = time(NULL);
> time_t Delta = timer ? Next - Now : 0;
> int Channel = timer ? timer->Channel()->Number() : 0;
> const char *File = timer ? timer->File() : "";
> char *cmd;
> asprintf(&cmd, "%s %ld %ld %d \"%s\" 2", Shutdown, Next, Delta, Channel, strescape(File, "\"$"));
> isyslog("executing '%s'", cmd);
> SystemExec(cmd);
> free(cmd);
> }
> }


My shutdown script (vdr_halt):
Remember that the BIOS must not need to reboot after
setting a timer via nvram-wakeup!

#!/bin/bash

LOGFILE="/var/log/vdr_halt.log"
NVRAMCMD="/usr/local/bin/nvram-wakeup"

echo "********************" >> $LOGFILE
date >> $LOGFILE
echo "1: $1 2: $2 3: $3 4: $4 5: $5" >> $LOGFILE

# write timer to nvram
$NVRAMCMD -ls $1

# written to nvram?
if test $PIPESTATUS -eq 2; then exit; fi
echo "timer ok" >> $LOGFILE

# setting timer only?
if test $5 -eq 2; then exit; fi

# are there logins?
logins=`who -q | grep '# users=' | awk -F "=" '{ print $2; }'`
if test "$1" = "force"; then logins=0; fi

# shutdown?
if test $logins -eq 0
then
echo "shutdown (halt -p)" >> $LOGFILE
halt -p
else
echo "there are $logins logins" >> $LOGFILE
fi

<--- end of vdr_halt --->

Kind regards
Andreas Böttger




--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index