Serwery na Linuxie

*Ten artykuł to jedynie zalążek, zawiera jedynie szczątkowe informacje o temacie. Możesz pomóc Krypcie poszerzając go.*
Ten artykuł nie został przetłumaczony w całości lub zawiera błędy w przekładzie.

Prosimy, pomóż w sprawdzeniu, dokończeniu lub poprawieniu tłumaczenia.
This tutorial will guide you through the steps required to setup a dedicated 7DTD server on Linux. The tutorial is currently targeted to the Alpha 1 release which seems to work as fine on Linux as it does on Windows.

Part of this tutorial are:

* Setup of 7DTD as dedicated server
* Startup/stop scripts, also for automatic start on system boot
* Memory usage monitoring / limit exceeding notification by mail or XMPP/Jabber (optional)
* Automatic save backups (optional)

The steps and used software in this tutorial apply to a Debian Squeeze (6) installation.

## Required software

Debian package names for Squeeze are given in brackets.

* Wine (as long as there is no "native" Linux build)
* Xvfb (probably also only as long as there is no native build)
* Mono-runtime
* Screen
* bash (for scripts)
* rsync (for backups)
* sendemail, sendxmpp (for memory limit notifications, both optional)

## Installation layout

Paths can be changed but this guide will assume that you use the paths as following:

/home/sdtd
home for the user running the server
/home/sdtd/7dtd
root of the 7dtd server installation
/home/sdtd/7dtd/7DaysToDie.exe
resulting in this path to the main exe
/usr/local/bin
For the management scripts
/etc/7dtd.conf
For global script configuration
/etc/init.d/7dtd.sh
Init script to start/stop the server
## Useraccount dedicated to running 7dtd

As running the game as root is not really the best thing we will create a new user just for the server.

```
useradd -d /home/sdtd -m -r -s /bin/bash -U sdtd

```

This will create a user and group named *sdtd* (last parameter) with home directory */home/sdtd*. Both can be changed but you will also have to adapt the other steps later on.

## "Install" the game

**Note:** It seems like the 64 bit version of the game does not run nicely on Wine. Please use the 32 bit version no matter if your server is 32 or 64 bit.

You can of course directly use the Windows installer on the server with Wine but that would require you to have either a monitor attached to the server or run a remote desktop.

An easier approach is to install the game normally on any machine running Windows and upload the installed game folder. You can (and should) of course compress the files to upload as this will significantly reduce upload size.

## Install the management script files

Get the script files:

```
wget http://illy.bz/fi/7dtd/management\_scripts.tar.gz

```

Extract the files to */*:

```
tar -xvzf management_scripts.tar.gz -C /

```

(alternatively you can extract to some temporary path and move files to their respective target folders manually)

Open the file /etc/7dtd.conf in the editor of your choice and edit the values. If you used the paths and usernames as in this guide you will most likely only have to edit the savegame name and memory limit notification values. make the server start at system boot:

```
update-rc.d 7dtd.sh defaults

```

## Upload a savegame

As it currently seems impossible to create a savegame directly on the server start a new local game on a Windows client and quit it. Then open the saves folder on that machine (*installation path\Data\Worlds\Navezgane\Saves\yourSafeName*), compress the folder of your savegame, upload and extract it to the appropriate folder on the server (*/home/sdtd/7dtd/Data/Worlds/Saves/yourSafeName*).

After uploading make sure the the whole *7dtd*-folder is owned by the user that will later run the engine:

```
chown sdtd.sdtd /home/sdtd/7dtd -R

```

## Add cron-jobs for savegame backups and memory limit notifications

If you want the system to automatically backup the Worlds folder add the following line to */etc/crontab*:

```
0 *     * * *   root    /usr/local/bin/7dtd-backup.sh

```

First two columns specify on which minute (0) and which hour (\* = every hour) the backup will be run. Next three specify day, month and day of week (you probably want to keep \* here).

**Warning:** As of Alpha 1 the game seems to only save the current state if the last player disconnects. So make sure that all players disconnect every now and then.

If you want to get notifications on the memory limit add this line:

```
*/5 *   * * *   root    /usr/local/bin/7dtd-check_mem.sh

```

Setting the minute to *\*/5* means the script is run *every 5* minutes.

**Make sure you set the appropriate values in */etc/7dtd.conf*!**

## Start the server

```
7dtd-start.sh

```

If everything went fine you should now be able to check console output of 7dtd:

```
screen -r sdtd/sdtd

```

This will open the virtual terminal that was attached to the game. **Do not press Ctrl+C to disconnect from that screen! Doing so will stop the whole engine!** The parameter specifies username of the user running 7dtd / screen session name (you should only need to change the first *sdtd* if you changed the name of the user running the engine). Normal output should look something like this:

```
Mono path[0] = 'Z:/home/sdtd/7dtd/7DaysToDie_Data/Managed'
Mono path[1] = 'Z:/home/sdtd/7dtd/7DaysToDie_Data/Mono'
Mono config path = 'Z:/home/sdtd/7dtd/7DaysToDie_Data/Mono/etc'

```

To disconnect from that screen session press Ctrl+A, Ctrl+D (simply keep Ctrl pressed). To stop the server run

```
7dtd-stop.sh

```

## Final words

Currently 7dtd does not include any login authentication. If you do not want your server to be public to everybody you have to set up external means to prevent this (e.g. OpenVPN or a firewall, if the clients have static IP addresses).

For feedback, comments, suggestions, discussion whatever please use the forum thread.