SRCDS Steam group


Launch Multiple Servers via Shell Script
#1
Hi there,

I would like to be able to launch multiple servers using a shell script file. Here is what I came up with:

Code:
#!/bin/sh
echo "Starting TF2 Server"
sleep 1
cd tf2/orangebox
screen -A -m -d -S tf2-server ./srcds_run -console -game tf +ip 119.63.204.26 +maxplayers 14 +map ctf_2fort
cd ../..
echo "Starting CSS Server"
cd css
screen -A -m -d -S css-server ./srcds_run -console -game cstrike +ip 119.63.204.26 +maxplayers 32 +map de_dust2
cd ../..
echo "Starting DoDS Server"
cd dods/orangebox
screen -A -m -d -S dods-server ./srcds_run -console -game dod +ip 119.63.204.26 +port 27016 +maxplayers 16 +map dod_flash -tickrate 66
cd ../..
echo "Starting RO Server"
cd ro/system
screen -A -m -d -S ro-server ./ucc-bin server RO-Konigsplatz.rom?game=ROEngine.ROTeamGame?MinPlayers=10? -multihome=119.63.204.26 -log=ServerLog.log --nohomedir &
cd ../..

When I try and launch, it says that it cannot find the directories listed.

Any help is greatly appreciated.

Signing off,

Swatmajor1
Reply
#2
You're missing the full path for your first cd...and your `cd ../..` is incorrect for css...and I don't think dods runs from the orangebox folder.

Personally I'd just use full paths instead of changing directories over and over, like so: These might not be correct paths but this is what it should look like (note the preceding slash before the paths). If you do `ls /` and you don't see all your game folders then they're installed in a subdirectory...in which case you just add those after the first /

Code:
#!/bin/sh

echo "Starting TF2 Server"
screen -A -m -d -S tf2-server /tf2/orangebox/srcds_run -console -game tf +ip 119.63.204.26 +maxplayers 14 +map ctf_2fort

sleep 1

echo "Starting CSS Server"
screen -A -m -d -S css-server /css/srcds_run -console -game cstrike +ip 119.63.204.26 +maxplayers 32 +map de_dust2

sleep 1

echo "Starting DoDS Server"
screen -A -m -d -S dods-server /dods/srcds_run -console -game dod +ip 119.63.204.26 +port 27016 +maxplayers 16 +map dod_flash -tickrate 66

sleep 1

echo "Starting RO Server"
screen -A -m -d -S ro-server /ro/system/ucc-bin server RO-Konigsplatz.rom?game=ROEngine.ROTeamGame?MinPlayers=10? -multihome=119.63.204.26 -log=ServerLog.log --nohomedir &
Reply
#3
injate Wrote:You're missing the full path for your first cd...and your `cd ../..` is incorrect for css...and I don't think dods runs from the orangebox folder.

Personally I'd just use full paths instead of changing directories over and over, like so: These might not be correct paths but this is what it should look like (note the preceding slash before the paths). If you do `ls /` and you don't see all your game folders then they're installed in a subdirectory...in which case you just add those after the first /

Code:
#!/bin/sh

echo "Starting TF2 Server"
screen -A -m -d -S tf2-server /tf2/orangebox/srcds_run -console -game tf +ip 119.63.204.26 +maxplayers 14 +map ctf_2fort

sleep 1

echo "Starting CSS Server"
screen -A -m -d -S css-server /css/srcds_run -console -game cstrike +ip 119.63.204.26 +maxplayers 32 +map de_dust2

sleep 1

echo "Starting DoDS Server"
screen -A -m -d -S dods-server /dods/srcds_run -console -game dod +ip 119.63.204.26 +port 27016 +maxplayers 16 +map dod_flash -tickrate 66

sleep 1

echo "Starting RO Server"
screen -A -m -d -S ro-server /ro/system/ucc-bin server RO-Konigsplatz.rom?game=ROEngine.ROTeamGame?MinPlayers=10? -multihome=119.63.204.26 -log=ServerLog.log --nohomedir &

I thank you for your time, but this won't work, since, for one reason or another, you have to be in the directory that the executable file is in for it to run. And DoDS does run from the orangebox folder, just to inform.
Reply
#4
id recommend having one script for each instance
then another launching each of those at once.
Reply
#5
Just cd to the full path of each one before running the servers. That should work.
Reply
#6
CarVac Wrote:Just cd to the full path of each one before running the servers. That should work.

Tried that, but it comes up with this:

Code:
: No such file or directoryrangebox

And this repeats throughout the script.
Reply
#7
I'll just copy-paste the commands in bulk when I need to launch the servers.
Reply
#8
directoryrangebox?
where'd the O go?
Reply
#9
Do as Ryan suggested. Have one startup script for each instance, and then have another startup script to execute all those separate startup scripts.

For example I've got these scripts to start, stop and restart my css server:

start.sh:
Code:
#!/bin/sh
cd /home/user/csds/
screen -A -m -d -S csds ./srcds_run -game cstrike -console +maxplayers 32 +port 27015 +ip 1.2.3.4 -tickrate 66 +map de_dust2
screen -r csds

stop.sh:
Code:
#!/bin/bash
screen -dr csds -X quit

restart.sh:
Code:
#!/bin/bash
/home/user/csds/stop.sh
sleep 10
/home/user/csds/start.sh

Note that in the start.sh I've got parameter "-S csds" for screen. That sets name "csds" for the new screen session. You could have for example "-S dods" and "-S tf2" for your DoD:S and TF2 servers. Then correspondingly you would have to use "screen -dr dods -X quit" in your stop.sh script.

When you have those scripts set for each individual server, write separate script which launches the servers one by one. For example you could have:

Code:
#!/bin/bash
/home/user/csds/restart.sh
sleep 1
/home/user/tfds/restart.sh
sleep 1
/home/user/dods/restart.sh

The cool thing is that you don't need to worry about which dir you are in, because all the individual startup scripts have their own "cd" command as the first line. Also the script is easy to use because it doesn't matter whether the servers are already running or not. The script will first shut down and then restart any server that's running. That's why this is easy to use for example in cron to make the servers reboot at night.
Reply
#10
Ok, that did the job, Thanks guys and/or girls.
Reply
#11
Just one more thing, this will help a lot of people

Add this to the srcds_run script and you can execute it from anywhere without having to cd to it (its good for people who execute it via web php etc)

init() {
GAMEPATH=$0
cd "${GAMEPATH%/*}"
# Initialises the various variables
# Set up the defaults
GAME=""
DEBUG=""
RESTART="yes"
HL=./srcds_i486


see what ive added?

GAMEPATH=$0
cd "${GAMEPATH%/*}"




By the way, id like to say hi to everyone, 1st post here
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)