Clipinc.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(clipinc.sh - v.0.2)
(M)
 
(30 dazwischenliegende Versionen von 24 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
#!/bin/sh
+
Vorschlag für ein einfaches Skript um [[clipinc]] zu ''starten'', welches über die [[reccmds.conf]] ausgeführt werden kann.
#
+
 
# clipinc.sh - v.0.2
+
{{Box Datei | [[Struktur|$PATH]]/clipinc.sh |
#
+
<pre>
# add this lines to your [[reccmds.conf]]:
+
#!/bin/sh
# folgende zeilen in die [[reccmds.conf]] eintragen:
+
#
#
+
# clipinc.sh
# Run clipinc       : /usr/local/bin/clipinc.sh -start
+
#
# Run clipinc + 2mp3 : /usr/local/bin/clipinc.sh -start -2mp3
+
# add this lines to your reccmds.conf:
# Stop clipinc?     : /usr/local/bin/clipinc.sh -kill
+
# folgende zeilen in die reccmds.conf eintragen:
+
#
# CONFIG START
+
# Run clipinc   : /path_to_this_script/clipinc.sh -start
  AUDIO_CODEC=""    # force audio codec ('copy' to copy stream) -> default ('mp3')
+
# Stop clipinc? : /path_to_this_script/clipinc.sh -kill
  AUDIO_BITRATE=""  # set audio bitrate (in kbit/s)            -> default ('192')
+
 
  AUDIO_SAMPLING=""  # set audio sampling rate (in Hz)          -> default ('44100')
+
# CONFIG START
# CONFIG END
+
  CLIPINC_LOGFILE="/var/log/vdr/clipinc.log"
+
# CONFIG END
PATH=$PATH:/usr/local/bin
+
 
+
which clipinc.pl >/dev/null 2>&1 || { echo clipinc.pl $"not found" ... ; exit 1 ; }
case "$1" in
+
 
 +
case $1 in
 
     -start)
 
     -start)
        at now <<EOF
+
if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
if [ -e "$2/recinfo.conf" ] ; then
+
    read PID < "$PIDFILE"
    clipinc.pl "$2"
+
    echo $"Clipinc process already active" "(pid: $PID)" ...
elif [ -e "$3/recinfo.conf" ] ; then
+
else
    clipinc.pl "$3"
+
    if [ -e "$2/recinfo.conf" ] ; then
    find "$CLIPINCDIR" -name "001.vdr" | sed '/\.rec\/001\.vdr/!d' | while read i ; do
+
screen -dm sh -c \
        cd "\$(echo \$i | sed -e 's/.\{8\}$//g')"
+
" \
        LABEL=\$(dirname "\$(pwd)")
+
    clipinc.pl \"$2\" > \"$CLIPINC_LOGFILE\" 2>&1 &
        find "\$CLIPINC2DIR" -type f -empty -exec rm -vf '{}' ';'
+
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process started"" (pid: \$!) ...\" ; \
        if [ ! -e "\$CLIPINC2DIR/\${LABEL##*/}.mp3" -a -f 001.vdr ] ; then
+
    echo \$! > \"$PIDFILE\" ; \
            ffmpeg -i 001.vdr -acodec ${AUDIO_CODEC:-mp3} -ab ${AUDIO_BITRATE:-192} -ar ${AUDIO_SAMPLING:-44100} "$CLIPINC2DIR/\${LABEL##*/}.mp3" &
+
    wait \$! ; \
        fi
+
    rm -f \"$PIDFILE\" ; \
        wait
+
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process finished"" (pid: \$!) ...\" ; \
    done
+
"
else
+
    else
    svdrpsend.pl MESG "recinfo.conf not found..."
+
echo $"recinfo.conf not found" ...
fi
+
    fi
EOF
+
fi
        ;;
+
;;
 
     -kill)
 
     -kill)
        killall vdrcut clipinc.pl
+
if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
        ;;
+
    read PID < "$PIDFILE"
esac
+
    if ps -p $PID >/dev/null 2>&1 ; then
 +
        kill -9 $PID
 +
    fi
 +
    rm -f "$PIDFILE"
 +
fi
 +
;;
 +
esac
 +
 
 +
exit $?
 +
</pre>
 +
}}
 +
 
 +
==Quellen==
 +
* [[clipinc]]
  
[[Kategorie:Scripts]]
+
[[Kategorie:Skripte]]

Aktuelle Version vom 12. Juni 2006, 09:02 Uhr

Vorschlag für ein einfaches Skript um clipinc zu starten, welches über die reccmds.conf ausgeführt werden kann.

Datei
$PATH/clipinc.sh
#!/bin/sh
#
# clipinc.sh
#
# add this lines to your reccmds.conf:
# folgende zeilen in die reccmds.conf eintragen:
#
# Run clipinc   : /path_to_this_script/clipinc.sh -start
# Stop clipinc? : /path_to_this_script/clipinc.sh -kill

# CONFIG START
  CLIPINC_LOGFILE="/var/log/vdr/clipinc.log"
# CONFIG END

which clipinc.pl >/dev/null 2>&1 || { echo clipinc.pl $"not found" ... ; exit 1 ; }

case $1 in
     -start)
	if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
	    read PID < "$PIDFILE"
	    echo $"Clipinc process already active" "(pid: $PID)" ...
	else
	    if [ -e "$2/recinfo.conf" ] ; then
		screen -dm sh -c \
		" \
		    clipinc.pl \"$2\" > \"$CLIPINC_LOGFILE\" 2>&1 &
		    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process started"" (pid: \$!) ...\" ; \
		    echo \$! > \"$PIDFILE\" ; \
		    wait \$! ; \
		    rm -f \"$PIDFILE\" ; \
		    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process finished"" (pid: \$!) ...\" ; \
		"
	    else
		echo $"recinfo.conf not found" ...
	    fi
	fi
	;;
     -kill)
	if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
	    read PID < "$PIDFILE"
	    if ps -p $PID >/dev/null 2>&1 ; then
	        kill -9 $PID
	    fi
	    rm -f "$PIDFILE"
	fi
	;;
esac

exit $?


[Bearbeiten] Quellen