#!/bin/sh ######################################################################################### # start, stop, restart, monitor multiple shoutcast servers, script default are 2 # # fragman march 2004 # # license is gpl. # # shoutcast is a trademark of nullsoft, inc. # ######################################################################################### # How to use: # This is configured for two Servers. If you want to run more Servers, simply add one more set of variables # (e.g. SERVER3, SERVERBIN3... and copy the start|stop|restart|status routines. dont forget to change the # values in the new entrys. # Configurable Variables ################################################ SERVER1="$HOME/shoutcast/server1" # Workdir 1.Server SERVER2="$HOME/shoutcast/server2" # Workdir 2.Server SERVERBIN1="sc_serv_1" # Name of the Server1-executable, default: sc_serv SERVERBIN2="sc_serv_2" # Name of the Server2-executable, default: sc_serv CONF1="sc_serv_1.conf" # Name of the Server1-Config, default: sc_serv.conf CONF2="sc_serv_2.conf" # Name of the Server2-Config, default: sc_serv.conf COMMENT1="für 192 kbps" # Comment Server1, will be used in Status-Messages to identify the Server COMMENT2="für 96 kbps" # Comment Server2, will be used in Status-Messages to identify the Server # Non-Configurable Parameters ############################################# PIDFILE1="$SERVERBIN1.pid" PIDFILE2="$SERVERBIN2.pid" PORTBASE1=`grep PortBase= $SERVER1/$CONF1 | awk -F= '{print $2}'` PORTBASE2=`grep PortBase= $SERVER2/$CONF2 | awk -F= '{print $2}'` PID_1="$SERVER1/$PIDFILE1" PID_2="$SERVER2/$PIDFILE2" # Start first Server ##################################################### if [ "$1" = "start" ]; then if [ -r $PID_1 ]; then echo "" echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 is already running !" else cd $SERVER1 ./$SERVERBIN1 $CONF1 & ps awx | grep $SERVERBIN1 | grep -v grep | awk '{print $1}' > $SERVER1/$PIDFILE1 echo "" echo ========================================================= echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 started !" echo ========================================================= echo "" fi # Start second Server ##################################################### if [ -r $PID_2 ]; then echo "Shoutcast-Server $COMMENT2 on Port $PORTBASE2 already running !" echo "" else cd $SERVER2 ./$SERVERBIN2 $CONF2 & ps awx | grep $SERVERBIN2 | grep -v grep | awk '{print $1}' > $SERVER2/$PIDFILE2 echo "" echo ========================================================= echo "Shoutcast-Server $COMMENT2 on Port $PORTBASE2 started !" echo ========================================================= echo "" fi # Stop first Server ######################################################## elif [ "$1" = "stop" ]; then if [ ! -r $PID_1 ]; then echo "" echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 not running !" else kill -9 `cat $PID_1` rm $SERVER1/$PIDFILE1 echo "" echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 stopped !" fi # Stop second Server ######################################################## if [ ! -r $PID_2 ]; then echo "Shoutcast-Server $COMMENT2 on Port $PORTBASE2 not running !" echo "" else kill -9 `cat $PID_2` rm $SERVER2/$PIDFILE2 echo "Shoutcast-Server $COMMENT2 on Port $PORTBASE2 stopped !" echo "" fi # Restart first Server ####################################################### elif [ "$1" = "restart" ]; then if [ ! -r $PID_1 ]; then echo "" echo "Shoutcast-Server für $COMMENT1 on Port $PORTBASE1 not running !" else kill -1 `cat $PID_1` echo "" echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 restarting !" fi # Restart second Server ####################################################### if [ ! -r $PID_2 ]; then echo "Shoutcast-Server $COMMENT2 on Port $PORTBASE2 not running !" echo "" else kill -1 `cat $PID_2` echo "Shoutcast-Server $COMMENT2 on Port $PORTBASE2 restarting !" echo "" fi # Status first Server ########################################################## elif [ "$1" = "status" ]; then if [ "`ps a |grep $SERVERBIN1 |grep -v grep |awk '{print $1}'`" != "" ]; then echo "" echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 seems to be up and running." echo "Process-ID found is `ps a |grep $SERVERBIN1 |grep -v grep |awk '{print $1}'`" else echo "" echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 seems not to be running." echo "No Process found." fi # Status second Server ######################################################### if [ "`ps a |grep $SERVERBIN2 |grep -v grep |awk '{print $1}'`" != "" ]; then echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 seems to be up and running." echo "Process-ID found is `ps a |grep $SERVERBIN1 |grep -v grep |awk '{print $1}'`" echo "" else echo "Shoutcast-Server $COMMENT1 on Port $PORTBASE1 seems not to be running." echo "No Process found." echo "" fi # Print Syntax ################################################################ else echo "" echo "Usage: shout start|stop|restart|status" echo "" fi