#!/bin/sh
### BEGIN INIT INFO
# Provides: kenzi_audio_stream
# Required-Start: $remote_fs $syslog networking
# Required-Stop: $remote_fs $syslog networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start an RTP stream for remote audio
# Description: Strart an RTP stream to stream line in to remote devices.
### END INIT INFO
VLCUSER="zefie"
ADDRESS="192.168.2.5"
STREAMPORT="5567"
RTSPPORT="5554"
STREAMNAME="kenzi"
case "$1" in
start)
if [ -f /tmp/vlcstream_${STREAMNAME}.pid ]; then
echo "Error: Already running? If not, remove /tmp/vlcstream_${STREAMNAME}.pid"
# TODO: Autodetect if pid is tombstone and fix
exit
else
echo "Starting Kenzi Audio Stream..."
sudo -u ${VLCUSER} vlc alsa://hw:0,0 -d --pidfile /tmp/vlcstream_${STREAMNAME}.pid --no-sout-video --alsa-caching=1 --sout "#rtp{dst=${ADDRESS},port=${STREAMPORT},sdp=rtsp://${ADDRESS}:${RTSPPORT}/${STREAMNAME}.sdp,caching=0}" 2>/dev/null > /dev/null &
fi
;;
stop)
if [ -f /tmp/vlcstream_${STREAMNAME}.pid ]; then
echo "Stopping Kenzi Audio Stream..."
kill $(cat /tmp/vlcstream_${STREAMNAME}.pid)
else
echo "Error: Cannot find pid file";
exit;
fi
;;
*)
echo "Usage: $0 {start|stop}" >&2
exit 1
;;
esac
Comments