VLC Start/Stop-Script

#!/bin/sh -e
# VLC start/stop script
 
NAME="VideoLAN streaming server"
PATH_TO="/usr/bin"
DAEMON="vlc"
OPTIONS="--daemon --extraintf http --http-host :8080"
 
[ -x $PATH_TO/$DAEMON ] || exit 1
 
running() {
	PIDS=`pidof $DAEMON 2> /dev/null`
	[ "$PIDS" ] && return 0 || return 1
}
 
do_start() {
	if running; then
		echo "$NAME always running with pid(s) $PIDS"
	else
		echo -n "Starting $NAME ... "
		su media -c "$PATH_TO/$DAEMON $OPTIONS"
		echo ""
        fi
}
 
do_stop() {
	if running; then
		echo "Stopping $NAME ... "
		i=0
		while running; do
			for PID in $PIDS; do
				echo -n " * $PID: "
				kill $PID 2> /dev/null
				if [ "$?" != "0" ]; then
					echo -n "."
					i=$(($i+1))
					if [ $i = "60" ]; then
						echo -n " Can't stop $NAME - nothing "
						break
					fi
					sleep 1
				fi
				echo "killed"
			done
		done
		#echo "done"
	else
		echo "$NAME doesn't running."
	fi
}
 
case "$1" in
'start')
	do_start
	;;
'stop')
	do_stop
	;;
'restart')
	do_stop
	do_start
	;;
*)
	echo "Usage: $0 {start|stop|restart}"
	exit 3
	;;
esac
exit 0
Nach oben
 
  wiki/scripte/script_vlc_start_stop.txt · Zuletzt geändert: 2010/01/23 10:11 (Externe Bearbeitung)
Valid XHTML 1.0 Valid CSS