Linux SRCDS server
From Www.FreeNerd.net
This guide is provided for informational purposes only. If you choose to use this guide for anything more than information, you do so "At Your Own Risk".
Linux Distro
- I used CentOS 5 for this guide. Any Red Hat based version of Linux should work. Other distributions may work as well with minimal change needed.
Add a new user
- For security reasons, you don't want to run SRCDS as root. The first step is creating a new user to run the SRCDS service.
- replace <newuser> with the username you want to run the SRCDS service under
useradd -d /home/<newuser> -s /bin/bash <newuser>
- Now lets set the password for the new user account just created.
passwd <newuser>
- Let's login as the new user. Logout as root and login with the newly created credentials.
- From this point forward if the guide requests running any command as root, you'll need to elevate to the root user account. To do this type in the command below and when prompted enter in the servers root password
su -
- After you have completed all tasks that require elevated root access, type exit to return to your user level access.
exit
Download the SRCDS
- I recommend that the new user account is only used to run the game server. If you are going to use this new account for more than running a dedicated server consider placing the source game files in a sub directory to prevent confusion in the users home directory. (i.e. /home/<newuser>/srcds)
- To avoid permission issues run the SRCDS server from the home directory of your new user. Let's change to the home directory now.
cd /home/<newuser>
- You need to get the SRCDS installation files onto your server
wget http://storefront.steampowered.com/download/hldsupdatetool.bin
- Make the hldsupdatetool executable
chmod u+x hldsupdatetool.bin
Run the hldsupatetool
- You'll need to install ncompress to run the hldsupdatetool. Execute the following command with root priveleges.
- Don't forget to type exit to drop back to your user level access when the install is complete
yum -y install ncompress
- The hldsupdatetool.bin should do most of the install work for you, we just need to execute it.
- With Ubuntu you may need a the file lib32gcc1. "sudo apt-get install lib32gcc1" if you cannot run the ./hldsupdatetool
./hldsupdatetool.bin
- Type "yes" to accept agreement
yes
- Run the steam installer for the first time, this will update the program.
./steam
Install the game
- This process will take a little while
- The new user you created from above should have a /home/<newuser> directory created, place the game files there with the command below.
./steam -command update -game "desired game" -dir /home/<newuser>
- Here is a list of games for SRCDS
** 'game' options for Source DS Install:
"Counter-Strike Source"
"ageofchivalry"
"diprip"
"dods"
"garrysmod"
"hl2mp"
"insurgency"
"l4d_full"
"left4dead"
"synergy"
"tf"
"zps"
** 'game' options for HL1 DS Install:
"cstrike"
"cstrike_beta"
"czero"
"dmc"
"dod"
"gearbox"
"ricochet"
"tfc"
"valve"
** 'game' options for Third-Party game servers:
"ageofchivalry"
"darkmessiah"
"diprip"
"garrysmod"
"insurgency"
"marenostrum"
"redorchestra"
"ship"
"sin"
"synergy"
"tshb"
"zps"
Setup srcds_run as a service
- You will need to install screen.i386 and create a file in the /etc/init.d directory. Both of these require root level access
yum -y install screen.i386 (or screen.x86_64 for 64 bit)
- SRCDS can be run a few different ways but I think running it as a service is the best option.
cd /etc/init.d/
- You'll need to use an editor to create the srcds service file
vi srcds
- paste the following data into the new SRCDS file, change <newuser> to the user created above, double check all file paths, and to match the IP to the IP of your server.
#replace <newuser> with the user you created above
SRCDS_USER="<newuser>"
#Do not change this path
PATH=/bin:/usr/bin:/sbin:/usr/sbin
#The path to the game you want to host. example = /home/newuser/dod
DIR=/home/<newuser>/<gamedir>
DAEMON=$DIR/srcds_run
#Change all PARAMS to your needs.
# I have removed the -ip <xxx.xxx.xxx.xxx> portion from this command as the last update to L4D removed the need for it
# If you have issues with your game put the -ip string back into the PARAMS line below
PARAMS="-game <game> ticrate 66 -pingboost 3 -secure" #These options can vary a bit from game to game, google is your friend here.
NAME=SRCDS
DESC="source dedicated server"
case "$1" in
start)
echo "Starting $DESC: $NAME"
if [ -e $DIR ];
then
cd $DIR
su $SRCDS_USER -l -c "screen -d -m -S $NAME $DAEMON $PARAMS"
screen -d -m -S $NAME $DAEMON $PARAMS
else echo "No such directory: $DIR!"
fi
;;
stop)
if screen -ls |grep $NAME
then
echo -n "Stopping $DESC: $NAME"
kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
echo " ... done."
else
echo "Coulnd't find a running $DESC"
fi
;;
restart)
if screen -ls |grep $NAME
then
echo -n "Stopping $DESC: $NAME"
kill `screen -ls |grep $NAME |awk -F . '{print $1}'|awk '{print $1}'`
echo " ... done."
else
echo "Couldn't find a running $DESC"
fi
echo -n "Starting $DESC: $NAME"
cd $DIR
screen -d -m -S $NAME $DAEMON $PARAMS
echo " ... done."
;;
status)
# Check whether there's a "srcds" process
# if "checkproc" is installed, you can use this:
# checkproc $DIR/srcds_run && echo "DODS-Server RUNNING" || echo "DODS-Server NOT RUNNING"
# (thx to commander)
ps aux | grep -v grep | grep hlds_r > /dev/null
CHECK=$?
[ $CHECK -eq 0 ] && echo "SRCDS is UP" || echo "SRCDS is DOWN"
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
- Save this file and test that the service can be started
service srcds restart
- You should see the following output from this command
Couldn't find a running source dedicated server Starting source dedicated server: SRCDS ... done.
- This confirms the service was not running, and is now started
- We no longer need root access so lets exit back to our user
exit
Setup the server.cfg
- To customize your server you will need to create a server.cfg file. You will want to spend some time reading on the game you are running, and what server.cfg options are available to you. I have a very basic server.cfg example here
//My server config file //Server Settings hostname My Game Servers Name rcon_password passwordgoeshere sv_alltalk 1 //Client Settings cl_updaterate 100 cl_cmdrate 100 rate 30000
- If you cannot see your new server in the servers list or connect to it by IP address from Steam, you will need to adjust your firewall rules to allow it to connect to the Steam network. The example below was taken from a CentOS 5.2 IPTABLES file, adjust to match your distributions IPTABLES file if needed.
- Add these lines to your /etc/sysconfing/IPTABLES file
- These lines must be added above the "reject all" rule or they will not work
-A RH-Firewall-1-INPUT -m state --state NEW,ESTABLISHED,RELATED -m udp -p udp --dport 27000:27015 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp --dport 27020:27050 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW,ESTABLISHED,RELATED -m udp -p udp --dport 1200 -j ACCEPT
For easy server admin continue on to the SRCDS - Mani Admin Mod Setup.
