I have a SHOUTcast server running on Ubuntu. The server process is working fine, but I cannot get the daemon script to function properly. After a few tutorials that I found, I came up with the following:
#!/bin/sh CONFIG="/home/apps/shout32/sc_plex.conf" DAEMON="/home/apps/shout32/sc_serv" case "$1" in start) echo "Starting SC..." $DAEMON $CONFIG > /dev/null 2>&1 & ;; stop) echo "Stopping SC..." kill -9 `ps -C sc_serv -o pid --no-headers` ;; restart) echo "Rebooting SC..." kill -9 `ps -C sc_serv -o pid --no-headers` $DAEMON $CONFIG > /dev/null 2>&1 & ;; *) echo "usage: service sc32d {start | stop | restart}" exit 1 ;; esac
This, however, does not work. I did not know what that meant, so I started breaking it up into lines. If I remove the / dev / null element, which, as I understand it now, makes the program run silently in the background, I get this message and the program closes:
root@streams3 :/etc/init.d
I was still studying what exactly / dev / null did, and why, so I wanted to run these commands with all the / dev / null materials that I did, and that where I got some kind of error code:
root@streams3 :/etc/init.d
Unfortunately, from the small amount of research that I have done, it sounds like this: "Exit 225" looks like an error code for all codes, which is outside the valid code range.
An interesting part of the whole problem is this: when I go to the / home / apps / shout32 / folder and run the commands there without a full path ... it works damn well:
root@streams3 :/home/apps/shout32
So, something went wrong because the script file is in /etc/init.d/, and not in the folder where the application is located? As far as I know, I followed every step in the published tutorials on setting up SHOUTcast in Ubuntu, and then in creating the daemon ... I donโt think I missed something. I have a feeling that the solution either looks at me directly in the face, or some kind of unclear resolution, which is slightly above my head.
But any help would be greatly appreciated!
So, based on the answer below, I added cd / home / apps / shout32 / to the START command in my script, also added pwd and ls ... to see if we can eliminate the fact that the script could not find the / directory log /.
So now my script is:
CONFIG="/home/apps/shout32/sc_plex.conf" DAEMON="/home/apps/shout32/sc_serv" cd /home/apps/shout32/ case "$1" in start) echo "Starting SC..." cd /home/apps/shout32/ pwd ls $DAEMON $CONFIG & ;; stop) echo "Stopping SC..." kill -9 `ps -C sc_serv -o pid --no-headers` ;; restart) echo "Rebooting SC..." kill -9 `ps -C sc_serv -o pid --no-headers` $DAEMON $CONFIG & ;; *) echo "usage: service sc32d {start | stop | restart}" exit 1 ;; esac
I got it:
admin@streams3 :/etc/init.d$ service sc32d start Starting SC... /home/apps/shout32 changes.txt readme.txt sc_serv_debug.conf config_builder sc_plex.conf sc_serv_public.conf control sc_serv sc_serv_relay.conf docs sc_serv2_linux_07_31_2011.tar sc_serv_simple.conf logs sc_serv_basic.conf tos.txt admin@streams3 :/etc/init.d$ 2013-06-05 17:52:08 E msg:<***> logger could not open file logs/sc_serv.log 2013-06-05 17:52:08 I msg:<***> Logger shutdown