SHOUTcast script daemon is not working properly

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# service sc32d start Starting SC... root@streams3 :/etc/init.d# 2013-05-21 14:41:50 E msg:<***> logger could not open file logs/sc_serv.log 2013-05-21 14:41:50 I msg:<***> Logger shutdown root@streams3 :/etc/init.d# root@streams3 :/etc/init.d# ps -C sc_serv PID TTY TIME CMD 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# /home/apps/shout32/sc_serv /home/apps/shout32/sc_plex.conf > /dev/null 2>&1 & [2] 2261 root@streams3 :/etc/init.d# [2]- Exit 255 /home/apps/shout32/sc_serv /home/apps/shout32/sc_plex.conf > /dev/null 2>&1 root@streams3 :/etc/init.d# ps -C sc_serv PID TTY TIME CMD 

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# ./sc_serv sc_plex.conf > /dev/null 2>&1 & [2] 2245 root@streams3 :/home/apps/shout32# root@streams3 :/home/apps/shout32# ps -C sc_serv PID TTY TIME CMD 2245 pts/0 00:00:00 sc_serv 

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 
+6
source share
1 answer

your second snippet contains logger could not open file logs/sc_serv.log . Therefore, he tries to write the sc_serv.log file, which he either expects or wants to create in the logs directory, which he expects in the current directory . This also explains that it works when you first connect to / home / apps / shout 32 /. I think there is a file /home/apps/shout32/logs/sc_serv.log .

Can you customize the location of this file? can't you just add some cd ... at the beginning of the script?

+2
source

Source: https://habr.com/ru/post/945518/


All Articles