Skip to content

Commit

Permalink
Refactor current confighandling, added features and fixed some shell …
Browse files Browse the repository at this point in the history
…linting
  • Loading branch information
jammsen committed Oct 3, 2024
1 parent 8b69fb4 commit 8df992f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM jammsen/base:wine-stable-debian-bullseye
FROM jammsen/base:wine-stable-debian-bookworm

LABEL org.opencontainers.image.authors="Sebastian Schmidt"
LABEL org.opencontainers.image.source="https://github.com/jammsen/docker-sons-of-the-forest-dedicated-server"
Expand All @@ -11,6 +11,7 @@ ENV WINEPREFIX=/winedata/WINE64 \
PUID=0 \
PGID=0 \
ALWAYS_UPDATE_ON_START=1 \
SKIP_NETWORK_ACCESSIBILITY_TEST=false \
USERDATA_PATH=/sonsoftheforest/userdata

VOLUME ["/sonsoftheforest", "/steamcmd", "/winedata"]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ services:
restart: always
environment:
ALWAYS_UPDATE_ON_START: 1
SKIP_NETWORK_ACCESSIBILITY_TEST: false
ports:
- 8766:8766/udp
- 27016:27016/udp
Expand Down
1 change: 1 addition & 0 deletions dedicatedserver.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"LogFilesEnabled": false,
"TimestampLogFilenames": true,
"TimestampLogEntries": true,
"SkipNetworkAccessibilityTest": false,
"GameSettings": {},
"CustomGameModeSettings": {}
}
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:
restart: always
environment:
ALWAYS_UPDATE_ON_START: 1
SKIP_NETWORK_ACCESSIBILITY_TEST: false
ports:
- 8766:8766/udp
- 27016:27016/udp
Expand Down
28 changes: 19 additions & 9 deletions usr/bin/servermanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ function installServer() {
echo ">>> Doing a fresh install of the gameserver"
isWineinBashRcExistent
steamcmdinstaller.sh
mkdir -p $USERDATA_PATH
mkdir -p "$USERDATA_PATH"

# only copy dedicatedserver.cfg if doesn't exist
if [ ! -f $CONFIGFILE_PATH ]; then
cp /dedicatedserver.cfg.example $CONFIGFILE_PATH
sed -i -e "s/###RANDOM###/$RANDOM/g" $CONFIGFILE_PATH
if [ ! -f "$CONFIGFILE_PATH" ]; then
cp /dedicatedserver.cfg.example "$CONFIGFILE_PATH"
sed -i -e "s/###RANDOM###/$RANDOM/g" "$CONFIGFILE_PATH"
fi

# only copy ownerswhitelist.txt if doesn't exist
if [ ! -f $USERDATA_PATH/ownerswhitelist.txt ]; then
cp /ownerswhitelist.txt.example $USERDATA_PATH/ownerswhitelist.txt
cp /ownerswhitelist.txt.example "$USERDATA_PATH/ownerswhitelist.txt"
fi

cp /steam_appid.txt $GAME_PATH
Expand All @@ -88,19 +88,29 @@ function startServer() {
fi
echo ">>> Starting the gameserver"
rm /tmp/.X1-lock 2> /dev/null
cd /sonsoftheforest
wine64 /sonsoftheforest/SonsOfTheForestDS.exe -userdatapath $USERDATA_PATH
# shellcheck disable=SC2164
cd "$GAME_PATH"
wine64 /sonsoftheforest/SonsOfTheForestDS.exe -userdatapath "$USERDATA_PATH"
}

function startMain() {
# Check if server is installed, if not try again
if [ ! -f "/sonsoftheforest/SonsOfTheForestDS.exe" ]; then
installServer
fi
if [ $ALWAYS_UPDATE_ON_START == 1 ]; then
if [[ ${ALWAYS_UPDATE_ON_START} == 1 ]]; then
updateServer
fi
if [[ -n ${SKIP_NETWORK_ACCESSIBILITY_TEST+x} ]]; then
echo ">>> Setting SkipNetworkAccessibilityTest to '$SKIP_NETWORK_ACCESSIBILITY_TEST'"
# sed -E -i "s/SkipNetworkAccessibilityTest=[a-zA-Z]*/SkipNetworkAccessibilityTest=$SKIP_NETWORK_ACCESSIBILITY_TEST/" "$CONFIGFILE_PATH"
# shellcheck disable=SC2086
sed -E -i 's/"SkipNetworkAccessibilityTest":\s*(false|true)/"SkipNetworkAccessibilityTest": '$SKIP_NETWORK_ACCESSIBILITY_TEST'/' "$CONFIGFILE_PATH"
cat "$CONFIGFILE_PATH"
fi
startServer
}

echo ">>> Listing config options ..."
echo "> ALWAYS_UPDATE_ON_START is set to: $ALWAYS_UPDATE_ON_START"
echo "> SKIP_NETWORK_ACCESSIBILITY_TEST is set to: $SKIP_NETWORK_ACCESSIBILITY_TEST"
startMain

0 comments on commit 8df992f

Please sign in to comment.