From a9ec72d6bb3f5067a33395ed149a034d020f8b6c Mon Sep 17 00:00:00 2001 From: Vinanrra Date: Tue, 12 Dec 2023 19:21:29 +0100 Subject: [PATCH] fix: Comeback of BepInEx 5.4.5 --- Dockerfile | 3 +- docs/mods_support.md | 4 ++ docs/parameters.md | 7 +++ docs/usage.md | 4 ++ scripts/Mods/bepinex.sh | 88 +++++++++++++++++++++++++++++++++++ scripts/Mods/mods_install.sh | 4 ++ scripts/Mods/mods_update.sh | 5 ++ scripts/Mods/undead_legacy.sh | 7 +++ 8 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 scripts/Mods/bepinex.sh diff --git a/Dockerfile b/Dockerfile index 2580d75..fe54950 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ STOPSIGNAL SIGTERM ####Labels#### LABEL maintainer="vinanrra" -LABEL build_version="version: 0.6.1" +LABEL build_version="version: 0.6.2" ####Environments #### ENV TimeZone=Europe/Madrid HOME=/home/sdtdserver LANG=en_US.utf8 TERM=xterm DEBIAN_FRONTEND=noninteractive @@ -93,6 +93,7 @@ ENV PUID=1000 PGID=1000 \ UNDEAD_LEGACY=no UNDEAD_LEGACY_VERSION=stable UNDEAD_LEGACY_UPDATE=no UNDEAD_LEGACY_URL=False \ ENZOMBIES=no ENZOMBIES_ADDON_SNUFKIN=no ENZOMBIES_ADDON_ROBELOTO=no ENZOMBIES_ADDON_NONUDES=no ENZOMBIES_UPDATE=no \ CPM=no CPM_UPDATE=no \ + BEPINEX=no BEPINEX_UPDATE=no \ CHANGE_CONFIG_DIR_OWNERSHIP=YES \ DARKNESS_FALLS_URL=False DARKNESS_FALLS=no DARKNESS_FALLS_UPDATE=no diff --git a/docs/mods_support.md b/docs/mods_support.md index a59ae97..a197bc1 100644 --- a/docs/mods_support.md +++ b/docs/mods_support.md @@ -34,6 +34,10 @@ Remember that some mods can't be installed with others, if you have problems wit - Environments: - CPM - CPM_UPDATE +- [BepInEz](https://github.com/BepInEx/BepInEx) + - Environments: + - BEPINEX + - BEPINEX_UPDATE - [Darkness Falls](https://community.7daystodie.com/topic/4941-darkness-falls-they-mostly-come-out-at-night/) - Environments: - DARKNESS_FALLS diff --git a/docs/parameters.md b/docs/parameters.md index 3a952b5..989b4da 100644 --- a/docs/parameters.md +++ b/docs/parameters.md @@ -98,6 +98,13 @@ | `CPM=NO` | Install [CPM](https://docs.csmm.app/en/cpm/), CPM version will be installed according to 7 days to die branch version, this will also install Allocs Fixes **optional** | YES, NO | | `CPM_UPDATE=NO` | Update [CPM](https://docs.csmm.app/en/cpm/), CPM on every server start, depending of your 7 days to die version, requiere UPDATE_MODS=YES **optional** | YES, NO | +### BepInEx + +| Parameter | Function | Values | +| --- | --- | :---: | +| `BEPINEX=NO` | Install [BEPINEX](https://github.com/BepInEx/BepInEx), latest BEPINEX version will be installed**optional** | YES, NO | +| `BEPINEX_UPDATE=NO` | Update [BEPINEX](https://github.com/BepInEx/BepInEx), BEPINEX on every server start, requiere UPDATE_MODS=YES **optional** | YES, NO | + ### START MODES | START_MODE | Information | diff --git a/docs/usage.md b/docs/usage.md index dffd7b3..ce031cc 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -39,6 +39,8 @@ docker run -d \ -e ENZOMBIES_UPDATE=NO \ -e CPM=NO \ -e CPM_UPDATE=NO \ + -e BEPINEX=NO \ + -e BEPINEX_UPDATE=NO \ -e BACKUP=NO \ -e MONITOR=NO \ -e PUID=1000 \ @@ -78,6 +80,8 @@ services: - ENZOMBIES_UPDATE=NO # Optional - Update EnZombies mod and addons before server start - CPM=NO # Optional - CSMM Patron's Mod (CPM) - CPM_UPDATE=NO # Optional - Update CPM before server start + - BEPINEX=NO # Optional - BepInEx + - BEPINEX_UPDATE=NO # Optional - Update BepInEx before server start - BACKUP=NO # Optional - Backup server at 5 AM - MONITOR=NO # Optional - Keeps server up if crash volumes: diff --git a/scripts/Mods/bepinex.sh b/scripts/Mods/bepinex.sh new file mode 100644 index 0000000..c8ba67e --- /dev/null +++ b/scripts/Mods/bepinex.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +BASEPATH="/home/sdtdserver" +SERVERFILES_FOLDER="${BASEPATH}/serverfiles" +BEPINEX_SH="${SERVERFILES_FOLDER}/run_bepinex.sh" +LSGMSDTDSERVERCFG="${BASEPATH}/lgsm/config-lgsm/sdtdserver/sdtdserver.cfg" + +# Get latest version (Removed until fix https://github.com/BepInEx/BepInEx/issues/592) +#DL_LINK=$(curl -L -s https://api.github.com/repos/BepInEx/BepInEx/releases/latest | grep -o -E "https://github.com/BepInEx/BepInEx/releases/download/(.*)/BepInEx_unix_(.*).zip") +DL_LINK="https://github.com/BepInEx/BepInEx/releases/download/v5.4.5/BepInEx_unix_5.4.5.0.zip" + +downloadRelease() { + curl "$DL_LINK" -SsL -o BepInEx.zip +} + +echo "[BepInEx] Downloading release from ${DL_LINK}" + +echo "[BepInEx] Downloading files" + +downloadRelease + +echo "[BepInEx] Extracting files" + +mkdir -p BepInEx-temp +unzip -q BepInEx.zip -d BepInEx-temp + +echo "[BepInEx] Removing older version" + +rm -rf $SERVERFILES_FOLDER/BepInEx +rm -rf $SERVERFILES_FOLDER/doorstop_libs + +echo "[BepInEx] Installing components" + +cp -a BepInEx-temp/. $SERVERFILES_FOLDER + +echo "[BepInEx] Editing run_bepinex.sh" + +echo "[BepInEx] Editing executable_name" + +if grep -q "7DaysToDieServer.x86_64" $BEPINEX_SH + then + echo "[BepInEx] Skiping executable_name changes, already replaced" + else + sed -i '/.*executable_name="".*/ s/""/"7DaysToDieServer.x86_64"/' $BEPINEX_SH +fi + +echo "[BepInEx] Editing command last execution" + +if grep -q "sdtdserver.xml" $BEPINEX_SH + then + sed -i '/.*config_file=""/ s/""/sdtdserver.xml/' $BEPINEX_SH + else + sed -i '/^.*NEEDED.*/a config_file="sdtdserver.xml"' $BEPINEX_SH + sed -i '/"${executable_path}"/ s/"${executable_path}"/"${executable_path}" -configfile=$config_file/' $BEPINEX_SH +fi + +echo "[BepInEx] Fixing executable_type" + +sed -i 's/executable_type=.*/executable_type=$(LD_PRELOAD="" file -b "${executable_path}")/' $BEPINEX_SH + +echo "[BepInEx] Replacing start parameters for LinuxGSM" + +if grep -q "startparameters" $LSGMSDTDSERVERCFG + then + sed -i 's/startparameters=.*/startparameters=""/' $LSGMSDTDSERVERCFG + else + echo startparameters='""' >> $LSGMSDTDSERVERCFG +fi + +echo "[BepInEx] Replacing executable for LinuxGSM" + +if grep -q "executable" $LSGMSDTDSERVERCFG + then + sed -i 's/executable=.*/executable=".\/run_bepinex.sh"/' $LSGMSDTDSERVERCFG + else + echo executable='"./run_bepinex.sh"' >> $LSGMSDTDSERVERCFG +fi + +echo "[BepInEx] Applying executable permssions" + +chmod u+x $BEPINEX_SH + +echo "[BepInEx] Cleanup" + +rm BepInEx.zip +rm -rf BepInEx-temp + +echo "[BepInEx] Finished! ヽ(´▽\`)/" \ No newline at end of file diff --git a/scripts/Mods/mods_install.sh b/scripts/Mods/mods_install.sh index ac203bc..2232b6c 100644 --- a/scripts/Mods/mods_install.sh +++ b/scripts/Mods/mods_install.sh @@ -39,3 +39,7 @@ if [ "${ENZOMBIES,,}" == 'yes' ] source $scriptsDir/Mods/enZombies.sh fi +if [ "${BEPINEX,,}" == 'yes' ] && [ "${UNDEAD_LEGACY,,}" == 'no' ] + then + source $scriptsDir/Mods/bepinex.sh +fi diff --git a/scripts/Mods/mods_update.sh b/scripts/Mods/mods_update.sh index 23977bc..32f842d 100644 --- a/scripts/Mods/mods_update.sh +++ b/scripts/Mods/mods_update.sh @@ -60,4 +60,9 @@ if [ "${ENZOMBIES,,}" == 'yes' ] && [ "${ENZOMBIES_UPDATE,,}" == 'yes' ] source $scriptsDir/Mods/enZombies.sh fi +if [ "${BEPINEX,,}" == 'yes' ] && [ "${BEPINEX_UPDATE,,}" == 'yes' ] && [ "${UNDEAD_LEGACY,,}" == 'no' ] + then + source $scriptsDir/Mods/bepinex.sh +fi + echo "[INFO] Updating/Installing mods finished" diff --git a/scripts/Mods/undead_legacy.sh b/scripts/Mods/undead_legacy.sh index aa1bde0..411cbcd 100644 --- a/scripts/Mods/undead_legacy.sh +++ b/scripts/Mods/undead_legacy.sh @@ -55,6 +55,13 @@ if [ "${MIRROR_EXT}" == 'tar' ]; then unzip -q "${MIRROR_FILE}" -d undeadlegacy-temp fi +if [ -d "$SERVERFILES_FOLDER/BepInEx" ] +then + echo "[Undead Legacy] Removing existing BepInEx, because Undead Legacy already come with BepInEx" + rm -rf $SERVERFILES_FOLDER/BepInEx + rm -rf $SERVERFILES_FOLDER/doorstop_libs +fi + echo "[Undead Legacy] Installing mod" if [ "${UNDEAD_LEGACY_VERSION}" == 'exp' ]; then