diff --git a/.gitignore b/.gitignore index de78a08..373bbc5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -BepInEx/ -data/ \ No newline at end of file +data/ +mods/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7d6f926..5b1d29e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/* diff --git a/docker-compose.yml b/docker-compose.yml index d26adfd..bf95516 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/launch.d/10-bepinex b/launch.d/10-bepinex new file mode 100644 index 0000000..764ac29 --- /dev/null +++ b/launch.d/10-bepinex @@ -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 + + + +EOL + +pushd mods +for mod in *; do + if [ -d "$mod" ]; then + echo "Found MOD: ${mod}..." + cat <> ../modconfig.xml + + ${mod} + true + ${STEAM_APP_PATH}/mods/${mod} + +EOL + fi +done +popd + +cat <> modconfig.xml + + 1 + true + + + +EOL + +# Make the modconfig immutable... sigh. +chattr +i modconfig.xml + +popd diff --git a/launch.d/99-start b/launch.d/99-start index 17e5e34..3ffa2df 100644 --- a/launch.d/99-start +++ b/launch.d/99-start @@ -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 \ No newline at end of file diff --git a/modlist.txt b/modlist.txt deleted file mode 100644 index 52027d8..0000000 --- a/modlist.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Put your workshop mod IDs between these two comments -# EOF - The parser needs a blank line at the end \ No newline at end of file