Clipinc.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(M)
 
(5 dazwischenliegende Versionen von 4 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
Skript für [[clipinc]]
+
Vorschlag für ein einfaches Skript um [[clipinc]] zu ''starten'', welches über die [[reccmds.conf]] ausgeführt werden kann.
  
 
{{Box Datei | [[Struktur|$PATH]]/clipinc.sh |
 
{{Box Datei | [[Struktur|$PATH]]/clipinc.sh |
Zeile 17: Zeile 17:
 
# CONFIG END
 
# CONFIG END
  
case "$1" in
+
which clipinc.pl >/dev/null 2>&1 || { echo clipinc.pl $"not found" ... ; exit 1 ; }
    -start)
+
 
 +
case $1 in
 +
    -start)
 
if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
 
if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
 
    read PID < "$PIDFILE"
 
    read PID < "$PIDFILE"
 
    echo $"Clipinc process already active" "(pid: $PID)" ...
 
    echo $"Clipinc process already active" "(pid: $PID)" ...
 
else
 
else
    if pidof atd >/dev/null ; then
+
    if [ -e "$2/recinfo.conf" ] ; then
if [ -e "$2/recinfo.conf" ] ; then
+
screen -dm sh -c \
    (
+
" \
echo "clipinc.pl \"$2\" > $CLIPINC_LOGFILE 2>&1 &"
+
    clipinc.pl \"$2\" > \"$CLIPINC_LOGFILE\" 2>&1 &
echo "PID=\$!"
+
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process started"" (pid: \$!) ...\" ; \
echo "svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process started"" (pid: \$PID) ...\" >/dev/null"
+
    echo \$! > \"$PIDFILE\" ; \
echo "echo \$PID > \"$PIDFILE\""
+
    wait \$! ; \
echo "wait \$PID"
+
    rm -f \"$PIDFILE\" ; \
echo "rm -f \"$PIDFILE\""
+
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process finished"" (pid: \$!) ...\" ; \
echo "svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"Clipinc process finished"" (pid: \$PID) ...\" >/dev/null"
+
"
    ) | at now
+
else
+
    echo $"recinfo.conf not found" ...
+
fi
+
 
    else
 
    else
echo $"Jobmanager (atd) is not running" ...
+
echo $"recinfo.conf not found" ...
 
    fi
 
    fi
 
fi
 
fi
 
;;
 
;;
    -kill)
+
    -kill)
 
if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
 
if [ -s "${PIDFILE:=$2/clipinc.pid}" ] ; then
 
    read PID < "$PIDFILE"
 
    read PID < "$PIDFILE"
Zeile 52: Zeile 50:
 
;;
 
;;
 
esac
 
esac
 +
 +
exit $?
 
</pre>
 
</pre>
 
}}
 
}}
 +
 +
==Quellen==
 +
* [[clipinc]]
  
 
[[Kategorie:Skripte]]
 
[[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