Runvdr
Aus VDR Wiki
Version vom 5. April 2006, 10:17 Uhr von 84.186.52.184 (Diskussion)
Runvdr aus den VDR Sourcen
#!/bin/sh # runvdr: Loads the DVB driver and runs VDR # # If VDR exits abnormally, the driver will be reloaded # and VDR restarted. # # Set the environment variable VDRUSR to the user id you # want VDR to run with. If VDRUSR is not set, VDR will run # as 'root', which is not necessarily advisable. # # Since this script loads the DVB driver, it must be started # as user 'root'. # # 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 1.14 2004/11/21 11:30:00 kls Exp $ DVBDIR="../DVB/driver" VDRPRG="./vdr" VDRCMD="$VDRPRG -w 60 $*" LSMOD="`/sbin/lsmod | grep -w '^dvb' | wc -l`" KILL="/usr/bin/killall -q -TERM" # Load driver if it hasn't been loaded already: if [ $LSMOD -eq 0 ] ; then (cd $DVBDIR; make insmod) fi while (true) do su $VDRUSR -c "$VDRCMD" if test $? -eq 0 -o $? -eq 2; then exit; fi date echo "restarting VDR" $KILL $VDRPRG sleep 10 (cd $DVBDIR; make rmmod; make insmod) date done
Tipps
Programme und libs werden nach dem ausführen der runvdr nicht gefunden?
Die Lösung ist ziemlich einfach, die Orginal runvdr (siehe oben) setzt die Environment auf Null.
while (true) do su $VDRUSR -c "$VDRCMD" ^^^^^^^^^^^^^^^^^^^^^^^ if test $? -eq 0 -o $? -eq 2; then exit; fi
Im Detail.
bash> echo $PATH /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/java/jre/bin bash> su bash> echo $PATH /usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin bash> su --help Usage: su [OPTION]... [-] [USER [ARG]...] Change the effective user id and group id to that of USER. -, -l, --login make the shell a login shell ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -c, --commmand=COMMAND pass a single COMMAND to the shell with -c -f, --fast pass -f to the shell (for csh or tcsh) -m, --preserve-environment do not reset environment variables ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -p same as -m ^^^^^^^^^^ -s, --shell=SHELL run SHELL if /etc/shells allows it --help display this help and exit --version output version information and exit A mere - implies -l. If USER not given, assume root. Report bugs to <bug-coreutils@gnu.org>.
Man braucht su lediglich mitzuteilen, die Environment nicht zu löschen, das wäre in der runvdr, eines folgender Möglichkeiten.
su - $VDRUSR -c "$VDRCMD" su $VDRUSR -m -c "$VDRCMD" su $VDRUSR -p -c "$VDRCMD"
Startest Du das ganze als "root", ist sh die bessere Wahl.
sh -c "$VDRCMD"