Runvdr
Aus VDR Wiki
Version vom 30. Juni 2004, 22:06 Uhr von 213.6.81.24 (Diskussion)
Andere Scripts:
http://www.informatik.uni-bremen.de/cgi-bin/cgiwrap/mwiesner/download/watchvdr
ftp://ftp.berlios.de/pub/avm-capi4linux/temp/cooker/dvb
http://linvdr.org/download/doku/vdr-2/runvdr
#!/bin/sh # # sample runvdr script # # runvdr: Loads the DVB driver and runs VDR # # If VDR exits abnormally, the driver will be reloaded # and VDR restarted. # # original by Klaus Schmidinger # adapted and enhanced for VDR-Install-Script # # $Id: runvdr 1.12 2004/01/09 16:19:26 kls Exp $
export TERM=linux export LANG=POSIX export HOME=/root export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/src/vdradmind
DESC="Digital Videorecorder" CONF="/usr/local/src/VDRtmp/vdr.conf"
. "${CONF}"
VERSION=( `grep -s 'define VDRVERSION' $MYPATH/VDR/config.h` ) COLUMNS=( `stty size 2>/dev/null` )
VDRPRG="${MYPATH}/VDR/vdr"
test -x "${VDRPRG}" || exit 0
colmsg() {
printf "%-$[${COLUMNS[1]:-60}-11]s%-0s\n" "${1}" "${2}"
}
testmod() {
test `/sbin/lsmod|grep -wc ^${1}` -eq 0
}
testproc() {
test "`which ${1}`" -a `ps -eo%c|grep -wc ^${1}` -eq 0
}
load_conf() {
for i in `sed '/="/!d;s/=.*\"//;/^#/d' "${CONF}"` ; do
eval x="\$${i}"
test "${x}" -a "${i%_*}" = VDR && {
VDROPT=${VDROPT}" --`echo "${i##*\_}"|tr A-Z a-z`='${x}'"
}
export ${i}="${x}"
done
}
load_cmds() {
for i in commands reccmds ; do
grep -qs ^ "${CMDPATH}"/${i}* && {
echo "cat "`ls -v "${CMDPATH}"/${i}*`" > \"${VDR_CONFIG}/${i}.conf\"" | sh
}
done
}
stop_dvb() {
echo ${START_PROCS}|egrep -q dvb && {
for i in 1 2 3 ; do
f=${f}". "
echo -ne "Shutting down DVB: ${f}\r"
sleep 1s
done
## way 1:
cd ${MYPATH}/DVB/driver ; make rmmod
## way 2:
#modules -rq
## way 3:
#/etc/init.d/dvb stop
## way 4:
#cd ${MYPATH}/DVB/build-<KERNELVERSION> ; ./insmod.sh unload
}
}
start_dvb() {
echo ${START_PROCS}|egrep -q dvb && {
echo "Starting DVB: "
## way 1:
cd ${MYPATH}/DVB/driver ; make insmod
## way 2:
#modules -q
## way 3:
#/etc/init.d/dvb start
## way 4:
#cd /usr/local/src/DVB/build-<KERNELVERSION> ; ./insmod.sh load
}
}
modules() {
case "${1##*\-}" in
q) REV="${LMODULES}" ;;
*) REV="${RMODULES}" ;;
esac
echo "${REV}"|sed -e '/^[ ]*$/d' | \
while read i ; do
/sbin/modprobe ${1} ${i} >/dev/null 2>&1
case $? in
0) colmsg "${i}" done ;;
1) colmsg "${i}" failed ;;
esac
done
}
load_dvb() {
testmod dvb && {
start_dvb
test "${TUNE}" = yes && testproc szap && {
szap -c "${VDR_CONFIG}/tune/channels.conf-dvbs-astra" -x -a 1 -n 1
}
}
}
load_atd() {
testproc atd && { atd; }
}
load_ivtv() {
testmod ivtv && { cd "${MYPATH}/ivtv/utils"; ./runivtv; }
}
load_dxr3() {
testmod em8300 && { cd "${MYPATH}/em8300/modules"; ./ldm; }
}
load_lcdd() {
testproc LCDd && { LCDd -c /etc/LCDd.conf; } &
}
load_lircd() {
testproc lircd && { setserial /dev/ttyS0 uart none; /sbin/modprobe lirc_serial; lircd; } &
wait $!
}
load_irexec() {
testproc irexec && { irexec /etc/lircrc; } &
}
load_admind() {
testproc vdradmind.pl && { rm -f "${MYPATH}/vdradmind/vdradmind.pid"; sleep 10; vdradmind.pl; } &
}
load_evexec() {
testproc evexec && {
grep -s ^[0-9]: "${EVEXECCNF}" | \
while IFS=: read a b c ; do
evexec /dev/input/event${a} ${b} "${c}" 2>/dev/null &
done
}
}
case "${1}" in
start)
for cmd in conf cmds ${START_PROCS} ; do
load_${cmd}
test ${cmd} = evexec && {
RELOAD_EVEXEC="yes"
}
done
while (true) ; do
test -e "${SYSLOG}" -a -e "${VDR_CONFIG}/setup.conf" && {
CHAN=$(tail -n 300 ${SYSLOG}|sed "/${PHRASE}/!d;s#^.* ##"|sed '$!d')
test -n "${CHAN##*[^0-9,-]*}" && {
sed -i "s/^CurrentChannel.*/CurrentChannel = ${CHAN}/" "${VDR_CONFIG}/setup.conf"
}
}
test -f "${VDR_CONFIG}/loadkeys/${AV7110LOADKEYS}" \
-a "`which av7110_loadkeys`" -a \
-w /proc/av7110_ir && {
av7110_loadkeys "${VDR_CONFIG}/loadkeys/${AV7110LOADKEYS}" > /proc/av7110_ir
}
test -x "${VDR_LIB}/libvdr-pluginsetup.so.${VERSION[2]//\"}" && {
PSETUP="-P'pluginsetup'"
}
echo "Starting ${DESC} ${VERSION[2]//\"}: "
PLUGINS="${PSETUP} `grep -s - "${VDR_CONFIG}/plugins/plugin_setup_runvdr.conf"`"
su ${VDRUSR} -c "${VDRPRG} ${VDROPT} ${USRDEV} ${PLUGINS}"
test $? -eq 0 -o $? -eq 2 && {
exit
}
date
echo "Restarting ${DESC}: "
killall -q -TERM ${VDRPRG}
date
stop_dvb
start_dvb
test "${RELOAD_EVEXEC}" = yes && {
load_evexec
}
done
;;
stop)
for i in ${STOP_PROCS} ; do
ps -eo%c|grep -q ^${i}$ && {
killall -v ${i}
}
done
stop_dvb
;;
xineclient)
testproc xine && {
xine -A alsa "vdr://tmp/vdr-xine/stream#demux:mpeg_pes"
}
;;
restart)
${0} stop
${0} start
;;
status)
for i in ${STOP_PROCS} ; do
ps -eo%c|grep -q ^${i}$
case $? in
0) colmsg "${i}" running ;;
1) colmsg "${i}" unused ;;
esac
done
;;
*)
echo "Usage: ${0} {start|stop|status|restart}" >&2
exit 1
;;
esac