Skip to content

Commit

Permalink
feat: improve readme, add restart behaviour for docker compose file, …
Browse files Browse the repository at this point in the history
…set SkipNetworkAccessibilityTest always to true
  • Loading branch information
Rouven Himmelstein committed Jan 24, 2024
1 parent fb955e9 commit 79553e7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
56 changes: 40 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@

## Introduction

This repository provides a container image for running a Sons of the Forest game server. It is designed to be used with
Docker and Docker Compose, making it easy to set up and manage your game server environment.
This repository provides a container image for running a Sons of the Forest game server.
It is designed to be used with Docker and Docker Compose,
making it easy to set up and manage your game server environment.

## Installation

To install and run the Sons of the Forest server using this container image, you will need _Docker_ and _Docker Compose_
installed on your system. If you do not have these tools installed, please refer to the official Docker documentation
for installation instructions.
To install and run the Sons of the Forest server using this container image,
you will need _Docker_ and _Docker Compose_ installed on your system.
If you do not have these tools installed,
please refer to the official Docker documentation for installation instructions.

Once Docker and Docker Compose are installed, clone this repository to your local machine:

Expand All @@ -49,32 +51,54 @@ docker-compose pull
docker-compose up -d
```

This will pull the latest image and start the server in detached mode. Your Sons of the Forest server should now be
running and accessible.
This will pull the latest image and start the server in detached mode.

When starting the server for the first time:

* The config files and folders will be automatically created in the `config/` folder.
* The server will download the latest version of the game from Steam to the `data/` folder.
* The server might need to be restarted once to apply the latest game update.

To restart the server after making changes to the configuration, use the following command:

```bash
docker-compose restart
```

In order to check the server logs, use the following command:

```bash
docker-compose logs -f
```

## Configuration

The game server configuration is done within the `dedicatedserver.cfg` located in the `config/` folder. The file is
automatically created on the first start of the container. You need to restart the container for changes to take effect.
> The server configuration does not differ from the official server configuration.
> Just follow an existing comprehensive guide on how to configure the
> server: https://steamcommunity.com/sharedfiles/filedetails/?id=2992700419&snr=1_2108_9__2107
The `config` folder contains the configuration files for the game server:

* The server owners list, in a file called `ownerswhitelist.txt`
* The game server configuration, in a file called `dedicatedserver.cfg`
* The game saves, in a folder called `Saves`
* The game settings, in a file called `SonsGameSettings.cfg`

All files and folders in the `config` will be created automatically when the server is started for the first time.

> `SkipNetworkAccessibilityTest` is always set to `true`, because the test method is not working in a container
> environment.
The `ownerswhitelist.txt`, also located in the `config/` folder, contains the Steam IDs of the people who are allowed
to join the server. The file is automatically created on the first start of the container. You need to restart the
container for changes to take effect.

The `data/` folder contains the game server data, such as the world/map save files.
Feel free to modify files in this folder, but be aware that the game server must be restarted for changes to take
effect.
The `data/` folder contains the game server data.
Feel free to modify files in this folder,
but be aware that the game server must be restarted for changes to take effect.
The folder can be deleted to reset the game server to its default state.

# Resources

- Inspired by: https://github.com/jammsen/docker-sons-of-the-forest-dedicated-server
- Built from: https://github.com/RouHim/sons-of-the-forest-container-image
- Built to: https://hub.docker.com/r/rouhim/sons-of-the-forest-server
- SteamCMD Documentation: https://developer.valvesoftware.com/wiki/SteamCMD
- SteamCMD Documentation: https://developer.valvesoftware.com/wiki/SteamCMD
- Dedicated server guide: https://steamcommunity.com/sharedfiles/filedetails/?id=2992700419&snr=1_2108_9__2107
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:
build:
context: .
dockerfile: Containerfile
restart: unless-stopped
volumes:
- "./config:/config"
- "./data:/data"
Expand Down
6 changes: 5 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ echo "✅ Server config is readable!"
echo "🖥️ Starting virtual display..."
export DISPLAY=":99"
rm -rf /tmp/.X* 2> /dev/null
Xvfb :99 -screen 0 1024x768x16 &
Xvfb :99 -screen 0 1024x768x16 -nolisten tcp -nolisten unix &
wineboot -r

# Update server
echo "🔄 Updating server..."
$STEAMCMD +runscript "$USER_HOME"/steam-game.script

# Modify the $SERVER_CONFIG_DIR/dedicatedserver.cfg (json file) and set the value SkipNetworkAccessibilityTest to true
echo "🔧 Adjust server config..."
sed -i 's/"SkipNetworkAccessibilityTest": false/"SkipNetworkAccessibilityTest": true/g' "$SERVER_CONFIG_DIR"/dedicatedserver.cfg

# Start server
echo "🎮 Starting server..."
cd "$SERVER_DIR"
Expand Down

0 comments on commit 79553e7

Please sign in to comment.