#!/bin/sh # # ice-downcoders relays and downcodes an icecast stream. # # chkconfig: 345 96 24 # description: relays and downcodes an icecast stream. # # Copyright © 2000-2006 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # Created: 3-Jul-2000 from_1=http://cerebellum.dnalounge.com:8000/ from_2=http://localhost:8000/live/128 output=http://localhost:8000/live downcoder_opts="-v --public" # pull the password out of the icecast config icecast_conf=/usr/local/icecast/conf/icecast.conf if [ -f $icecast_conf ]; then passwd=`sed -n 's/^[ \t]*encoder_password[ \t][ \t]*\(.*\)$/\1/p' \ $icecast_conf` else # icecast_conf=/usr/local/icecast/etc/icecast.xml icecast_conf=/etc/icecast.xml passwd=`sed -n 's/^.*\([^<>]*\)<.*$/\1/p' \ $icecast_conf` fi # Source function library. . /etc/rc.d/init.d/functions PATH=/sbin:$PATH PATH=/usr/local/bin:$PATH PATH=/home/jwz/src/icecast:$PATH export PATH LANG=C export LANG # See how we were called. case "$1" in start) if [ `whoami` = root ] ; then sucmd='su icecast -s /bin/sh' else sucmd='/bin/sh' fi $sucmd <<__EOF__ ulimit -c 0 echo -n "Starting icecast relays from $from_1..." ice-downcoder-loop.sh $downcoder_opts $from_1 $output/128 128 $passwd & # sleep 5 # ice-downcoder-loop.sh $downcoder_opts $from_2 $output/96 96 $passwd & # sleep 1 # ice-downcoder-loop.sh $downcoder_opts $from_2 $output/64 64 $passwd & # sleep 1 ## ice-downcoder-loop.sh $downcoder_opts $from_2 $output/48 48 $passwd & ## sleep 1 # ice-downcoder-loop.sh $downcoder_opts $from_2 $output/32 32 $passwd & # sleep 1 # ice-downcoder-loop.sh $downcoder_opts $from_2 $output/24 24 $passwd & # sleep 1 update-downcoder-metadata.sh $from_1 & __EOF__ echo "done." ;; stop) echo -n "Stopping icecast relays..." # "killall" hates sh scripts... #killall ice-downcoder-loop.sh ice-downcoder.pl update-downcoder-metadata.sh pids=`ps auxww | \ grep 'ice-downcoder\.pl\|ice-downcoder-loop\.sh\|update-downcoder-metadata\.sh' | \ sed 's/ */ /g' | \ cut -d' ' -f2` pids=`echo $pids` if [ "$pids" != "" ]; then echo -n " ($pids) " kill $pids else echo -n " (nothing to kill) " fi echo "done." ;; restart) $0 stop $0 start ;; restart2) echo -n "Resetting downcoded icecast relays..." pids=`ps auxww | \ grep 'ice-downcoder\.pl' | \ grep -v '128 128' | \ sed 's/ */ /g' | \ cut -d' ' -f2` pids=`echo $pids` if [ "$pids" != "" ]; then echo -n " ($pids) " kill $pids else echo -n " (nothing to kill) " fi echo "done." ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac