Wechseln zu: Navigation, Inhalt, Suche

Permalink

0

HowTo: VDR in den Systemstart einbinden

Um einen Video Disk Recorders (VDR) sofort nach dem Start mit der Fernbedienung zu steuern, ist es notwendig ihn automatisch zu starten. Außerdem sollte er für gesetzte Timer automatisch aufwachen, um diese aufzunehmen. Ich verwende dazu jeweils ein Start-Skript für VDR und Xine, zusätzlich noch ein Shutdown-Skript für VDR.

Teo-X VDR 04

Shutdown-Skript

Shutdown-Skript erstellen

vi /usr/src/VDR/shutdown.sh
#!/bin/sh
#
# shutdown.sh

# wake up method ('off','acpi','nvram','suspend')
WAKEUP_METHOD="acpi"

# read board configuration from specified configuration file (e.g: "/etc/nvram-wakeup.conf")
NVRAM_CONFIG=""

# specify the iw (infowriter) name. (e.g: gigabyte_5aa)
NVRAM_IWNAME=""

# try "nvram-wakeup --help"
NVRAM_OPT="--syslog"

# Which boot manager are you using? (grub/lilo)
BOOT_MANAGER="grub"

TIMER=$1
LILOCNF=/etc/lilo.conf
GRUBCNF=/boot/grub/menu.lst
ACPIALARM=/proc/acpi/alarm

case ${#TIMER}-${WAKEUP_METHOD:-off} in
     10-acpi)
	test -e $ACPIALARM
	case $? in
	     0) date -d "1970-01-01 UTC $(($TIMER-120)) seconds" +"%Y-%m-%d %R:%S" > $ACPIALARM
		sudo poweroff
		exit 0
		;;
	     *) logger -t ${0##*/} "ARG -> missing $ACPIALARM"
		;;
	esac
	;;
     10-nvram)
	eval test $(echo $NVRAM_OPT | egrep -q directisa || echo "-e /dev/nvram -a") -e /dev/rtc -a -e /dev/mem
	case $? in
	     0) which nvram-wakeup >/dev/null 2>&1
		case $? in
		     0) sudo nvram-wakeup -s $TIMER $NVRAM_OPT ${NVRAM_CONFIG:+-C $NVRAM_CONFIG} ${NVRAM_IWNAME:+-I $NVRAM_IWNAME}
			case ${BOOT_MANAGER:-lilo} in
			     grub) REBOOT_LINE=`grep -s ^title "$GRUBCNF" | grep -i -n poweroff | { IFS=: read a b ; echo $a ; }`
				   test -n "$REBOOT_LINE"
                                   case $? in
					0) which grub-set-default >/dev/null 2>&1
					   case $? in
						0) which grubonce >/dev/null 2>&1
						   case $? in
						        0) sudo grubonce $((REBOOT_LINE-1))
							   ;;
							*) sudo grub-set-default $((REBOOT_LINE-1))
							   ;;
						   esac
						   ;;
						*) echo -e "savedefault --default=$((REBOOT_LINE-1)) --once\nquit" | sudo grub --batch
						   ;;
					   esac
					   ;;
					*) logger -t ${0##*/} "ARG -> missing poweroff entry in $GRUBCNF"
					   ;;
				   esac
				   ;;
			     lilo) REBOOT_ENTRY=`grep -s -i label.*poweroff "$LILOCNF" | { IFS== read a b ; echo $b ; }`
				   test -n "$REBOOT_ENTRY"
				   case $? in
					0) sudo lilo -R $REBOOT_ENTRY
					   ;;
					*) logger -t ${0##*/} "ARG -> missing poweroff entry in $LILOCNF"
					   ;;
				   esac
				   ;;
			esac
			sudo shutdown -r now
			exit 0
			;;
		     *) logger -t ${0##*/} "ARG -> missing nvram-wakeup"
			;;
		esac
		;;
	     *) logger -t ${0##*/} "ARG -> missing $(echo $NVRAM_OPT | egrep -q directisa || echo /dev/nvram -o) /dev/rtc -o /dev/mem"
		;;
	esac
	;;
     10-suspend)
	test -e $ACPIALARM -a -e /sys/power/state
	case $? in
	     0) date -d "1970-01-01 UTC $((TIMER-120)) seconds" +"%Y-%m-%d %R:%S" > $ACPIALARM
		echo mem > /sys/power/state
		sudo reboot
		exit 0
		;;
	     *) logger -t ${0##*/} "ARG -> missing $ACPIALARM -o /sys/power/state"
		;;
	esac
	;;
     10-off)
	logger -t ${0##*/} "MESG -> no wakeup method"
	;;
     1-*)
	logger -t ${0##*/} "MESG -> no timer"
	;;
esac

sudo shutdown -h now
exit $?

Runvdr

Runvdr bearbeiten

vi /usr/src/VDR/runvdr
#!/bin/bash

# runvdr: Loads the DVB driver and runs VDR
#
# If VDR exits abnormally, the driver will be reloaded
# and VDR restarted.
#
# In order to actually use this script you need to implement
# the functions DriverLoaded(), LoadDriver() and UnloadDriver()
# and maybe adjust the VDRPRG and VDRCMD to your particular
# requirements.
#
# Since this script loads the DVB driver, it must be started
# as user 'root'. Add the option "-u username" to run VDR
# under the given user name.
#
# Any command line parameters will be passed on to the
# actual 'vdr' program.
#
# See the main source file 'vdr.c' for copyright information and
# how to reach the author.
#
# $Id: runvdr 2.0 2006/05/14 16:02:05 kls Exp $

export LANG=de_DE
export LC_COLLATE=de_DE

VDRDIR="/usr/src/VDR"
VDRPRG="./vdr"
VDRCMD="$VDRPRG -t /dev/tty8 -w 60 -c /etc/vdr -E /var/vdr --vfat \
-P 'xine -r' -P streamdev-server -P streamdev-client \
-P epgsearch -P live -P 'dvd -C /dev/dvd' \
-P 'osdteletext -d /tmp/vtx' \
-P 'remote -i /dev/input/remote' \
-s /usr/src/VDR/shutdown.sh
$*"

KILL="/usr/bin/killall -q -TERM"

# Detect whether the DVB driver is already loaded
# and return 0 if it *is* loaded, 1 if not:
function DriverLoaded()
{
return 1
}

# Load all DVB driver modules needed for your hardware:
function LoadDriver()
{
modprobe dvb_ttpci
modprobe budget_ci
}

# Unload all DVB driver modules loaded in LoadDriver():
function UnloadDriver()
{
modprobe -r budget_ci
modprobe -r dvb_ttpci
modprobe -r stv0299
modprobe -r lnbp21
}

# Load driver if it hasn't been loaded already:
if ! DriverLoaded; then
LoadDriver
fi

while (true) do
cd $VDRDIR
eval "$VDRCMD"
if test $? -eq 0 -o $? -eq 2; then exit; fi
echo "`date` reloading DVB driver"
$KILL $VDRPRG
sleep 10
UnloadDriver
LoadDriver
echo "`date` restarting VDR"
done

Start-Skript

Start-Skript anlegen

vi /etc/init.d/vdr
#!/bin/bash

/usr/src/VDR/runvdr &
chmod +x /etc/init.d/vdr
update-rc.d vdr defaults
 Adding system startup for /etc/init.d/vdr ...
   /etc/rc0.d/K20vdr -> ../init.d/vdr
   /etc/rc1.d/K20vdr -> ../init.d/vdr
   /etc/rc6.d/K20vdr -> ../init.d/vdr
   /etc/rc2.d/S20vdr -> ../init.d/vdr
   /etc/rc3.d/S20vdr -> ../init.d/vdr
   /etc/rc4.d/S20vdr -> ../init.d/vdr
   /etc/rc5.d/S20vdr -> ../init.d/vdr

Start-Skript für Xine anlegen

vi /usr/src/VDR/xinestart.sh
#!/bin/sh

xine -pqhf --no-splash --post vdr_video --post vdr_audio --post upmix_mono "vdr:/tmp/vdr-xine/stream#demux:mpeg_pes"
chmod +x /usr/src/VDR/xinestart.sh
vi ~/.config/autostart/xinestart.desktop
[Desktop Entry]
Type=Application
Encoding=UTF-8
Version=1.0
Name=Xine-Starter
Name[de_DE]=Xine-Starter
Comment[de_DE]=Startet Xine
Comment=Startet Xine
Exec=sh /usr/src/VDR/xinestart.sh
X-GNOME-Autostart-enabled=true

Schreibe einen Kommentar