Half-Life Dedicated Server
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Contents |
[edit] About a Halflife Dedicated Server
A Halflife Dedicated Server is the foundation for many Steam-based games like Counter-Strike, Counter-Strike: Source, Halflife DM ...
This howto covers the creation of a secure "Counter-Strike: Source" game server.
[edit] Installation
This howto has been created with gentoo 2005.1
First, we need to install steam. There is an ebuild for this:
emerge halflife-steam
This was pretty easy ;) Now we can update steam to the newest version. Just type
cd /opt/halflife
./steam
Thats it. Now we need to install a game - the following command will install "CounterStrike: Source":
mkdir /opt/halflife/css
./steam -command update -game "Counter-Strike Source" -dir /opt/halflife/css
For Half-Life 2 Deathmatch use
mkdir /opt/halflife/hl2mp
./steam -command update -game hl2mp -dir /opt/halflife/hl2mp
You can see here that I don't use the --username and --password parameters as recommended by older ebuilds and other howtos. This is because Valve has removed the need for it. You can also specify another directory for the game - most howtos use the default steam directory, but I like a subdirectory. Now be patient...
It is possible to run the server as root, but this is a BIG security risk. The current ebuild configures steam to run as user "games". This is fine and we only need to fix some permissions later...
[edit] Configuration
Now we have a full installation of steam with "CounterStrike:Source" and we need to configure the server. Here is my - nearly default - configuration as an example. Place it in /opt/halflife/css/cstrike/cfg/server.cfg if you've chosen "css" as your game directory.
| File: server.cfg |
// server name hostname "Counter-Strike: Source" // rcon passsword rcon_password "" // rcon disabled // server cvars mp_friendlyfire 0 mp_footsteps 1 mp_autoteambalance 1 mp_autokick 9 mp_flashlight 1 mp_tkpunish 1 mp_forcecamera 0 sv_alltalk 0 sv_pausable 0 sv_cheats 0 sv_consistency 1 sv_allowupload 1 sv_allowdownload 1 sv_maxspeed 320 mp_limitteams 2 mp_hostagepenalty 5 sv_voiceenable 1 mp_allowspectators 1 mp_timelimit 25 mp_chattime 10 sv_timeout 65 sv_turbophysics 1 // round specific cvars mp_freezetime 6 mp_roundtime 5 mp_startmoney 800 mp_c4timer 45 mp_fraglimit 0 mp_maxrounds 0 mp_winlimit 0 mp_playerid 0 mp_spawnprotectiontime 5 // bandwidth rates/settings sv_minrate 0 sv_maxrate 0 decalfrequency 10 sv_maxupdaterate 60 sv_minupdaterate 10 sv_unlag 1 // server logging log off sv_logbans 0 sv_logecho 1 sv_logfile 1 sv_log_onefile 0 // operation sv_lan 0 sv_region 3 sv_contact YOUR@E-MAIL.COM // execute ban files exec banned_user.cfg exec banned_ip.cfg |
You can change the motd.txt file for a personalized welcome screen. If you want to only use a few maps you can also edit the maplist.txt and mapcycle.txt files.
[edit] Running the server
Now its time for a test run. We want to test the server as user "games" so we need to fix some permissions:
chown -R games:games /opt/halflife
Now change user to games ...
su - games
... and start the server:
cd /opt/halflife/css
./srcds_run -console -port 27015 -game cstrike +map de_dust +maxplayers 6
For Half-Life 2 Deathmatch do
cd /opt/halflife/hl2mp
./srcds_run -console -port 27015 -game hl2mp +map dm_lockdown +maxplayers 6
This is a good time to start your Steam client and test your server. If all went well type "quit" and change back to user root:
exit
As of 2005/11/16 my rc-script found its way into portage (thanks to SpanKY!). To make it work, we need a valid pidfile:
touch /var/run/hlds.pid
chown games:games /var/run/hlds.pid
Now you can start your hlds-server by typing
/etc/init.d/hlds start
and stop it by typing
/etc/init.d/hlds stop
Of course, you can also add it to your default runlevel
rc-update add hlds default
If you use the rc-script, you may have to edit /etc/conf.d/hlds and set
HLDS_PATH="/opt/halflife/css"
HLDS_OPTS="-console -port 27015 -game cstrike +map de_dust +maxplayers 6"
or, for Half-Life 2 Deathmatch
HLDS_PATH="/opt/halflife/hl2mp"
HLDS_OPTS="-console -port 27015 -game hl2mp +map dm_lockdown +maxplayers 6"
You might also have to adjust HLDS_MT.
| Note: When you stop the server it will delete your .pid file. Restarting the server doesn't re-create the .pid file. If you don't run the 'touch /var/run/hlds.pid' command before running '/etc/init.d/hlsd start' than you won't be able to stop the server outside of going into top and killing the process... Unless I'm doing this wrong... /Maximus |
| Note: To get the pid file to work correctly, I changed it's location to '/opt/halflife/hlds.pid'. This let the rc-script create the file. It couldn't before because running as games, it did not have write permission to '/var/run/'. Can someone that knows more about rc-scripts help fix this?
--Cinderblock 07:21, 27 July 2007 (UTC) |
Note: To fix this bug I changed /etc/init.d/hlsd script:
... touch /var/run/hlds.pid chown games:games /var/run/hlds.pid start-stop-deamon --start \ ... /Cepro |
Note: I must change HLDS_MT="scrds_run" in /etc/conf.d/hlds to fix rc-script, but i now have problem with stoping this daemon... I've added to script:
... start-stop-daemon --stop --pidfile /var/run/hlds.pid killall -u games ... but can somebody do it better, and post it here?? I've also turn on logs, by add: ...
-pidfile /var/run/hlds.pid ${HLDS_OPTS} > /var/log/hlds.log 2>/var/log/hlds.log &
...
|
--Amigafan 13:50 9 November 2005 (GMT)
--Hanu 12:51 19 July 2006 (PDT)
A good idea how to control multiply servers - moving them into "screen"
emerge screen
Mini screen howto: Create new screen: screen -S newscreenname
Detach created screen: CTRL+A, D
Restore screen: screen -r screenname
List all screen names: screen -list
For more info about "screen" utility see MAN_screen
After running your HLDS into screen, you have the possibility at anytime to get back control over the main console (not RCONed connections), so, if the server crashes you can see error output (in case of log missing)
[edit] Other method
We can install game also in a old fasion way - that is grabbing hldsupdatetool.bin and doing the rest by hand.
First you need uncompress package emerge app-arch/ncompress
Also refer to http://www.serverwiki.org/index.php/Installing_HLDS for Counter-Strike 1.6 , Condition Zero, Day Of Defeat etc servers
http://www.serverwiki.org/index.php/Installing_SRCDS for Source and Half-Life 2 game servers (mostly same manes but with Source suffix)
