ADDING CONTENT
Of course, we want to be able to use stuff from Team
Fortress 2, Counter-Strike: Source and other supported games. Using the script
above, this is simple process.
However, since we want to save on download time, we are
going to put all this content in a seperate folder, so if we have 5 servers, we
only need to update the content once if a content update gets released.
Now we are going to modify the script mentioned above. Add
the following line where it says "Add any additional servers here".
Here, we add Team Fortress 2.
update_server 232250 "content/tf2"
Now, when we run update_gmod.sh the script will verify (and,
if required, update) Garry's Mod (since we downloaded it in the step above) and
then install Team Fortress 2 in ~/content/tf2.
For a list of IDs for the servers, you can have a look at
the Valve Developer Community page. Remember that you can theoretically
download any game here using its ID, but with these dedicated servers you don't
need to login using your steam account.
Starting the server
To start the server, we run the file called srcds_run, which
is located in the root directory of each server. The command below starts the
server with 12 slots on gm_flatgrass.
~/server_1/srcds_run -game garrysmod +maxplayers 12 +map
gm_flatgrass
The script (srcds_run) will keep the server alive, should it
crash, but it won't restart when you restart linux and if you close the
terminal the server will close. We will fix this later on in this article.
Updating the server
To update the server, or to update the content, we simply
call our download script. You need to make sure your servers are off, or else
the update will fail.
Update our scripts by just calling this (from the home
directory)
./update_gmod.sh
Keeping the server alive after a reboot
To keep the server alive we use crontab. We add an entry to
crontab which will call srcds_run when the server has loaded.
Open crontab
crontab -e
Now, add the following line at the end
@reboot /home/steam/server_1/srcds_run -game garrysmod
+maxplayers 12 +map gm_flatgrass
Now save the file. Usually crontab opens in nano so the
commands would, again, be Ctrl+O, ↵ Enter, Ctrl+X.
Now, after you reboot the linux server, the Garry's Mod
Server will auto start.
Additional notes
Of course, there are better ways of keeping your server
alive, but they can become quite complex in no-time so they are not discussed
here. If you want to know more, Google around or ask on Facepunch.
No comments:
Post a Comment