FreeBSD Dedicated Server Setup

From GMod Wiki

Revision as of 16:07, 20 June 2010 by Philxyz (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Contents

Freebsd-logo.png FreeBSD

NOTICE: Linux server binaries are currently in beta and are not guaranteed to be updated as often as the Windows binaries. AzuiSleet is doing his best to keep them up to date.

Install Guide

Stop.png You will need to be root at one point in this guide so be careful! You can do serious damage while logged in as root.

Install Linux Compatibility

Become root and execute the following command:

kldload linux

Now edit /etc/rc.conf and append the following text to the end of the file:

linux_enable=YES

Now install the linux user tools:

cd /usr/ports/emulators/linux_base-f10 && make install distclean

Finally, mount the Linux proc filesystem.

mount -t linprocfs linproc /compat/linux/proc

To avoid having to mount it manually like that ^ at every boot, add the following line to the end of /etc/fstab

linprocfs    /compat/linux/proc    linprocfs    rw    0    0

Want to run multiple gmod servers?

- You can run multiple servers if you like, just remember to use different ports for each server. - Another option is using BSD Jails. With this method, you can allocate a CPU and a new IP address to each server instance on your single FreeBSD server.

Setting up BSD Jails (optional, incomplete)

setenv D /usr/jail/server1                        (where 1 is the dedicated server number)
mkdir -p $D
cd /usr/src
make buildworld
make installworld DESTDIR=$D
make distribution DESTDIR=$D
mount -t devfs devfs $D/dev
Add the jails to /etc/rc.conf
jail_enable="YES"
jail_list="server1"
jail_server1_rootdir="/usr/jail/server1" # jail's root directory
jail_server1_hostname="gmod145.extremeserversorsomething.net"  # jail's hostname
jail_server1_ip="192.168.0.10"           # jail's IP address
jail_server1_devfs_enable="YES"          # mount devfs in the jail
jail_server1_devfs_ruleset="server1_ruleset" # devfs ruleset to apply to jail
How to start and stop the jail
/etc/rc.d/jail start server1
/etc/rc.d/jail stop server1

Create a user

Never run srcds as root.


You should use an unprivileged user to run srcds.

If you have root access:

adduser
Username: gmod
Full Name: Garry Mod
Uid (Leave empty for default):
Login group [gmod]:
Login group is gmod. Invite gmod into other groups? []:
Login class [default]:
Shell (sh csh tcsh nologin) [sh]:
Home directory [/home/gmod]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password: (whatever you like here)
Enter password again: (whatever you like here - same as above)
Lock out the account after creation? [no]:
OK? (yes/no): yes
adduser: INFO: Successfully added (gmod) to the user database.
Add another user? (yes/no): no
Goodbye!

Login as gmod before continuing.

su gmod

Change to home directory:

cd

Make a folder for your server

Go to your home folder if not already there:

cd ~
mkdir srcds
cd srcds

Installing Steam

Do this bit as the "gmod" user for security reasons:

su gmod

Download the dedicated server update tool, make it executable and run it.

wget http://www.steampowered.com/download/hldsupdatetool.bin
chmod +x hldsupdatetool.bin
./hldsupdatetool.bin

You will need to agree to the terms of the license agreement - type 'yes' and press return.

If you receive an error about uncompressing, make a symbolic link to the gunzip tool called "/usr/bin/uncompress". If you already have a tool called uncompress, be sure to move it away from /usr/bin/uncompress first.

ln -s /usr/bin/gunzip /usr/bin/uncompress

Now run Steam - Providing you have an active Internet connection and the Steam servers are up, it will update itself.

./steam

Now we want to install Garry's Mod.

Installing GM10 Content

Enter the following:

./steam -command update -game orangebox -dir .
./steam -command update -game garrysmod -dir .

Installing the necessary Linux binary code

Now, download the GMod Linux server binaries from http://www.facepunch.com/showthread.php?t=933697, and save the zip file to your srcds folder and unzip them there:

unzip <filename>.zip

Next, move each of the extracted files below into the places they need to be for the server to operate:

mv server_i486.so orangebox/garrysmod/bin
mv lua_shared_i486.so orangebox/bin
mv scenecacheproxy_i486.so orangebox/bin
mv gm_sqlite orangebox/garrysmod/lua/includes/modules/gm_sqlite_486.dll

Installing extra game content

See the Extra Content section of General Server Setup Information.

Optionally Creating a Startup Script

You can now in theory just run the server with this command: orangebox/srcds_run -console -game garrysmod +maxplayers 16 +map gm_construct -autoupdate

However if you close SSH your server will close too.

We want to attach our GMod server to a virtual screen so we can log off and come back later or share the screen with other users (Other admins for example).

Open up a file called startgmod.sh with your favourite editor, for example:

nano -w startgmod.sh

Enter the following into the file:

#!/bin/bash
echo "Starting up Garry's Mod 10 server."
sleep 5
screen -A -m -d -S gm10server orangebox/srcds_run -console -game garrysmod +maxplayers 16 +map gm_construct -autoupdate
echo "Started. Type screen -x to resume!"

You may wish to edit maxplayers and map.

Once you've got to this stage you're good to go. Make the script executable before running it:

chmod +x startgmod.sh

Everyday Server Operations

Starting Up

Type:

./startgmod.sh

Shutting Down

Type:

screen -x

This resumes your screen session, sharing it with any other users. If the server is still active with players, it's advisable to shut it down by typing:

killserver

Once you've done that, press Ctrl+C+X to kill the screen.

If it's hung, just press Ctrl+C+X.

Administration

If you type:

screen -x

You're sitting at the console of your server.

Info 64.png To disconnect from screen, type Ctrl+D+A.
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox