Shoutcast startup script

Anybody out there have a shoutcast server that they were able to get to startup with the system.

I have been trying many many things and all with no luck

I found this using google

#!/bin/sh
# description: SHOUTcast streaming MP3 radio station server
# chkconfig: 2345 99 00

case "$1" in
'start')
        cd /home/shoutcast/bin && ./sc_serv
        touch /var/lock/subsys/shoutcast
        ;;
'stop')
        rm -f /var/lock/subsys/shoutcast
        ;;
*)
        echo "Usage: $0 { start | stop }"
        ;;
esac
exit 0

named shoutcast and placed in /etc/init.d
chmod 755

then made a simlink to /etc/init.d/rc3.d

ln -s /etc/init.d/shoutcast /etc/rc.d/rc3.d/S08shoutcast
S08 was open and it is after network startup wich is S06

I restart the computer and to my dismay it does not autostart.

Go to yast to check runlevels and it is listed and it says “yes” for startup… I went to advanced and it conferms is in runlevel 3 (the runlevel i use)

If I go to enable in yast a box comes up and says shoutcast start and does not go away, if i hit F10 it gives an error saying NULL and leaves you to believe the server is not started. but it is. I can see it in ps -ef and i can also connect to it from my windows laptop with winamp

Anyone succesfully get a shoutcast server to autostart… Please help.

Thanks

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If you run the script from the command line do you get any errors? Does
it work?

Good luck.

geoffmcc wrote:
| Anybody out there have a shoutcast server that they were able to get to
| startup with the system.
|
| I have been trying many many things and all with no luck
|
| I found this using google
|
|

Code:
#!/bin/sh
# description: SHOUTcast streaming MP3 radio station server
# chkconfig: 2345 99 00
case “$1” in
‘start’)
cd /home/shoutcast/bin && ./sc_serv
touch /var/lock/subsys/shoutcast
;;
‘stop’)
rm -f /var/lock/subsys/shoutcast
;;
*)
echo "Usage: $0 { start
;;
esac
exit 0
--------------------
named shoutcast and placed in /etc/init.d
chmod 755
then made a simlink to /etc/init.d/rc3.d
> ln -s /etc/init.d/shoutcast /etc/rc.d/rc3.d/S08shoutcast S08 was open

and it is after network startup wich is S06
|
| I restart the computer and to my dismay it does not autostart.
|
| Go to yast to check runlevels and it is listed and it says “yes” for
| startup… I went to advanced and it conferms is in runlevel 3 (the
| runlevel i use)
|
| If I go to enable in yast a box comes up and says shoutcast start and
| does not go away, if i hit F10 it gives an error saying NULL and leaves
| you to believe the server is not started. but it is. I can see it in ps
| -ef and i can also connect to it from my windows laptop with winamp
|
| Anyone succesfully get a shoutcast server to autostart… Please help.
|
| Thanks
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIatxa3s42bA80+9kRAvNiAJ91QAiYJDLYKOoboQzfI6M8NbzBSACeJY/s
wR0zPaQE8pIm5gDthGeMfzQ=
=G+oK
-----END PGP SIGNATURE-----

OK I got it figured out. I placed the shoutcast script in /etc/init.d

then ran command:

chkconfig -a shoutcast

restarted and shoutcast server has autostarted,
now the problem i face is that it is running under root.

Im thinking thats not the best of ideas. Any thoughts

You should use the utility program startproc which is designed to handle all the various settings a server process might take. Also creates/checks pid files, etc. See the man page for usage info, and existing init scripts for examples of use.

Ken you are awesome. I was wondering when you were gonna chime in with your helpful advice. I should just PM you rather than post, lol

I read threw man page… I think i can figure that out.
I just removed everything that i did, and restarted to make sure it dont startup again then i will give it a try

Thanks again

well i got it to start under the right user but it is not detecting the conf file. What do i need to add after path to sc_srv to let it know to use sc_serv.conf

i thought it was && but thats not right

actually now that i look closer, it says unable to find sc_serv.conf even though it is in same dir as sc_serv ???

ugh


startproc -u username /home/username/bin/sc_serv

starts the server but states, cannot find sc_serv.conf using defaults… even though the conf file is in same directory as sc_serv

so then i try

startproc -u username /home/username/bin/sc_serv > /home/username/bin/sc_serv.conf

same thing. i cant get this to notice the conf file that is in the same directory as the server… i think im gonna give up for the night, will check back tomorrow

startproc doesn’t do any chdir or anything like that so the current directory is wherever the init script is run. sc_serv might have an option which might set the config file, otherwise you should do:

cd /home/username/bin; startproc ... ./sc_serv

BTW, I think your > redirection wiped out the config file in your last experiment.

still no go, no matter what i do it does not find the config file even though it is in same directory

Have you changed it to run under another account, and if so, is the config file readable by that account?

yes i am trying to use a specific user account.
after reading your post I chown user all shoutcast files and try again, same results … cant find config file

i then try putting shoutcast in /root/bin and running command without change of user and get same results. unable to locate config file

???

Does the program rely on any environment variables like $HOME to find the config file? You may have to set those explicitly. Is there an option to specify the config file instead of letting it default, e.g. say something like -c /path/to/config/file.conf?

OMG! I feel so dumb. I remembered reading that you can make multiple config files and to launch server you would just use

./sc_serv file.conf

so i tried

startproc -u user /path/to/sc_serv sc_serv.conf and it started right up

So now if i want this to happen at each startup i have to add a script doing this into runlevel3?

i dont get it. I ran the command just like i said again after bringing down the server

1st time i ran it and hit enter it looked like nothing happened but when i checked processes it was listed with correct user name.

Now when i do it it comes up and says cant find config file again, but 2 min ago it worked… Now its just toying with me

Yes, write a script to go into /etc/init.d, using /etc/init.d/skeleton as an example. Pay attention to the extra info at the top of the script, they are needed to arrange startup at the correct sequence point. For sure your server needs the network to be up first so $network would be one of the dependencies. Then install it with

insserv /etc/init.d/shoutcast

You might want to look at the -c option to change to a specified directory before starting the service. Also remember that services started by startproc leave behind a pid file which is meant to prevent a second instance from starting by mistake but also prevent startup if you have left a pid file lying around after the service has stopped. Have a look at killproc, this is meant to go with startproc in init scripts to stop services.

RESOLVED:

Just wanted to post for in case anyone stumbles across looking for a way to start shoutcast at system startup.


#!/bin/sh
# description: SHOUTcast streaming MP3 radio station server
# chkconfig: 2345 99 00

case "$1" in
'start')
        startproc -u username /path/to/shoutcast /path/to/config
        touch /var/lock/subsys/shoutcast
        ;;
'stop')
        rm -f /var/lock/subsys/shoutcast
        ;;
*)
        echo "Usage: $0 { start | stop }"
        ;;
esac
exit 0


just name this shoutcast and place this in /etc/init.d and chmod 755 then run

 chkconfig -a shoutcast 

and your done.

This will start shoutcast using whatever username you specified. Please not that it is important to use the full path to sc_serv and sc_serv.conf in the script

example would be startproc -u shoutcast /home/shoutcast/bin/sc_serv /home/shoutcast/bin/sc_serv.conf

Even if the conf file is in the same directory as sc_serv, you still have to declare the whole path otherwise shoutcast will not find it.

Thanks to all that helped me get this far

Realised that the script posted above does do what i want it to do but i then noticed shoutcast is not hidden. When i try to log directly into computer shoutcast is in the way.

fixed this by using



#!/bin/sh
# description: SHOUTcast streaming MP3 radio station server
# chkconfig: 2345 99 00

case "$1" in
'start')
        startproc -u username /path/to/sc_serv /path/to/sc_serv.conf > /dev/null 2>&1 &
        touch /var/lock/subsys/shoutcast
        ;;
'stop')
        rm -f /var/lock/subsys/shoutcast
        ;;
*)
        echo "Usage: $0 { start | stop }"
        ;;
esac
exit 0

instead