Noad.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
K (Änderungen von Benutzer:89.96.169.141 rückgängig gemacht und letzte Version von Benutzer:Anonymous wiederhergestellt)
 
(45 dazwischenliegende Versionen von 32 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
Vorschlag für ein einfaches Skript um [[noad]] zu ''starten'', welches über die [[reccmds.conf]] ausgeführt werden kann.
 +
 +
{{Box Datei | [[Struktur|$PATH]]/noad.sh |
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
 
#
 
#
# noad.sh - v.0.1
+
# noad.sh
 +
#
 +
# source: noad
 
#
 
#
 
# add this lines to your reccmds.conf:
 
# add this lines to your reccmds.conf:
 
# folgende zeilen in die reccmds.conf eintragen:
 
# folgende zeilen in die reccmds.conf eintragen:
 
#
 
#
# Start advertising filter    : /usr/local/bin/noad.sh -start
+
# Run noad                          : /path_to_this_script/noad.sh -start
# View Cut list              : /usr/local/bin/noad.sh -marks
+
# Run noad, all recordings (batch)? : /path_to_this_script/noad.sh -batch
# Advertising filter overview : /usr/local/bin/noad.sh -count
+
# In prozess                        : /path_to_this_script/noad.sh -count
# Stop advertising filter    : /usr/local/bin/noad.sh -stop
+
# Stop noad (killpid)              : /path_to_this_script/noad.sh -killpid
 
+
# Stop noad (killall)?              : /path_to_this_script/noad.sh -killall
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
# Remove marks                      : /path_to_this_script/noad.sh -rmmarks
 +
# Remove all marks?                : /path_to_this_script/noad.sh -rmallmarks
  
 
# CONFIG START
 
# CONFIG START
   NOADOPT="nice --background --jumplogo --ac3 --overlap --OSD --statisticfile=/var/log/noadstat"
+
   NOADOPTS="nice --ac3 --overlap --jumplogo --comments --OSD --statisticfile=/var/log/vdr/noad.log"
 +
  VDR_VIDEO="/video0"
 
# CONFIG END
 
# CONFIG END
  
case "${1}" in
+
which noad >/dev/null 2>&1 || { echo noad $"not found" ... ; exit 1 ; }
      -start)
+
 
echo "Recording: "
+
case $1 in
 +
    -start)
 +
echo $"Recording" ...
 
echo
 
echo
echo "${2}"
+
echo "$2"
 
echo
 
echo
test -e "${2}/noad.pid" && {
+
if [ -s "${PIDFILE:=$2/noad.pid}" ] ; then
    echo "Advertising filter is already active."
+
    read PID < "$PIDFILE"
    } || {
+
    if ps -p $PID >/dev/null 2>&1 ; then
    echo "/usr/local/bin/noad ${NOADOPT} \"${2}\"" | at now
+
echo $"Noad process already active" "(pid: $PID)" ...
    echo "Advertising filter startet."
+
exit 0
}
+
    else
 +
        rm "$PIDFILE"
 +
    fi
 +
fi
 +
screen -dm sh -c "noad $NOADOPTS \"$2\""
 +
echo $"Noad startet" ...
 
;;
 
;;
      -marks)
+
    -batch)
echo "Recording: "
+
        screen -dm bash -c " \
echo
+
    while read i ; do \
echo "${2}"
+
noad $NOADOPTS \"\$i\" &
echo
+
wait \$! ; \
test -e "${2}/noad.pid" && {
+
    done < <(find "$VDR_VIDEO" -follow -name "*.rec")"
    echo "Advertising filter is still active."
+
    echo
+
}
+
test -e "${2}/marks.vdr" && {
+
    cat "${2}/marks.vdr"
+
    } || {
+
    echo "There is not missing cut markings."
+
}
+
 
;;
 
;;
      -count)
+
    -count)
echo "Counting of the advertising filters:"
+
echo $"Noad processes" $(pidof noad | wc -w | tr -d ' ') ...
echo
+
ps axc|awk "{if (\$5==\"noad\") print \$1}"|wc -w|tr -d ' '
+
 
;;
 
;;
      -stop)
+
    -killpid)
echo "Recording: "
+
echo $"Recording" ...
 
echo
 
echo
echo "${2}"
+
echo "$2"
 
echo
 
echo
test -e "${2}/noad.pid" && {
+
if [ -s "${PIDFILE:=$2/noad.pid}" ] ; then
    kill `cat "${2}/noad.pid"`
+
    read PID < "$PIDFILE"
    echo "Advertising filter stopped."
+
    if ps -p $PID >/dev/null 2>&1 ; then
    } || {
+
kill $PID
    echo "Advertising filter is not active."
+
echo $"Noad stopped" "(pid: $PID)" ...
}
+
exit 0
 +
    fi
 +
            rm -f "$PIDFILE"
 +
fi
 +
echo $"Noad is not active" ...
 
;;
 
;;
      -kill)
+
    -killall)
killall noad
+
pidof noad | xargs -r kill
 +
;;
 +
    -rmmarks)
 +
rm -f "$2/marks.vdr"
 +
;;
 +
    -rmallmarks)
 +
find "$VDR_VIDEO" -follow -type f -name marks.vdr -print0 2>/dev/null | xargs -r0 rm
 +
;;
 +
    *)
 +
echo "unrecognized option: $1"
 +
exit 1
 
;;
 
;;
 
esac
 
esac
 +
 +
exit $?
 
</pre>
 
</pre>
 +
}}
  
Quelle: Aus den Sourcen von [[Noad]].
+
==Quellen==
 +
* [[noad]]
  
[[Kategorie:Scripts]]
+
[[Kategorie:Skripte]]

Aktuelle Version vom 25. Mai 2009, 07:42 Uhr

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

Datei
$PATH/noad.sh
#!/bin/sh
#
# noad.sh
#
# source: noad
#
# add this lines to your reccmds.conf:
# folgende zeilen in die reccmds.conf eintragen:
#
# Run noad                          : /path_to_this_script/noad.sh -start
# Run noad, all recordings (batch)? : /path_to_this_script/noad.sh -batch
# In prozess                        : /path_to_this_script/noad.sh -count
# Stop noad (killpid)               : /path_to_this_script/noad.sh -killpid
# Stop noad (killall)?              : /path_to_this_script/noad.sh -killall
# Remove marks                      : /path_to_this_script/noad.sh -rmmarks
# Remove all marks?                 : /path_to_this_script/noad.sh -rmallmarks

# CONFIG START
  NOADOPTS="nice --ac3 --overlap --jumplogo --comments --OSD --statisticfile=/var/log/vdr/noad.log"
  VDR_VIDEO="/video0"
# CONFIG END

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

case $1 in
     -start)
	echo $"Recording" ...
	echo
	echo "$2"
	echo
	if [ -s "${PIDFILE:=$2/noad.pid}" ] ; then
	    read PID < "$PIDFILE"
	    if ps -p $PID >/dev/null 2>&1 ; then
		echo $"Noad process already active" "(pid: $PID)" ...
		exit 0
	    else
	        rm "$PIDFILE"
	    fi
	fi
	screen -dm sh -c "noad $NOADOPTS \"$2\""
	echo $"Noad startet" ...
	;;
     -batch)
        screen -dm bash -c " \
	    while read i ; do \
		noad $NOADOPTS \"\$i\" &
		wait \$! ; \
	    done < <(find "$VDR_VIDEO" -follow -name "*.rec")"
	;;
     -count)
	echo $"Noad processes" $(pidof noad | wc -w | tr -d ' ') ...
	;;
     -killpid)
	echo $"Recording" ...
	echo
	echo "$2"
	echo
	if [ -s "${PIDFILE:=$2/noad.pid}" ] ; then
	    read PID < "$PIDFILE"
	    if ps -p $PID >/dev/null 2>&1 ; then
		kill $PID
		echo $"Noad stopped" "(pid: $PID)" ...
		exit 0
	    fi
            rm -f "$PIDFILE"
	fi
	echo $"Noad is not active" ...
	;;
     -killall)
	pidof noad | xargs -r kill
	;;
     -rmmarks)
	rm -f "$2/marks.vdr"
	;;
     -rmallmarks)
	find "$VDR_VIDEO" -follow -type f -name marks.vdr -print0 2>/dev/null | xargs -r0 rm
	;;
     *)
	echo "unrecognized option: $1"
	exit 1
	;;
esac

exit $?


[Bearbeiten] Quellen