Old 11th February 2009, 17:12   #1
Multimix
Junior Member
 
Join Date: May 2007
Location: Hamilton, Ontario, CA
Posts: 6
Starting Shoutcast on Boot up

Hi, I have done lots of searching both in this forum and on the web for a sample on how to start my shoutcast server when my unix server reboots instead of I always having to SH into the server and start it up manually.

I did find a mac and something at the following link but its not working. http://forums.theplanet.com/index.ph...pic=13540&st=0

Can anyone point me to a topic some where which deals with this subject or a sample script?

Many Thanks
Multimix is offline   Reply With Quote
Old 11th February 2009, 19:44   #2
caraoge
Senior Member
 
caraoge's Avatar
 
Join Date: Dec 2003
Location: Saarland, Germany
Posts: 331
please delete
caraoge is offline   Reply With Quote
Old 11th February 2009, 19:51   #3
caraoge
Senior Member
 
caraoge's Avatar
 
Join Date: Dec 2003
Location: Saarland, Germany
Posts: 331
Step 1:
Create a file named "shoutcast" with the following content in "/etc/init.d/" or
download the attached file, rename, modify and copy it to "/etc/init.d/" (Full path "/etc/init.d/shoutcast"):

code:
#!/bin/sh
#
# Sample init script for SHOUTcast
# by caraoge
#

# Check for SHOUTcast binary
test -f /caraoge/sc_serv || exit 0

# The init commands
case "$1" in
start)
echo "Starting SHOUTcast server..."
/caraoge/sc_serv /caraoge/sc_serv.conf &
;;
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..."
/caraoge/sc_serv /caraoge/sc_serv.conf &
;;
*)
echo "usage: /etc/init.d/shoutcast"
echo "$0 {start | stop | restart}"
exit 1
;;
esac


Note: You have to edit the path to your SHOUTcast binary and your configuration file


Step 2:
Now you have to make the file executable:
code:
chmod 755 /etc/init.d/shoutcast


Step 3:
Create the startup scripts with (Debian!):
code:
update-rc.d shoutcast defaults


Step 4:
Now your SHOUTcast server starts up everytime your server pass through its startup sequence.
If your server is running, you can use
code:
/etc/init.d/shoutcast start

or
code:
/etc/init.d/shoutcast stop

or
code:
/etc/init.d/shoutcast restart

to control your SHOUTcast server.

Removing the SHOUTcast server from the startup sequence:
Type this on your command line:
code:
update-rc.d -f shoutcast remove
Attached Files
File Type: txt shoutcast.txt (921 Bytes, 945 views)
caraoge is offline   Reply With Quote
Old 12th February 2009, 01:08   #4
Multimix
Junior Member
 
Join Date: May 2007
Location: Hamilton, Ontario, CA
Posts: 6
Hi Garaoge, Many THANKS for the quick response and the script.

When I run this command: "update-rc.d shoutcast defaults" I get the error message: bash: update-rc.d: command not found.

However, when I run "/etc/init.d/shoutcast start" the server starts.

What should I be looking for?

Thanks

Fred
Multimix is offline   Reply With Quote
Old 19th February 2009, 00:25   #5
dopelabs
Major Dude
 
dopelabs's Avatar
 
Join Date: Oct 2006
Location: Silicon Valley
Posts: 519
Send a message via AIM to dopelabs
the following will start up services on boot, and will restart if it fails or crashes. ive tested this on freebsd 6 and 7, centos, macosx

a script that checks to see if the sc_serv is running, if it isnt, start it.

Create a file. name it whatever.. i call mine sc_mon.sh

put the following in it:
code:

#!/bin/sh
#!/usr/bin/perl



### Shoutcast (SC_SERV)


## SC_SERV Server 1
if
( ! ps auxwww | grep "/home/user/sc_serv/sc_serv /home/user/sc_serv/sc_serv.conf" | grep -v grep )
then echo "Shoutcast not running..."
/home/user/sc_serv/sc_serv /home/user/sc_serv/sc_serv.conf &
fi


save and close the file

chmod 777 sc_mon.sh

setup a cron job to run this script every 60 secs... mine looks like this:

*/1 * * * * /home/user/sc_serv/sc_mon.sh >> /dev/null 2>&1

this will execute the script every 60 secs to check if shoutcast is running and will start it if its not.

cheers

DopeLabs
dopelabs is offline   Reply With Quote
Old 19th February 2009, 14:26   #6
Multimix
Junior Member
 
Join Date: May 2007
Location: Hamilton, Ontario, CA
Posts: 6
Hi dopelabs, Many THANKS, this script sure works. It was a headache for me having to manually restart my shoutcast server.

I running Unix


Again Thanks

Fred
Multimix is offline   Reply With Quote
Old 3rd May 2018, 19:35   #7
AusFreak
Junior Member
 
Join Date: Jul 2017
Posts: 8
Its now 2018 and this won't work on centOS
remove " | grep -v grep " and it seems to work now for anyone in the future
AusFreak is offline   Reply With Quote
Old 12th May 2018, 07:17   #8
Creator
Junior Member
 
Creator's Avatar
 
Join Date: May 2018
Posts: 31
Quote:
Originally Posted by AusFreak View Post
Its now 2018 and this won't work on centOS
remove " | grep -v grep " and it seems to work now for anyone in the future
Thanks!
Creator is offline   Reply With Quote
Old 12th May 2018, 15:00   #9
dopelabs
Major Dude
 
dopelabs's Avatar
 
Join Date: Oct 2006
Location: Silicon Valley
Posts: 519
Send a message via AIM to dopelabs
Quote:
Originally Posted by AusFreak View Post
Its now 2018 and this won't work on centOS
remove " | grep -v grep " and it seems to work now for anyone in the future
you do not want to do this as it will create a false positive and will always try to start shoutcast... even if its already running...

the idea is only try to start IF its not running.

when the script checks the list of running processes

code:
ps auxwww | grep "/home/user/sc_serv/sc_serv /home/user/sc_serv/sc_serv.conf"


if sc_serv is running it will return 2 lines, one line that matches the sc_serv process
and one line that matches the ps auxwww command that you just executed.

if sc_serv is not running, it will return only the ps command you just executed, both resulting in a 'true' result.

the script has a ! at the beginning which means do something if there are no results or 'false' result.


if sc_serv is NOT running, then run it... and the only way it can tell if its NOT running is if you run

code:
! ps auxwww | grep "/home/user/sc_serv/sc_serv /home/user/sc_serv/sc_serv.conf" | grep -v grep


the grep -v grep ensures that when running ps, it will not return itself as a running process...

i hope that makes sense..
dopelabs is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > SHOUTcast > SHOUTcast Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump