1

Topic: Shoutcast Automatic Start Script

I found this script and modified it a bit so it starts all three of my Shoutcast servers automatically when/if the server ever restarts. That part works great. However, there's something I would like to change...I want to be able to manage each server individually. I'm not really sure what to do to accomplish this.

For instance, I want to be able to do "service shoutcast restart" and somehow be able to choose which one to restart (or restart all of them if no specific server is specified). Restarting them all isn't acceptable when I'm only making configuration changes to one (kicking all users=bad). There is the method of hunting down the pid and killing it and then typing in the command to start it again, but that's getting old rather fast.

I'd appreciate any suggestions.

#!/bin/sh
#
# chkconfig: 345 99 01
#
# description: shoutcast server startup script
#
# Init script for SHOUTcast
# by caraoge, modified to work correctly by Thomas R Bailey, modified further for
# use with three servers by Nathan Skelton
#
# Last edited Jan 13 2009

# Set config to config file location
# set daemon to sc_serv location
############################################################################
##  CHANGE THESE VALUES to match your setup
## CONFIG is the fully qualified location of your config file
## DAEMON is the fully qualified location of the sc_serv binary
## Note, the script will look for sc_serv and sc_serv.conf in /home/shoutcast
############################################################################
DAEMON="/home/shoutcast/sc_serv"
CONFIG="/home/shoutcast/sc_serv.conf"
CONFIG2="/home/shoutcast/sc_serv2.conf"
CONFIG3="/home/shoutcast/sc_serv3.conf"

############# Don't fiddle below this line ##############
# Check for SHOUTcast binary
test -f $DAEMON || exit 0

# The init commands
case "$1" in
        start)
                echo "Starting SHOUTcast server..."
                $DAEMON $CONFIG  > /dev/null 2>&1 &
                $DAEMON $CONFIG2  > /dev/null 2>&1 &
                $DAEMON $CONFIG3  > /dev/null 2>&1 &
                ;;
        stop)
                echo "Stopping SHOUTcast server..."
                kill -9 `ps -C sc_serv -o pid --no-headers`
                ;;
        restart)
                echo "Stopping SHOUTcast server..."
                kill -9 `ps -C sc_serv -o pid --no-headers`
                echo "Starting SHOUTcast server..."
                $DAEMON $CONFIG  > /dev/null 2>&1 &
                $DAEMON $CONFIG2  > /dev/null 2>&1 &
                $DAEMON $CONFIG3  > /dev/null 2>&1 &
                ;;
        *)
                echo "usage: /etc/init.d/shoutcast"
                echo "$0 {start | stop | restart}"
                exit 1
                ;;
esac

And for those interested in this, here are the steps to set this up (by memory, so please correct me if I'm wrong):
cd /etc/init.d
nano shoutcast
**paste in above data and save**
chmod 0755 /etc/init.d/shoutcast
cd /etc/rc.d/rc5.d
ln -s ../init.d/shoutcast S99shoutcast
chkconfig --add shoutcast
chkconfig shoutcast on
/etc/init.d/shoutcast start

Of course you would remove "$DAEMON $CONFIG2  > /dev/null 2>&1 &," "$DAEMON $CONFIG3  > /dev/null 2>&1 &," etc, unless you are running more than one server. Setting $DAEMON and $CONFIG to wherever you placed Shoutcast is also necessary.

2

Re: Shoutcast Automatic Start Script

Nice! Very helpful for me. Thanks.

the detour network - http://thedetour.us - Knoxville/Tri-Cities, TN - Phoenix, AZ
detour MUSIC, detour TALK, detour BLUES, State of Franklin Radio

Purple Zebra Media Services - http://purplezebra.us

3

Re: Shoutcast Automatic Start Script

aaronsnet wrote:

Nice! Very helpful for me. Thanks.

You're very welcome. I'm glad it helped. :-)

4

Re: Shoutcast Automatic Start Script

That's great, audioprobe....:)

Your modification is very nice...

I would use it on my work...

Thanks...