Linux dedicated server

From SDG Wiki
Jump to: navigation, search

Guide icon.png This is a community guide.
This page is maintained by the community, and will walk you through a specific task or mechanic. As this guide is maintained by the community, it may fail to provide the most reliable support on the subject.

This is a setup guide for hosting a Linux dedicated server for Unturned (version 3). Previously, RocketMod was required to start the server, but not anymore since the release of 3.30.3.0. RocketMod is still required however if you need to use the console.

Installing dependencies[edit]

Add an interactive process viewer, a virtual terminal, an unzip utility, and a file downloader. Most of the time, these packages are already installed, but it's never a bad idea to make sure.

sudo apt-get install screen htop unzip wget

Add 32-bit architecture libraries. This is required mostly for SteamCMD support.

sudo apt-get update
sudo apt-get install lib32gcc1

Create two files, start.sh and update.sh. In start.sh, add the contents of this into it.

#!/bin/bash -

UNTURNED_HOME="/path/to/server/directory/unturned"

# Un-comment the update.sh line to check for updates (and install if any) whenever the server runs.
# You should remove the "validate" keyword in the update.sh file however, since validating takes a long time (occurs every boot!)
# ./update.sh

ulimit -n 2048
export LD_LIBRARY_PATH=$UNTURNED_HOME/lib:$LD_LIBRARY_PATH

# Rename MyServer to whatever you'd like. Really doesn't matter, unless you want to save server states.

$UNTURNED_HOME/Unturned_Headless.x86_64 -nographics -batchmode -logfile 'Servers/MyServer/unturned.log' +secureserver/MyServer

In update.sh, add the contents of this it.

#!/bin/bash -
# This script was originally made by fr34kyn01535 (RocketMod), but modified.

STEAMCMD_HOME="/path/to/server/directory/steamcmd"
UNTURNED_HOME="/path/to/server/directory/unturned/"

mkdir -p $STEAMCMD_HOME
mkdir -p $UNTURNED_HOME

cd $STEAMCMD_HOME
if [ ! -f "steamcmd.sh" ]; then
	wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
	tar -xvzf steamcmd_linux.tar.gz
	rm steamcmd_linux.tar.gz
fi

./steamcmd.sh +login anonymous +force_install_dir $UNTURNED_HOME +app_update 1110390 validate +exit

Make sure all of the scripts are in the same folder, then run:

chmod +x *.sh

Now, you are ready to start installing the Unturned server. From the root directory of your server (with the steamcmd and unturned directories), execute the update.sh script.

./update.sh

If file permission errors appear, you may have tried to install the server as root. Try running the following, while replacing [YOUR USERNAME] with the account being used to run the server (it should be the same used for in the SystemD script later on):

chown -R [YOUR USERNAME]:[YOUR USERNAME] /path/to/server/directory

If you have an error similar to this:

dlopen failed trying to load:
steamclient.so
with error:
steamclient.so: cannot open shared object file: No such file or directory
[S_API FAIL] SteamAPI_Init(): Sys_LoadModule failed to load: steamclient.so
[S_API FAIL] SteamAPI_Init() failed

Run these two commands from the root directory of your server (steamcmd and unturned folder are within this).

cp steamcmd/linux64/steamclient.so /lib
cp steamcmd/linux64/steamclient.so /lib64

Creating a SystemD script allows the server to automatically reboot. Using your preferred text editor (e.g., Vim, GNU nano, Pico, Emacs), create a file ending with .service in /usr/lib/systemd/system/ as root or with sudo.

[Unit]
Description=Unturned Server
RefuseManualStart=no
RefuseManualStop=no

[Service]
User=[REPLACE WITH YOUR USERNAME]
Type=forking
Restart=always
ExecStart=/usr/bin/screen -dmS [SERVER NAME] /path/to/server/directory/start.sh
WorkingDirectory=/path/to/server/directory

[Install]
WantedBy=multi-user.target

If you have created a secondary (low-permission) account, use that instead in the script. Otherwise, use the current account you are on.

Never use root, as it is unsafe and may mess up the file permissions.

Current Problems

  • 64-bit library is placed in the 32-bit library folder (/lib) due to a flaw in Unturned.
  • Console doesn't work, unless you install RocketMod.