One of the things that always bothered me about the shoutcast server was the fact that you had to stuff it in the rc.local in order to get it to start up. In order to fix that, I wrote a script for SYSV daemon startup for shoutcast. This script is optimized for Red Hat Linux (tested on 7.2 - 9.0) and can be made permanent with chkconfig as follows:
cd /etc/rc.d/init.d/;chkconfig --add shoutcast;chkconfig --level 3 shoutcast;chkconfig shoutcast on
Rantradio.com has been running this script since late november, and reliability has been GRRRRRRRRRRRRR8!
Feel free to either download the script here, or continue reading and copy and paste it.
#!/bin/bash
#
# chkconfig: 345 91 35
# description: Starts and stops sc_serv.
# You know, the mp3 streaming thang.
#
# Version 1.3 (nov 4 2001)
# Now with more revisions! System now checks for pid file before cat
# to display so that we receive no error messages. System also displays
# pids as we are killing old processes. Profanity was removed from the
# startup messages. Tests for a pid file before reporting success. Displays
# the relay server name when we start the daemon up, so that we know
# which servers are getting booted. Pushed the success marker over to the
# right and added [] because I am just a slave to fashion.
#
# Version 1.2 (nov 3 2001)
# Same exact shit, but runs as nobody for security reasons. Just
# in case we are worried about buffer overflows or whatnot.
#
# Version 1.1 (nov 3 2001)
# Starts stops and restarts jobs. Also checks for existing daemons
# before calling a start, and exits without starting new ones. This
# prevents you from being a dumbass and starting multiple listeners
# on the same port. I would suggest using the restart command
# in these cases. Also creates a shoutcast.pid file that can be used
# to discover all of the (many) pids used by shoutcast when running.
#
# Version 1.0 (nov 3 2001)
# Starts and stops successfully.
# Kills old jobs on start command. Dirty, but
# does the job well enough. Tested functional on
# mandrake version 8.1 but should work on redhat
# or any other distro that supports a standard
# sysv startup script.
#
# Instructions for use.
# 1: untargzip shoutcast into the directory of your choosing
# 2: copy sc_serv into the /usr/sbin directory
# 3: Create the directory /etc/shoutcast
# 4: copy the shoutcast.conf file into your /etc/shoutcast dir.
# 5: Edit the shoutcast.conf file to match your needs.
# 6: Make as many more conf files as needed to support
# multiple streams. Be sure to edit these files so that
# you are not starting multiple shoutcast servers that
# are either listening or broadcasting on the same port.
# 7: Copy this file into the /etc/rc.d/init.d directory
# 8: chmod this file +x (chmod ug+x /etc/rc.d/init.d/shoutcast)
# 9: run chkconfig --add shoutcast from the /etc/rc.d/init.d dir.
# 10:Run /etc/rc.d/init.d/shoutcast start
# 11:Drink a beer, or light one up, and enjoy the tunes.
#
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up. This line may cause an error on incompatible
# distributions. Remove it if necessary. Also remove if the startup always
# fails for no apparent reason.
[[ ${NETWORKING} = "no" ]] && exit 0
stop (){
#First we want to kill the original servers, so we don't get errors.
echo "Killing old shoutcast servers."
for oldpid in `ps -A | grep sc_serv | cut -c 0-6`; do
kill -9 $oldpid
if [[ $1 == "-v" ]]
then
echo $oldpid
fi
done
rm -f /var/run/shoutcast.pid
}
start (){
#Now we can start the servers up.
if [[ $1 == "-v" ]]
then
echo "Starting up the new shoutcast servers. Starting..."
fi
servcount=`expr 0`
for cfile in `ls /etc/shoutcast`; do
echo -n $cfile
echo -n " -> "
grep ^RelayServer /etc/shoutcast/$cfile
# This is the line where we actually run the shoutcast program!
#sudo -u nobody /usr/bin/sc_serv /etc/shoutcast/$cfile > /dev/null &
/usr/bin/sc_serv /etc/shoutcast/$cfile > /dev/null &
let servcount=servcount+1
done
#Create the pid file...
ps -A | grep sc_serv | cut -c 0-6 > /var/run/shoutcast.pid
#Done now!
echo "Started $servcount servers."
}
case "$1" in
start)
if [[ ! -e /var/run/shoutcast.pid ]]
then
start $2
if [[ -e /var/run/shoutcast.pid ]]
then
echo "Startup [SUCCESS]"
fi
else
if [[ $2 == "-v" ]]
then
echo "Shoutcast is already running these processes:"
#Toldja! Checks before displaying pid file.
if [[ -e /var/run/shoutcast.pid ]]
then
cat /var/run/shoutcast.pid
fi
echo "Try calling shoutcast restart in order to kill old processes."
else
echo "SC_SERV is already running. Try calling shoutcast restart."
fi
echo "Startup [FAILED]"
fi
;;
restart)
stop $2
if [[ $2 == "-v" ]]
then
echo "Waiting for the old servers to die..."
fi
sleep 4
start $2
if [[ -e /var/run/shoutcast.pid ]]
then
echo "Startup [SUCCESS]"
fi
;;
stop)
if [[ -e /var/run/shoutcast.pid ]];
then
stop $2
echo "Shoutcast shutdown [SUCCESS]"
else
echo "There are no registered shoutcast servers running right now. Attempting to kill anyways."
stop $2
fi
;;
*)
echo "Usage: shoutcast (start|stop|restart) [-v]"
esac
This script is superb and is working 100% for me.
Thanks
Posted by: Matt at August 31, 2003 12:06 PMOMG i cant belive i googled this one out!!! this is exactly wut i need and wut i been looking for. it works great. THANKS!!!!!!!!!!!!!
Posted by: mike at October 9, 2003 03:40 AMSuggestion: add in the sc log file, the killing of de shoutcast when this is stoped. ;-)
Posted by: blackhead at October 13, 2003 02:33 PMlooks nice. i don't suppose there a snowball's chance in hell that you'd be writing a script for the SHOUTcast DSP plug-in for linux as well? :)
Posted by: hugo at October 28, 2003 07:14 PMExcellent work, but you reference sc_serv in both /usr/bin and /usr/sbin; which do you prefer?
Posted by: Artok at December 3, 2003 07:07 PMI would say modify the script to launch from wherever you put it. I would recommend placing it in sbin, since you are running it as root. You may want to suid the server as well for more security. I have some new scripts, but haven't finished testing them yet.
Posted by: Enki at December 4, 2003 09:29 AMno comments
Posted by: kaur at December 9, 2003 06:33 AMno comments
Posted by: kaur at December 9, 2003 06:33 AMThis helped a ton. Thanks a lot for doing this, it worked right off the bat. I added a "status" subroutine too. Do all versions of redhat linux come with the /etc/rc.d/init.d/functions ? if so, then perhaps you can alter the script to use these built in functions for displaying [ OK ] or [ FAILED ] in the fancy green or red that you see during a linux boot. There is also a built in status() function in that library.
Also, how do you get the script to not run as root. The one you have here on your site claims to run as nobody, but when I do a ps -aux I see that sc_serv is running as root.
Thanks so much for your hard work. Email me at
amn (at) nospam frognet.net
hopefully you can demangle my email address ;-) and the bots can't.
Posted by: Matt at January 7, 2004 04:58 PMPHAT Respect!
Posted by: David at February 19, 2004 09:54 AMThis is an awsome script.
Is there anyway to make it so it only reads the pid number of the stream you'd like to reset instead of all of them?
Say, if you have multple streams, and there is a passwd change in the sc_serv.conf file, you need to restart that one stream to make it take effect.
I have my conf's renamed to the port number like 8008.conf so when I do a ps x I can see what ports are running.
I'm thinking it would be great if you could have a script in each users stream dir and some how pull the pid running and reset just that one to initial the new conf changes instead of interupting all the streams.
If anyone can help, please email me at rainner468@yahoo.com
Thanks
Rainner
Posted by: rainner at March 13, 2004 03:37 PMThis is an awsome script.
Is there anyway to make it so it only reads the pid number of the stream you'd like to reset instead of all of them?
Say, if you have multple streams, and there is a passwd change in the sc_serv.conf file, you need to restart that one stream to make it take effect.
I have my conf's renamed to the port number like 8008.conf so when I do a ps x I can see what ports are running.
I'm thinking it would be great if you could have a script in each users stream dir and some how pull the pid running and reset just that one to initial the new conf changes instead of interupting all the streams.
If anyone can help, please email me at rainner468@yahoo.com
Thanks
Rainner
Posted by: rainner at March 13, 2004 03:38 PMI just installed the script. It appeared to work fine, but none of my clients could connect. I had to start the servers from their original folders instead of the ones I created via your specs. Thanks
Posted by: Kevin at March 24, 2004 06:58 PMI need sum help settin up a radio station, i downloaded wat i need jus dunno how to get a link for ir so people can hear it
Posted by: mk at April 27, 2004 10:54 AMI need sum help settin up a radio station, i downloaded wat i need jus dunno how to get a link for ir so people can hear it
Posted by: mk at April 27, 2004 10:54 AMI need sum help settin up a radio station, i downloaded wat i need jus dunno how to get a link for ir so people can hear it
Posted by: mk at April 27, 2004 10:54 AMWhat if we have multiple servers, where do we ad the command for the extra conf files? and do we need to change the sevcount value?
Posted by: ameno at May 21, 2004 04:28 PMYou rock the Kasbah!! My scripts always ate it.
Posted by: Swamp at June 8, 2004 01:03 PMYour ultimate video on demand solutions
Posted by: at September 9, 2004 12:13 AMCialis information online site.
Posted by: Cialis online at October 9, 2004 12:33 PM4262 http://www.texas-hold-em-i.com play texas hold em online here.
Posted by: texas hold em at October 11, 2004 07:08 PMNice site yo got here! I really like it!
Posted by: penis extender at October 13, 2004 06:05 AM8092 http://www.e-texas-holdem.info
texas holdem
Posted by: texas holdem at October 13, 2004 08:56 AMInfo on Levaquin online.
Posted by: Levaquin at October 14, 2004 03:48 AM7946 http://www.e-texas-hold-em.com
texas hold em
Posted by: texas hold em at October 14, 2004 03:51 PMSeasonale online info site.
Posted by: Cheap Seasonale at October 15, 2004 06:02 AM3 http://www.rapid-debt-consolidation.com
consolidate debt
Posted by: debt consolidation at October 17, 2004 03:46 AMFioricet prescription info site.
Posted by: buy Fioricet at October 18, 2004 02:59 AMThe real question is not whether machines think but whether men do.
Posted by: fleshlight at October 20, 2004 08:22 AMBy recognizing a favorable opinion of yourself, and taking pleasure in it, you in a measure give yourself and your peace of mind into the keeping of another, of whose attitude you can never be certain.
Posted by: vimax at October 22, 2004 01:29 PMRemeron information.
Posted by: Remeron online at October 23, 2004 12:38 AMUniversal doubt cancels itself.
Posted by: penis pills at October 23, 2004 04:42 AMCheck Effexor info site.
Posted by: Effexor at October 24, 2004 03:59 AMWhat's Crackin! - Just need to go Play Bingo - for my Online Bingo Habit! But I cannot Find a Good Bingo Online website to cover my bingo addiction!
Posted by: Bingo at October 25, 2004 02:43 AMCelexa online info.
Posted by: Celexa at October 26, 2004 12:58 AMThe fundamental sense of freedom is freedom from chains, from imprisonment, from enslavement by others. The rest is extension of this sense, or else metaphor.
Posted by: penis enlargement pills at October 26, 2004 07:51 AMHappy to read this, that is great guys!
Posted by: gazduire at October 26, 2004 03:11 PMtravel
online gambling
finances
homes
internet
health
shopping
insurance
education
careers
entertainment
business
internet marketing
autos
romance
You guys may find interesting these links.
Hello.
I've been looking around and came across your site by accident. The information you link to from your home page is quite informative so thanks for taking the time to post it.
Joe
trim spa health risks
Hello.
I've been looking around and came across your site by accident. The information you link to from your home page is quite informative so thanks for taking the time to post it.
Joe
zymax
Hello there,
Iwas browsing the web and found this blog. Some interesting quotes. Keep them coming!
Alice
debt consolidation loans with bad credit
Money does not pay for anything, never has, never will. It is an economic axiom as old as the hills that goods and services can be paid for only with goods and services.
Posted by: vimax at November 4, 2004 01:00 PMIt's not so hard to lift yourself by your bootstraps once you're off
the ground.
-- Daniel B. Luten
Wellbutrin online site.
Posted by: Wellbutrin at November 6, 2004 12:45 AMExperience is something you don't get until just after you need it.
-- Olivier
Texas Holdem http://www.texas-holdem-poker-casino.com
If God didn't mean for us to juggle, tennis balls wouldn't come three
to a can.
Credit Report http://www.credit-report-x.com
Of course there's no reason for it, it's just our policy.
Online Dating http://www.online-dating-com.com
Swipple's Rule of Order:
He who shouts the loudest has the floor.
Auto Insurance http://www.auto-insurance-com.com
Democracy is the recurrent suspicion that more than half of the people
are right more than half of the time.
-- E. B. White
Home Equity Loan http://www.home-equity-loan-x.com
The world is coming to an end ... SAVE YOUR BUFFERS!!!
Refinance Mortgage http://www.refinance-mortgage-com.com
hot 3 reel and 5 reel single online video slots
Posted by: online slots at November 9, 2004 11:17 AMNever call a man a fool. Borrow from him.
Mortgage Refinancing http://www.refinance-mortgage-com.com
highest quality replica jewelry Rolex watch, wrist watch, Replica Watch purchase your affordable realistic Rolex replica watch today at http://www.pro-rolex-replica-watches.com
Posted by: Rolex Replica at November 13, 2004 10:22 PMREDEFINING THE ROLE OF THE UNITED STATES FROM ENABLERS TO KEEP THE PEACE TO ENABLERS TO KEEP THE PEACE FROM PEACEKEEPERS IS GOING TO BE AN ASSIGNMENT.
- George W Bush, JAN. 14, 2002THE CALIFORNIA CRUNCH REALLY IS THE RESULT OF NOT ENOUGH POWER-GENERATING PLANTS AND THEN NOT ENOUGH POWER TO POWER THE POWER OF GENERATING PLANTS.
- George W Bush, JAN. 14, 2001 Home Equity Loan Rate http://www.home-equity-loan-x.com