Infosatepg.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(M)
Zeile 7: Zeile 7:
 
# infosatepg.sh
 
# infosatepg.sh
 
#
 
#
# Required: ps, svdrpsend.pl, infosatepg, tvm2vdr.pl (optional)
+
# Required: screen, svdrpsend.pl, infosatepg, tvm2vdr.pl (optional)
 
#
 
#
 
# add this lines to your commands.conf:
 
# add this lines to your commands.conf:
 
# folgende zeilen in die commands.conf eintragen:
 
# folgende zeilen in die commands.conf eintragen:
 
#
 
#
# Run infosatepg              : echo "/path_to_this_script/infosatepg.sh" | at now
+
# Run infosatepg              : /path_to_this_script/infosatepg.sh start
# Run infosatepg + tvmovie2vdr : echo "/path_to_this_script/infosatepg.sh -tvmovie2vdr" | at now
+
# Run infosatepg + tvmovie2vdr : /path_to_this_script/infosatepg.sh start +
# View logfile                : /path_to_this_script/infosatepg.sh -log
+
# Status                      : /path_to_this_script/infosatepg.sh status
 
#
 
#
 
# Edit the config.pl:
 
# Edit the config.pl:
Zeile 22: Zeile 22:
  
 
# CONFIG START
 
# CONFIG START
   INFOSAT_OPT="-v"                           # options
+
   OPT="-v"                                     # options
   CHANNEL="VIVA"                             # which channel, e.g: <NUM> or <NAME>
+
   CHANNEL="TechniSat Kanal 50"                 # which channel, e.g: <NUM> or <NAME>
  SHOWSTATUS="1"                            # show status (1=true/0=false)
+
   CLEANUP="10"                                 # cleanup files (older n*24 hours ago)
   CLEANUP="10"                               # cleanup files (older n*24 hours ago)
+
   OUT="/usr/local/cache/infosatepg"           # store infosatepg in
   INFOSAT_OUT="/usr/local/cache/infosatepg" # store infosatepg in
+
   TVMOVIE2VDRDIR="${SOURCEDIR:?}/tvmovie2vdr"  # tvmovie2vdr directory
   INFOSAT_LOG="/var/log/vdr/infosatepg.log" # logfile
+
  LOGFILE="/var/log/vdr/infosatepg.log"       # logfile
 
# CONFIG END
 
# CONFIG END
  
PATH=/usr/local/bin:$PATH:$PREFIX/bin
+
# cleanup old images
 +
find "$OUT" -follow -type f -mtime +${CLEANUP:-100} -exec rm {} \;
  
 
case $1 in
 
case $1 in
    -log)
+
    start)
if [ -s $INFOSAT_LOG ] ; then
+
if screen -ls | egrep -q infosatepg ; then
    tail -n 10 $INFOSAT_LOG | tr -d '#_'
+
    echo "infosatepg is already running..."
 
else
 
else
    echo "$INFOSAT_LOG not exist or empty..."
+
    screen -dmS infosatepg sh -c " \
 +
    infosatepg $OPT -c \"$CHANNEL\" -o \"$OUT\" > \"$LOGFILE\" 2>&1 ; \
 +
    if [ -n \"\$2\" ] ; then \
 +
cd \"$TVMOVIE2VDRDIR\" ; ./tvm2vdr.pl ; \
 +
    fi \
 +
    "
 
fi
 
fi
 
;;
 
;;
    *)
+
    status)
if [ -n "$(pidof infosatepg)" ] ; then
+
screen -ls | egrep -c infosatepg
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG "infosatepg is already running..."
+
else
+
    if [ "$(svdrpsend.pl -p ${VDR_PORT:-2001} CHAN $CHANNEL | grep -c '^250.*')" -eq 0 ] ; then
+
svdrpsend.pl -p ${VDR_PORT:-2001} MESG "switch to $CHANNEL failed..."
+
    else
+
mkdir -p $INFOSAT_OUT
+
                find $INFOSAT_OUT -follow -type f -mtime +${CLEANUP} -exec rm \{} \;
+
infosatepg $INFOSAT_OPT -o $INFOSAT_OUT > $INFOSAT_LOG &
+
PID=$!
+
if [ "$SHOWSTATUS" -eq 1 ] ; then
+
    sh -c "until ! ps -p $PID; do sleep 30s; svdrpsend.pl -p ${VDR_PORT:-2001} MESG \"\$(grep -s [0-9]% $INFOSAT_LOG | tail -n 1)\"; done" &
+
fi
+
wait $PID; kill $!
+
svdrpsend.pl -p ${VDR_PORT:-2001} MESG "$(tail -n 1 $INFOSAT_LOG)..."
+
if [ -n "$1" ] ; then
+
                    cd ${SOURCEDIR:?}/tvmovie2vdr
+
    ./tvm2vdr.pl
+
fi
+
    fi
+
fi \
+
>/dev/null 2>&1
+
 
;;
 
;;
 +
    *)
 +
echo "Usage: $0 {start|status}" >&2
 +
        exit 1
 
esac
 
esac
 +
 +
exit $?
 
</pre>
 
</pre>
 
}}
 
}}
  
 
[[Kategorie:Skripte]]
 
[[Kategorie:Skripte]]

Version vom 22. April 2006, 03:07 Uhr

Skript von infosatepg.

Datei
$PATH/infosatepg.sh
#!/bin/sh
#
# infosatepg.sh
#
# Required: screen, svdrpsend.pl, infosatepg, tvm2vdr.pl (optional)
#
# add this lines to your commands.conf:
# folgende zeilen in die commands.conf eintragen:
#
# Run infosatepg               : /path_to_this_script/infosatepg.sh start
# Run infosatepg + tvmovie2vdr : /path_to_this_script/infosatepg.sh start +
# Status                       : /path_to_this_script/infosatepg.sh status
#
# Edit the config.pl:
#
# - our $infosaturl="/video/received_data";
# + our $infosaturl="/usr/local/cache/infosatepg";

# CONFIG START
  OPT="-v"                                     # options
  CHANNEL="TechniSat Kanal 50"                 # which channel, e.g: <NUM> or <NAME>
  CLEANUP="10"                                 # cleanup files (older n*24 hours ago)
  OUT="/usr/local/cache/infosatepg"            # store infosatepg in
  TVMOVIE2VDRDIR="${SOURCEDIR:?}/tvmovie2vdr"  # tvmovie2vdr directory
  LOGFILE="/var/log/vdr/infosatepg.log"        # logfile
# CONFIG END

# cleanup old images
find "$OUT" -follow -type f -mtime +${CLEANUP:-100} -exec rm {} \;

case $1 in
     start)
	if screen -ls | egrep -q infosatepg ; then
	    echo "infosatepg is already running..."
	else
	    screen -dmS infosatepg sh -c " \
	    infosatepg $OPT -c \"$CHANNEL\" -o \"$OUT\" > \"$LOGFILE\" 2>&1 ; \
	    if [ -n \"\$2\" ] ; then \
		cd \"$TVMOVIE2VDRDIR\" ; ./tvm2vdr.pl ; \
	    fi \
	    "
	fi
	;;
     status)
	screen -ls | egrep -c infosatepg
	;;
     *)
	echo "Usage: $0 {start|status}" >&2
        exit 1
esac

exit $?