PDA

View Full Version : Complex Auto-Startup Script


JustGags
06-24-2004, 09:03 AM
I need a script that will do the following:

-Start Multiple Servers at System Startup
-Give each Server it's own Screen w/ Screen Name
-Run Everything as Another User

Is thre anywhere that you can direct me to that meets these qualifications? Most of the scripts that I have seen right now either do not work or are meant for one server.

LIGHTFRAG
06-24-2004, 09:38 AM
Originally posted by JustGags
I need a script that will do the following:

-Start Multiple Servers at System Startup
-Give each Server it's own Screen w/ Screen Name
-Run Everything as Another User

Is thre anywhere that you can direct me to that meets these qualifications? Most of the scripts that I have seen right now either do not work or are meant for one server.
Not probably one script to start some servers under various users.
Each server should have script of start

JustGags
06-24-2004, 09:51 AM
Well, could you point me to a script that acheives the last two requirements and I'll just duplicate it myself?

LIGHTFRAG
06-24-2004, 10:36 AM
links on SCREEN :
screen_HL
screen_TFC
screen_CS

in start file:

For CS
screen_CS -A -dmS csds16 ./hlds_run + game cstrike and etc ... ...
For HL
screen_HL -A -dmS hlds16 ./hlds_run - and etc ... ...
For TFC
screen_HL -A -dmS hltfc16 ./hlds_run and etc ...
............................
:
++++++++++++++++++++++++++++++++++++++++++++++++++

#!/bin/sh
# description: Restart cstrike and logs proc
# Source function library.
. /etc/rc.d/init.d/functions
#-----------------------------------------------------------
# hls is var - name of script which run proc -
# SCREEN_HLDS
#
hls=./start_cs.sh
#
# exit if file not exist
test -x $hls || exit 0

#-----------------------------------------------------------
# log is var - name of script which run proce -
#
# SCREEN_LOG
#
log=./start_log.sh
#
# exit if file not exist
test -x $log || exit 0

# Set run_hl to 1 to start HL 0 to disable it.
run_hl=1
case "$1" in
stop)
if [ $run_hl = 1 ]
then
#-----------------------------------------------------------
# shutdown processes
#
echo -n " Shutting down 'SCREEN_LOG' proc --------->"
killproc SCREEN_LOG
echo
rm -f /var/lock/subsys/SCREEN_LOG
rm -f /var/log/cs/*
echo -n " Shutting down 'SCREEN_HLDS' proc -------->"
killproc SCREEN_HLDS
echo
rm -f /var/lock/subsys/SCREEN_HLDS
fi
;;
start)
if [ $run_hl = 1 ]
then
#-----------------------------------------------------------
# Start script which run proces
#
echo -n " Starting 'SCREEN_HLDS' procproces ------->"
daemon $hls
echo
touch /var/lock/subsys/SCREEN_HLDS

echo -n " Starting 'SCREEN_LOG' proc -------------->"
daemon $log
echo
touch /var/lock/subsys/SCREEN_LOG
echo ""
echo ""
echo " For connect to proc 'SCREEN_HLDS' run ./connect_cs_serv"
echo " -------------------------------------------------------"
echo ""
echo ""
echo ""
echo " For connect to proc 'SCREEN_LOG' run ./connect_cs_log"
echo " -----------------------------------------------------"
echo ""
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/cs_xxd {start|stop|restart}"
exit 1
esac
exit 0
++++++++++++++++++++++++++++++++++++++++++++++++++


Startup file
./start_cs.sh:
./screen_HLDS -A -m -d -S cs_serv ./hlds_run_test1 \
-game cstrike \: /etc/init.d/cs_xxd {start|stop|restart}"
-nomaster \
-port 27015 \
+sv_lan 1 \
+rcon_password 2002 \2~^M
+maxplayers 13 \
+map cs_italy

./start_log.sh:
./screen_LOG -A -m -d -S cs_log /mnt/hda1/games/hlds_l/statistiks/cslog.pl


its script for start 1 server and stats for him

if you want to start from non-root use
su - name user -c name script

JustGags
06-24-2004, 11:02 AM
I'm really confused. What do you mean by "links on screen"?

LIGHTFRAG
06-24-2004, 11:09 AM
Originally posted by JustGags
I'm really confused. What do you mean by "links on screen"?
sorry for my English (translator is bad)- its startup SCREENS

JustGags
06-26-2004, 09:08 AM
What would be wrong with?

----------------------------------------

FILE: /etc/rc.d/rc.local

/usr/local/bin/starthlds.sh

-----------------------------------------

FILE: /usr/local/bin/starthlds.sh

#!/bin/sh

cd /usr/local/gameservers/server1
su serverhost -c "screen -A -dmS server1 ./hlds_run...."


cd /usr/local/gameservers/server2
su serverhost -c "screen -A -dmS server2 ./hlds_run...."

-----------------------------------------

For some reason, after I reboot the system, the servers do not start until I SSH in as root. I don't even run any commands, they just start at the exact time that I SSH in.

LIGHTFRAG
06-26-2004, 11:57 AM
Originally posted by JustGags
What would be wrong with?

----------------------------------------

FILE: /etc/rc.d/rc.local

/usr/local/bin/starthlds.sh

-----------------------------------------

FILE: /usr/local/bin/starthlds.sh

#!bin/sh

cd /usr/local/gameservers/server1
su serverhost -c "screen -A -dmS server1 ./hlds_run...."


cd /usr/local/gameservers/server2
su serverhost -c "screen -A -dmS server2 ./hlds_run...."

-----------------------------------------

For some reason, after I reboot the system, the servers do not start until I SSH in as root. I don't even run any commands, they just start at the exact time that I SSH in.


You have user "serverhost" ?

See this (your) script make su to serverhost

In /etc/rc.d/ server start from user root.
You must make su username -c in this script, that the server was started from the user csadmin-username and all files in folder hlds_l must be chown csadmin-username

For example file start_cs.sh for user games:

#!/bin/sh
/bin/su - games -c "/usr/bin/screen -AmdS cs15 /var/games/cs_start.sh"

and file cs_start.sh:

#!/bin/sh
cd /usr/games/hlds_l
./hlds_run -game cstrike -pingboost 2 +map de_chateau -restart +maxplayers 20

Sorry if I don't speak correctly in English

counternube
06-27-2004, 06:48 PM
this will do most of what you want:

http://www.counter-strike.de/hlinside/server/hlds_start

You could modify it such that it would take the various game specific parameters such as name, port, mapcycle, etc... as command line attributes, but thats kind of pointless. Just replicate the script and modify for each server instance.

LIGHTFRAG
06-27-2004, 09:23 PM
Originally posted by counternube
this will do most of what you want:

http://www.counter-strike.de/hlinside/server/hlds_start

You could modify it such that it would take the various game specific parameters such as name, port, mapcycle, etc... as command line attributes, but thats kind of pointless. Just replicate the script and modify for each server instance.
o yes!
Realy good script