Quick and dirty Linux dedicated server howto

ZaggyZaggy NullPointerExceptionThe Netherlands Join Date: 2003-12-10 Member: 24214Forum Moderators, NS2 Playtester, Reinforced - Onos, Subnautica Playtester
edited November 2013 in Server Discussion
A quick and dirty Linux dedicated server howto
Legend
Text in italic are commands to be run from the commandline

Initial installation of Ubuntu and Steam
Create a fresh Steam account for this server and note the login credentials.
Download Ubuntu Server x64 12.04.3: from http://www.ubuntu.com/download/server
Install Ubuntu Server x64, select appropriate options, select OpenSSH server if you want to remotely manage it.
Note: I highly recommend configuring your Ubuntu server properly, at LEAST change the default ssh port and disable root login, this guide should work rather well: http://www.thefanclub.co.za/how-to/how-secure-ubuntu-1204-lts-server-part-1-basics
Update, upgrade, install 32-bit libraries and reboot: sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install ia32-libs -y && sudo reboot
Create seperate folder for ns2 server and steam: mkdir ns2server && cd ns2server
Create seperate folders for ns2 server files, config and log: mkdir ns2 log config
Download and unpack SteamCMD: wget http://media.steampowered.com/client/steamcmd_linux.tar.gz && tar -xvzf steamcmd_linux.tar.gz
Run SteamCMD: ./steamcmd.sh
login steamaccountname
enter password
force_install_dir ns2
app_update 4940 validate
exit

Create server startup script and config files
If you have no GUI it's quite a bit to type out: wget the attachment of this post, extract the files and move them to appropriate folders:
wget -O ns2scripts.tar.gz http://tinyurl.com/pj8qyzn && tar -xvzf ns2scripts.tar.gz && mv *.json config/.
(original URL: https://us.v-cdn.net/5019629/uploads/FileUpload/cc/c1af7e46d444363753f03173ede096.gz)
Edit the config files, config/ServerAdmin.json and start.sh are important!
Make the following changes to start.sh:
Remove the \ in front of
"/home/<username>/ns2server/config"
add
sleep 2
above
echo
echo -n "Starting NS2 Server: "
And change the hostnames, usernames, password and ports.
Make sure start.sh is executable: chmod +x start.sh
If all this succeeded, you can attempt to start the server with ./start.sh!

Portforwarding
Remember to forward the appropriate ports or your server will not be visible!
Webport, 27000-27050 TCP/UDP (default server port) and 4380 UDP
As per https://support.steampowered.com/kb_article.php?ref=8571-GLVN-8711

Server startup script and nfig files copied below for reference
start.sh
--cut below--
#!/bin/bash
echo -n "Killing any previous servers: "
killall server_linux32
sleep 2
echo
echo -n "Starting NS2 Server: "
cd /home/<username>/ns2server/ns2
screen -A -m -d -S ns2 ./server_linux32 -name "Server title in browser" -webadmin -webdomain <LANaddresshere> -webuser <webusername> -webpassword <webuserpass> -webport <webport> -map ns2_biodome -ip <LANadresshere> -port 27015 -limit 16 -logdir /home/<username>/ns2server/log -config_path "/home/<username>/ns2server/config"
cd /home/<username>/ns2server
sleep 2
echo
echo "Attaching to server console..."
screen -x ns2
--cut above--

MapCycle.json
--cut below--
{
"maps": [ "ns2_descent", "ns2_docking", "ns2_mineshaft", "ns2_summit", "ns2_tram", "ns2_veil", "ns2_refinery", "ns2_biodome" ],
"time": 30,
"mode": "order",
"mods": [ ]
}
--cut above--
Cycle all official maps at time of writing.

ServerAdmin.json
--cut below--
{
"groups":
{
"admin_group": { "type": "allowed", "commands": [ "sv_changemap", "sv_reset", "sv_say", "sv_cheats"] },
"mod_group": { "type": "disallowed", "commands": [ "sv_ban", "sv_reset" ] },
"clan_group": { "type": "allowed", "commands": [ "sv_kick", "sv_say" ] }
}

"users":
{
"joe": { "id": 1234567, "groups": [ "admin_group" ] },
"bob": { "id": 12345678, "groups": [ "mod_group" ] }
}
}
--cut above--
Change users and their ids to the people you want to be admin or mod

ServerConfig.json
--cut below--
{
"settings": {
"rookie_friendly": false,
"end_round_on_team_unbalance": 0.4,
"auto_kick_afk_time": 300,
"auto_team_balance": {
"enabled_after_seconds": 10,
"enabled_on_unbalance_amount": 2
},
"auto_kick_afk_capacity": 0.5
},
"tags": [ "tag" ]
}
--cut above--
Current afk kick is set to kick after 5m

edit: couple of typos
Will look into the sv_commands and json rights issue, thanks radionaut!
edit2: removed \ from start.sh file, added sleep 2 after server start to give attach a bit more time to succeed, added attachment with corrected start.sh
TODO:
-check permissions issues with ServerAdmin.json

Comments

  • radionautradionaut california Join Date: 2013-01-22 Member: 181192Members, Reinforced - Supporter, WC 2013 - Gold
    Zaggy, thank you for this tutorial. getting a little practice server up and running in a vitualbox on windows 7 was relatively simple.
    i'm still a linux noob, so naturally hit a few minor snags along the way.
    wget -O ns2scripts.tar.gz http://tinyurl.com/pj8qyzn && tar -xvzf ns2script.tar.gz && mv *.json config/.
    
    should read: -xvzf ns2scripts.tar.gz
    start.sh wrote:
    \"/home/<username>/ns2server/config"
    should read: \"/home/<username>/ns2server/config\" (also works fine without quotes/escaped quotes)

    also, a user assigned to the admin group claimed to have no privileges to execute sv_* commands.
    after 'chmod 664 ServerAdmin.json' and a server restart, the sv_* commands worked (644 being default for that file).
    ^^ not sure what to make of that, i'll have to look into it further :/ (maybe it was simply a mistype on their part?)

    anyway, thanks again for this.
  • ZaggyZaggy NullPointerException The Netherlands Join Date: 2003-12-10 Member: 24214Forum Moderators, NS2 Playtester, Reinforced - Onos, Subnautica Playtester
    radionaut wrote: »
    Zaggy, thank you for this tutorial. getting a little practice server up and running in a vitualbox on windows 7 was relatively simple.
    i'm still a linux noob, so naturally hit a few minor snags along the way.
    wget -O ns2scripts.tar.gz http://tinyurl.com/pj8qyzn && tar -xvzf ns2script.tar.gz && mv *.json config/.
    
    should read: -xvzf ns2scripts.tar.gz
    start.sh wrote:
    \"/home/<username>/ns2server/config"
    should read: \"/home/<username>/ns2server/config\" (also works fine without quotes/escaped quotes)

    also, a user assigned to the admin group claimed to have no privileges to execute sv_* commands.
    after 'chmod 664 ServerAdmin.json' and a server restart, the sv_* commands worked (644 being default for that file).
    ^^ not sure what to make of that, i'll have to look into it further :/ (maybe it was simply a mistype on their part?)

    anyway, thanks again for this.

    Thank you for the feedback!
    Will make corrections to OP.
  • ZaggyZaggy NullPointerException The Netherlands Join Date: 2003-12-10 Member: 24214Forum Moderators, NS2 Playtester, Reinforced - Onos, Subnautica Playtester
    edited November 2013
    Tested guide with build 260, apart from config folder already existing it works.
    Edit: after deleting the old attachment I couldn't find a way to attach the new file..
  • ionfluxionflux Join Date: 2012-11-24 Member: 173039Members, Reinforced - Diamond, Reinforced - Shadow
    edited May 2014
    does console ever work?
  • titanmastertitanmaster usa Join Date: 2014-07-12 Member: 197386Members, Reinforced - Gold
    How does one get there server to not show up as lan in the list... portforwarded the server for both udp and tcp, set iptables, tried wiht -lan false flag... still not working any idea?
Sign In or Register to comment.