Skip to content

Commit

Permalink
Updated to autoload any mod placed in a mods mout
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnVidler committed Oct 24, 2024
1 parent 0145ccf commit 7161b46
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BepInEx/
data/
data/
mods/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ENV MOD_STATIONEERSMODS_VERSION="${MOD_STATIONEERSMODS_VERSION}"
# Stationeers requires a different version of libstdc++ and libc to actually work, so we roll this back
USER root
RUN touch /etc/apt/sources.list && sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list && \
apt-get update && apt-get install -y file locales unzip libc6 libstdc++6 locales && locale-gen en_GB.UTF-8 && \
apt-get update && apt-get install -y file locales unzip libarchive-tools libc6 libstdc++6 locales && locale-gen en_GB.UTF-8 && \
sed -i 's/bookworm/bullseye/g' /etc/apt/sources.list && \
rm -rf /var/lib/apt/lists/*

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ services:
- "8081:8081/tcp"
volumes:
- ./data:/home/steam/stationeers/saves
- ./modlist.txt:/home/steam/stationeers/modlist.txt
- ./mods:/home/steam/stationeers/mods
79 changes: 79 additions & 0 deletions launch.d/10-bepinex
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

pushd "${STEAM_APP_PATH}"

# Do we have a config directory yet?
if [ ! -f BepInEx/config/BepInEx.cfg ]; then
echo "Running first-time BepInEx setup"

if [ ! -f "BepInEx_linux_x64_${MOD_BEPINEX_VERSION}.zip" ]; then
echo "Downloading BepInEx version ${MOD_BEPINEX_VERSION}"
curl -LO "https://github.com/BepInEx/BepInEx/releases/download/v${MOD_BEPINEX_VERSION}/BepInEx_linux_x64_${MOD_BEPINEX_VERSION}.zip"
unzip "BepInEx_linux_x64_${MOD_BEPINEX_VERSION}.zip"
fi

if [ ! -d BepInEx/plugins ]; then
mkdir -p "BepInEx/plugins"
pushd "BepInEx/plugins"

echo "Downloading and unpacking jixxed/StationeersMods..."
if [ ! -f StationeersMods.zip ]; then
echo "Downloading StationeersMods version ${MOD_STATIONEERSMODS_VERSION}"
curl -LO "https://github.com/jixxed/StationeersMods/releases/download/v${MOD_STATIONEERSMODS_VERSION}/StationeersMods.zip"
#unzip "StationeersMods.zip"
bsdtar -xf StationeersMods.zip -s'|[^/]*/||'
fi

echo "Downloading and unpacking pch91/ServerFixes-Stationeers..."
if [ ! -f ServerFixes.zip ]; then
echo "Downloading StationeersMods version ${MOD_STATIONEERSMODS_VERSION}"
curl -LO "https://github.com/pch91/ServerFixes-Stationeers/releases/download/V1.0.0/ServerFixes.zip"
#unzip "ServerFixes.zip"
bsdtar -xf ServerFixes.zip -s'|[^/]*/||'
fi

popd
fi

# Update the runner script to have our executable
sed -i 's/^executable_name=""$/executable_name="rocketstation_DedicatedServer.x86_64"/' run_bepinex.sh
chmod u+x run_bepinex.sh
else
echo "BepInEx already present, skipped"
fi

# Autocreate the modconfig.xml for anything in /mods
cat > modconfig.xml << EOL
<?xml version="1.0" encoding="utf-8"?>
<ModConfig xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Mods>
EOL

pushd mods
for mod in *; do
if [ -d "$mod" ]; then
echo "Found MOD: ${mod}..."
cat <<EOL >> ../modconfig.xml
<ModData>
<Id>${mod}</Id>
<IsEnabled>true</IsEnabled>
<LocalPath>${STEAM_APP_PATH}/mods/${mod}</LocalPath>
</ModData>
EOL
fi
done
popd

cat <<EOL >> modconfig.xml
<ModData>
<Id>1</Id>
<IsEnabled>true</IsEnabled>
</ModData>
</Mods>
</ModConfig>
EOL

# Make the modconfig immutable... sigh.
chattr +i modconfig.xml

popd
65 changes: 47 additions & 18 deletions launch.d/99-start
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,52 @@

pushd "${STEAM_APP_PATH}"

rocketstation_DedicatedServer.x86_64 \
-batchmode \
-nographics \
-autostart \
-difficulty "${SV_DIFFICULTY}" \
-loadlatest "${SV_SAVE_NAME}" ${SV_DEFAULT_WORLD} \
-settings \
StartLocalHost "True" \
ServerVisible "${SV_VISIBLE}" \
ServerName "${SV_NAME}" \
GamePort ${SV_PORT} \
ServerPassword "${SV_PASSWORD}" \
AutoSave "${SV_AUTOSAVE}" \
SaveInterval ${SV_SAVE_INTERVAL} \
ServerMaxPlayers ${SV_MAX_PLAYERS} \
UPNPEnabled "${SV_UPNP_ON}" \
ServerAuthSecret "${SV_AUTH_SECRET}" \
LocalIpAddress "0.0.0.0"
chmod u+x run_bepinex.sh

# Run the server with a timeout first, if we haven't got a config yet...
# Yes, this is a stupid hack, but it works, and only affects initial startup times
# so it's not _entirely_ terrible...
if [ ! -f BepInEx/config/BepInEx.cfg ]; then
timeout 20 run_bepinex.sh \
-batchmode \
-nographics \
-autostart \
-difficulty "${SV_DIFFICULTY}" \
-loadlatest "${SV_SAVE_NAME}" ${SV_DEFAULT_WORLD} \
-settings \
StartLocalHost "True" \
ServerVisible "${SV_VISIBLE}" \
ServerName "${SV_NAME}" \
GamePort ${SV_PORT} \
ServerPassword "${SV_PASSWORD}" \
AutoSave "${SV_AUTOSAVE}" \
SaveInterval ${SV_SAVE_INTERVAL} \
ServerMaxPlayers ${SV_MAX_PLAYERS} \
UPNPEnabled "${SV_UPNP_ON}" \
ServerAuthSecret "${SV_AUTH_SECRET}" \
LocalIpAddress "0.0.0.0"

echo "Ran once to generate a BepInEx configuration. Restarting..."
fi

# Otherwise run a regular server instance
run_bepinex.sh \
-batchmode \
-nographics \
-autostart \
-difficulty "${SV_DIFFICULTY}" \
-loadlatest "${SV_SAVE_NAME}" ${SV_DEFAULT_WORLD} \
-settings \
StartLocalHost "True" \
ServerVisible "${SV_VISIBLE}" \
ServerName "${SV_NAME}" \
GamePort ${SV_PORT} \
ServerPassword "${SV_PASSWORD}" \
AutoSave "${SV_AUTOSAVE}" \
SaveInterval ${SV_SAVE_INTERVAL} \
ServerMaxPlayers ${SV_MAX_PLAYERS} \
UPNPEnabled "${SV_UPNP_ON}" \
ServerAuthSecret "${SV_AUTH_SECRET}" \
LocalIpAddress "0.0.0.0"

popd
2 changes: 0 additions & 2 deletions modlist.txt

This file was deleted.

0 comments on commit 7161b46

Please sign in to comment.