zefie

Kenzi Audio Stream

Apr 11th, 2012
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.31 KB | None | 0 0
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          kenzi_audio_stream
  4. # Required-Start:    $remote_fs $syslog networking
  5. # Required-Stop:     $remote_fs $syslog networking
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: Start an RTP stream for remote audio
  9. # Description:       Strart an RTP stream to stream line in to remote devices.
  10. ### END INIT INFO
  11.  
  12. VLCUSER="zefie"
  13. ADDRESS="192.168.2.5"
  14. STREAMPORT="5567"
  15. RTSPPORT="5554"
  16. STREAMNAME="kenzi"
  17.  
  18. case "$1" in
  19.   start)
  20.     if [ -f /tmp/vlcstream_${STREAMNAME}.pid ]; then
  21.         echo "Error: Already running? If not, remove /tmp/vlcstream_${STREAMNAME}.pid"
  22.         # TODO: Autodetect if pid is tombstone and fix
  23.         exit
  24.     else
  25.             echo "Starting Kenzi Audio Stream..."
  26.         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 &
  27.     fi
  28.         ;;
  29.   stop)
  30.     if [ -f /tmp/vlcstream_${STREAMNAME}.pid ]; then
  31.         echo "Stopping Kenzi Audio Stream..."
  32.         kill $(cat /tmp/vlcstream_${STREAMNAME}.pid)
  33.     else
  34.         echo "Error: Cannot find pid file";
  35.         exit;
  36.     fi
  37.         ;;
  38.   *)
  39.         echo "Usage: $0 {start|stop}" >&2
  40.         exit 1
  41.         ;;
  42. esac
Add Comment
Please, Sign In to add comment