diff options
| author | root <root@elwms02.(none)> | 2010-04-06 16:13:08 +0200 |
|---|---|---|
| committer | root <root@elwms02.(none)> | 2010-04-06 16:13:08 +0200 |
| commit | 0e7005fcc7483c01aa102fbea358c5ac65a48d62 (patch) | |
| tree | 11517ce0d3d2977c6732b3aa583b0008083e0bd3 /vdr/scripts/runvdr | |
| download | x-vdr-0e7005fcc7483c01aa102fbea358c5ac65a48d62.tar.gz x-vdr-0e7005fcc7483c01aa102fbea358c5ac65a48d62.tar.bz2 | |
hello world
Diffstat (limited to 'vdr/scripts/runvdr')
| -rw-r--r-- | vdr/scripts/runvdr | 247 |
1 files changed, 247 insertions, 0 deletions
diff --git a/vdr/scripts/runvdr b/vdr/scripts/runvdr new file mode 100644 index 0000000..36115ea --- /dev/null +++ b/vdr/scripts/runvdr @@ -0,0 +1,247 @@ +#!/bin/sh + +# x-vdr (Installations-Skript fuer einen VDR mit Debian als Basis) +# von Marc Wernecke - www.zulu-entertainment.de +# 24.03.2009 +# runvdr + +VDRLANG="de_DE.iso88591" +VDRCHARSET="ISO-8859-9" +KILL="/usr/bin/killall -q -TERM" +KERNEL=`uname -r` +VDRCONFIG=/etc/default/vdr +LOGGER="logger -s ${0##*/} " + +function VdrSettings() { + # read vdr default configuration + if [ -f "$VDRCONFIG" ]; then + . $VDRCONFIG + else + $LOGGER "exit, because $VDRCONFIG does not exists" + exit 1 + fi + + # read sysconfig generated by setup-plugin + if [ "$setup" = "on" ] && [ -f "$VDRCONFDIR/plugins/setup/sysconfig" ]; then + . "$VDRCONFDIR/plugins/setup/sysconfig" + fi + + # test if vdr exists and is executable + test -x "$VDRPRG" || exit 0 + + # create tmp files + $VDRPRG --help | sed -e '/^$/d' -e 's/^. //' > /tmp/vdr-help.tmp + $VDRPRG --version | sed -e 's/\(^[^ ]*\)\(.*$\)/\1_desc="\1\2"/' -e '/^streamdev/s/-/_/' -e 's/^\[.*//' | sort > /tmp/vdr-desc.cache + + # export vdr language + export LANG=$VDRLANG + export LC_ALL=$VDRLANG + export VDR_CHARSET_OVERRIDE=$VDRCHARSET + + # export HOME + if [ "$VDRUSER" = "root" ]; then + export HOME="/root" + else + export HOME="$VDRCONFDIR" + fi + + # java / projectx for burn and dvdconvert + if [ "$burn" = "on" ] || [ "$dvdconvert" = "on" ]; then + [ -z "$JAVA_HOME" ] && export JAVA_HOME="/usr/lib/jvm/java-6-sun/jre" + [ -z "$PROJECTX_HOME" ] && export PROJECTX_HOME="/usr/bin/ProjectX" + fi + + # set DISPLAY + # - activate automatic login + # - copy x-vdr/extra/xhost to ~/.kde/Autostart and set xhost executable + if [ "$softdevice" = "on" ] || [ "$xineliboutput" = "on" ]; then + [ -z "$DISPLAY" ] && export DISPLAY=:$XV_DISPLAY + fi + + # load nvram + if [ `which nvram-wakeup | wc -l` -gt 0 ] && [ `lsmod | grep -cw 'nvram'` -eq 0 ]; then + modprobe -q nvram + fi + + # load cdfs + if [ `lsmod | grep -cw 'cdfs'` -eq 0 ]; then + modprobe -q cdfs + fi + + # load av7710ir + if [ -e /proc/av7110_ir ] || [ -e /proc/budget_ci_ir ]; then + for FILE in av7110_ir budget_ci_ir; do + if [ -e "/proc/$FILE" ]; then + chown $VDRUSER:$VDRGROUP /proc/$FILE + fi + done + if [ `lsmod | grep -cw 'evdev'` -eq 0 ]; then modprobe -q evdev ; fi + fi + + # load em8300 + if [ "$em8300" = "on" ]; then +# EM8300="/lib/modules/$KERNEL/em8300" +# if [ -f "$EM8300/adv717x.ko" ] && [ -f "$EM8300/bt865.ko" ] && [ -f "$EM8300/em8300.ko" ]; then +# $VDRSCRIPTDIR/rmm +# $VDRSCRIPTDIR/ldm + [ "$dxr3" != "on" ] && em8300setup +# fi + fi + + # load parport + if [ "$graphlcd_base" = "on" ]; then + [ `lsmod | grep -cw 'parport'` -eq 0 ] && modprobe -q parport + [ `lsmod | grep -cw 'parport_pc'` -eq 0 ] && modprobe -q parport_pc + [ `lsmod | grep -cw 'ppdev'` -eq 0 ] && modprobe -q ppdev +# chmod 0666 /dev/parport0 + fi + + # only for mplayer via xine + # - copy x-vdr/extra/xhost to ~/.kde/Autostart and set xhost executable + if [ "$VDRUSER" != "root" ] && [ "$xine" = "on" ] && [ "$mplayer" = "on" ]; then + chmod 666 /dev/rtc +# echo 1024 > /proc/sys/dev/rtc/max-user-freq + fi + + # plugins + PLUGINS="" + ignore_cmd="" + + if [ "$USE_SYSCONFIG" = "on" ]; then # use PLUGINLIST from sysconfig + PLUGINS="$PLUGINLIST" + + else # start creating a temporary pluginlist ... + # plugin api version + plugin_api="$(grep -m1 '^vdr_desc=' /tmp/vdr-desc.cache | sed -e 's/^vdr_desc=//' -e 's/[^)]*$//' -e 's/^[^\/]*//g' -e 's/\///' -e 's/\/*)//')" + [ -n "$plugin_api" ] || plugin_api="$($VDRPRG --version | grep -m1 '^vdr ' | sed -e 's/[^)]*$//' -e 's/^[^\/]*//g' -e 's/\///' -e 's/\/*)//')" + + # put these plugins on top of the pluginlist + if [ -n "$PLUGINS_ON_TOP" ]; then + for p in $PLUGINS_ON_TOP ; do + if [ -f "$VDRLIBDIR/libvdr-${p}.so.${plugin_api}" ]; then + ignore_cmd="$ignore_cmd -I libvdr-${p}.so.${plugin_api}" + plugin=$(echo $p | sed -e "s/-/_/g") # this is for streamdev-... + if [ "${!plugin}" = "on" ]; then + plugin_args="${plugin}_args" + if [ -n "${!plugin_args}" ]; then + PLUGINS="$PLUGINS -P'${p} ${!plugin_args}'" + else + PLUGINS="$PLUGINS -P'${p}'" + fi + fi + fi + done + fi + + # read libdir and continue creating pluginlist + files=$(ls -B $ignore_cmd "$VDRLIBDIR" | grep "^libvdr-" | grep ".so.${plugin_api}$" | sed -e "s/^libvdr-//g" -e "s/.so.${plugin_api}$//g") + if [ -n "$files" ]; then + for p in $files ; do + plugin=$(echo $p | sed -e "s/-/_/g") # this is for streamdev-... + if [ -z "${!plugin}" ] && [ -f "$VDRLIBDIR/libvdr-$(echo $plugin | sed -e "s/_/-/g").so.${plugin_api}" ]; then + echo "" >> $VDRCONFIG + echo "# $p" >> $VDRCONFIG + echo "${plugin}=\"off"\" >> $VDRCONFIG + eval ${plugin}="off" + # plugin args + nl=0; (( nl=$(grep -n "^$p " /tmp/vdr-help.tmp | cut -f 1 -d ":") +1 )) + [ $nl -gt 1 ] && [ $(sed -n "${nl}p" /tmp/vdr-help.tmp | grep -c "^-") -gt 0 ] && echo "${plugin}_args=\"\"" >> $VDRCONFIG + fi + if [ "${!plugin}" = "on" ]; then + plugin_args="${plugin}_args" + if [ -n "${!plugin_args}" ]; then + PLUGINS="$PLUGINS -P'${p} ${!plugin_args}'" + else + PLUGINS="$PLUGINS -P'${p}'" + fi + fi + done + fi + + # special plugin settings + [ "$remote" = "on" ] && chmod 0666 $remote_event + fi + + # scripts + VDRRECCMDS="" + [ -x "$VDRSCRIPTDIR/vdrreccmds" ] && VDRRECCMDS="-r $VDRSCRIPTDIR/vdrreccmds" + VDRSETTIME="" + [ -x "$VDRSCRIPTDIR/vdrsettime" ] && [ $(grep -c "\-T CMD, --timeset=CMD" /tmp/vdr-help.tmp) -gt 0 ] && VDRSETTIME="-T $VDRSCRIPTDIR/vdrsettime" + VDRSHUTDOWN="" + [ -x "$VDRSCRIPTDIR/vdrshutdown" ] && VDRSHUTDOWN="-s $VDRSCRIPTDIR/vdrshutdown" + + # keyboard tty (terminal for vdr) + VDRKEYBTTY="" + if [ "$KEYB_TTY" != "" ]; then + VDRKEYBTTY="-t $KEYB_TTY" + [ "$VDRUSER" != "root" ] && chmod 0666 $KEYB_TTY + fi + + # cmd + VDRCMD="$VDRPRG -w $WATCHDOG -v $VIDEODIR -c $VDRCONFDIR -E $VDRVARDIR/epg.data -L $VDRLIBDIR -u $VDRUSER \ + $VDRRECCMDS $VDRSETTIME $VDRSHUTDOWN $VDRKEYBTTY $PLUGINS $OPTIONS " +} + +# modules +function get_modulenames() { + KVERS=`uname -r | grep -e '2.6'` + if [ -z "$KVERS" ]; then + MODULES=`lsmod | grep 'dvb-core' | cut -d'[' -f2 | cut -d']' -f1` + else + MODULES=`lsmod | grep '^dvb_core' | awk '{print $4;}' | awk '{ gsub(/,/," ", $1); print }'` + fi +} + +get_modulenames + +if [ -z "$MODULES" ]; then # If no DVB-Modules were found, try to load + modprobe -q dvb # the module with the name dvb, this could + get_modulenames # be an alias for the dvb-ttpci-module or +fi # another dvb-module + +MODULES="$MODULES dvb-core" + +if [ `echo $MODULES | grep -cw 'b2c2_flexcop'` -gt 0 ] && [ `echo $MODULES | grep -cw 'b2c2_flexcop_pci'` -eq 0 ]; then + MODULES="b2c2_flexcop_pci $MODULES" +fi + +# clear TTY +if [ "$KEYB_TTY" != "" ]; then + clear > $KEYB_TTY +fi + +# main script +while (true) do + # load vdr settings + VdrSettings + # start X + MSG="Starting Xserver for VDRUSER: '$VDRUSER'" + [ "$XPLAYER" = "on" ] && echo "$MSG" && su "$VDRUSER" -c "startx &" + # start vdr + $LOGGER "Starting Video Disk Recorder at `date`" + eval $VDRCMD >/dev/null 2>&1 + if test $? -eq 0; then + $LOGGER "Video Disk Recorder stopped at `date`" + [ "$XPLAYER" = "on" ] && $KILL Xorg + exit 0 + fi + # stop vdr + $LOGGER "Stopping Video Disk Recorder at `date`" + [ "$XPLAYER" = "on" ] && $KILL Xorg + $KILL $VDRPRG + wait `pidof $VDRPRG` + # unload modules + for MODULE in $MODULES; do + rmmod $MODULE >/dev/null 2>&1 + wait `pidof rmmod` + done + # load modules + for MODULE in $MODULES; do + modprobe $MODULE >/dev/null 2>&1 + done +done + +# clear tty +if [ "$KEYB_TTY" != "" ]; then + clear > $KEYB_TTY +fi |
