SRCDS Steam group


Nice bash script for server control
#16
If you guys are having issues, try creating the file and pasting the syntax using nano from the console directly. DO NOT upload this via FTP as something must be changed to prevent it from running right. Just create it via nano or whatever your comfortable with. This seemed to fix every issue I have had with this script. Just make sure you add the code to use a startup map.
Reply
#17
ok here is how to get it to work. Its very simple to do, just follow what I say, it will be working.

You can try this. Download the file to your linux server. when you are where you can see the file in linux, type ....

mv srcds_ctl.txt srcds
on " srcds " use a file name of whatever you want.

or you can do this to get it on your liunx server, via windows...

I would say do this. goto http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe " download that to your desktop and run it, and connect to the IP of the linux server then press open at the bottom. This may not work because SSh is not running. You will have to google to find how to turn it on for your linux diro.

first you have to make a file, name it what you want.
I named mine " srcds " type vi like so ...

vi srcds

when your in that, press " I or A " to insert
copy and paste from this post, from windows.

then add ....


#!/bin/sh
# half-Life Source Dedicated Server Control Script
# Adaptation of Half-Life Dedicated Controle Sctipt
#
# srcds_ctl
# Author: Rogier "GrefTek" den Dulk <rogier.dendulk@xs4all.nl>
# Date: Feb 5th 2005
#
# This script is free for distribution and/or modification.
# Any improvements may be submitted to the address above.
#

# Source Dedicated Server Configuration Variables ############################
#
# IP address the server should be bound to
#
SERVER_ADDRESS=

# Port number the server should be bound to
#
SERVER_PORT=

# Starting Map
#
STARTING_MAP=

# Type of game
#
GAME=

#Type of game for Steam Update
#
GAME_UPDATE=""

# Maximum amount of players
#
MAXPLAYERS=

# Your steam account (for automatic updates)
#
STEAM_USER=

# The password for your steam account
#
STEAM_PASS=

# The heapsize used by the dedicated server
#
HEAPSIZE=128000

# Environmental Variables ####################################################
#
# Location of the screen binary
#
SCREEN=/usr/bin/screen

# Name of the screen session
#
SCREEN_NAME=srcds

# Location of the Half-Life Source Dedicated Server
#
SERVER_HOME=/home/hlds

# Location of the Steam update utility
#
STEAM_HOME=$SERVER_HOME

# Do not edit beyond this point unless you know what you are doing ###########
#
ACTION=$1
die(){
echo "$2"
exit $1
}

isrunning(){
return `ps -ef | grep -v grep | grep SCREEN | grep -c " $SCREEN_NAME "`
}
if [ "x$ACTION" == "x" ]; then die 1 "usage: $0 <start|stop|restart|console|status|update>"; fi

case "$ACTION" in
start|up)
echo -en "Starting server: "
isrunning; UP=$?
if [ $UP -eq 1 ]; then die 1 "Server is already running..."; fi
cd $SERVER_HOME &>/dev/null || die 1 "Cannot find server directory..."
$SCREEN -A -m -d -S $SCREEN_NAME ./srcds_run -console -autoupdate\
-game $GAME +map $STARTING_MAP +maxplayers $MAXPLAYERS -heapsize $HEAPSIZE \
+ip $SERVER_ADDRESS +port $SERVER_PORT \
#-steamuser $STEAM_USER -steampass $STEAM_PASS || die 1 "FAILED"
echo "OK"
;;
stop|down)
echo -en "Stopping server: "
isrunning; UP=$?
if [ $UP -eq 0 ]; then die 7 "Server isn't running..."; fi
$SCREEN -r $SCREEN_NAME -X quit || die 1 "FAILED"
echo "OK"
;;
restart)
$0 stop
sleep 1
$0 start
;;
console)
echo -en "Connecting... "
isrunning; UP=$?
if [ $UP -eq 0 ]; then die 1 "Server isn't running..."; fi
$SCREEN -r $SCREEN_NAME || die 1 "FAILED"
;;
status)
isrunning; UP=$?
if [ $UP -eq 0 ]; then echo "Server is DOWN"; exit 3
else echo "Server is UP"; exit 0
fi
;;
update)
isrunning; UP=$?
if [ $UP -eq 1 ]; then $0 stop; fi
cd $STEAM_HOME
$STEAM_HOME/steam -command update -game "$GAME_UPDATE" -dir $SERVER_HOME -username $STEAM_USER -password $STEAM_PASS -remember_password
if [ $UP -eq 1 ]; then $0 start; fi
;;
*)
die 0 "usage: $0 <start|stop|restart|console|status|update>"
esac
exit 0



-------------------------------------------------------------------------
check the very top of the page from when you pasted it into putty, cuz the top of the code may have got messed up. Check around " #!/bin/sh " at the top of the page in putty. just retype the code in.

once you added that, fill out what you want in the top part of the page I.E. Server IP, Starting Map, etc .... and press " Esc " and then type ...

:qw!

that will quit and save it.Once back in the command line, Now you must make the file execute.

type...

chmod +x srcds

now to get it working, it is ...

./srcds start | ./srcds stop | ./srcds restart | ./srcds console | ./srcds status | ./srcds update

Those are the commands for it.
let me know if you have any kind of problems.

-----------------------------------------------------------------------------
I was just brain storming and I know how to host 2 servers at one time.

do everything I just said above 2 times, make to files I.E. " srcds & srcds2 " fill both of them out with the specs you want for both servers. Then make a new file, name it what you want, I called mine " server " type ...

vi server

when your in that, press " I or A " again to instert, now type

./srcds start && ./srcds2 start

now type ...

:wq!

to save it and quit

When your back in the command line, type
chmod +x server

now your done. all you would have to do is type

./server

to start both servers at one time. There is a command so that, when you type ./server, one server will wait till its up and running, then it would start the other server. I will update the post when I find the command for it.

Thanks,
- Blackhawk
Reply
#18
Thanks Blackhawk!

That fixed it. Tried first with the "Kate" editor in SuSE KDE. Didnt work. The graphical editor was the thing that messed it up!
Works great. Will test! Thanks!
(BTW: Couldnt reply to ur e-mail u sent me....)

TT
Reply
#19
ok, I am having some probs!!!

: bad interpreter: No such file or directory

#!/bin/sh
#
# Half-Life Source Dedicated Server Control Script
# Adaptation of Half-Life Dedicated Controle Sctipt
#
# srcds_ctl
# Author: Rogier "GrefTek" den Dulk <rogier.dendulk@xs4all.nl>
# Date: Feb 5th 2005
#
# This script is free for distribution and/or modification.
# Any improvements may be submitted to the address above.
#

# Source Dedicated Server Configuration Variables ############################
#
# IP address the server should be bound to
#
SERVER_ADDRESS=*************

# Port number the server should be bound to
#
SERVER_PORT=27016

# Type of game
#
GAME=cstrike

#Type of game for Steam Update
#
GAME_UPDATE="Counter-Strike Source"

# Maximum amount of players
#
MAXPLAYERS=16

# Your steam account (for automatic updates)
#
STEAM_USER=******

# The password for your steam account
#
STEAM_PASS=******

# The heapsize used by the dedicated server
#
HEAPSIZE=256000

# Environmental Variables ####################################################
#
# Location of the screen binary
#
SCREEN=/usr/bin/screen

# Name of the screen session
#
SCREEN_NAME=Private_Server

# Location of the Half-Life Source Dedicated Server
#
SERVER_HOME=/home/css/CSS_Server/

# Location of the Steam update utility
#
STEAM_HOME=/home/css/css

# Do not edit beyond this point unless you know what you are doing ###########
#
ACTION=$1
die(){
echo "$2"
exit $1
}

isrunning(){
return `ps -ef | grep -v grep | grep SCREEN | grep -c " $SCREEN_NAME "`
}
if [ "x$ACTION" == "x" ]; then die 1 "usage: $0 <start|stop|restart|console|status|update>"; fi

case "$ACTION" in
start|up)
echo -en "Starting server: "
isrunning; UP=$?
if [ $UP -eq 1 ]; then die 1 "Server is already running..."; fi
cd $SERVER_HOME &>/dev/null || die 1 "Cannot find server directory..."
$SCREEN -A -m -d -S $SCREEN_NAME ./srcds_run -autoupdate -console -secure +map cs_italy -tickrate 66 -exec server2.cfg\
-game $GAME +maxplayers $MAXPLAYERS -heapsize $HEAPSIZE \
-ip $SERVER_ADDRESS -port $SERVER_PORT \
-steamuser $STEAM_USER -steampass $STEAM_PASS || die 1 "FAILED"
echo "OK"
;;
stop|down)
echo -en "Stopping server: "
isrunning; UP=$?
if [ $UP -eq 0 ]; then die 7 "Server isn't running..."; fi
$SCREEN -r $SCREEN_NAME -X quit || die 1 "FAILED"
echo "OK"
;;
restart)
$0 stop
sleep 1
$0 start
;;
console)
echo -en "Connecting... "
isrunning; UP=$?
if [ $UP -eq 0 ]; then die 1 "Server isn't running..."; fi
$SCREEN -r $SCREEN_NAME || die 1 "FAILED"
;;
status)
isrunning; UP=$?
if [ $UP -eq 0 ]; then echo "Server is DOWN"; exit 3
else echo "Server is UP"; exit 0
fi
;;
update)
isrunning; UP=$?
if [ $UP -eq 1 ]; then $0 stop; fi
cd $STEAM_HOME
$STEAM_HOME/steam -command update -game "$GAME_UPDATE" -dir $SERVER_HOME -username $STEAM_USER -password $STEAM_PASS -remember_password
if [ $UP -eq 1 ]; then $0 start; fi
;;
*)
die 0 "usage: $0 <start|stop|restart|console|status|update>"
esac
exit 0
Reply
#20
fixed it
Reply
#21
it the script uses screen and you dont have it type "apt-get install screen" into the console if you have debian or "emerge screen" if yo have gentoo, for other distros i dont know, also it might be nice to add a setting for controlling the "nice" value "priority"

i like to run my server "nice -n -10"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)