From 8125efa5b64bbebfe3be98a6dbc346593d7b34b1 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Sun, 19 Jan 2025 21:40:01 +0000 Subject: [PATCH 1/4] update depotdownloader and refactor install function to always fallback to depotdownloader --- Dockerfile | 2 +- scripts/helper_install.sh | 123 ++++++++++++++++++++++++++------------ scripts/start.sh | 5 ++ 3 files changed, 91 insertions(+), 39 deletions(-) diff --git a/Dockerfile b/Dockerfile index b853c5ca..16eca6ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ LABEL maintainer="thijs@loef.dev" \ ARG SUPERCRONIC_SHA1SUM_ARM64="e0f0c06ebc5627e43b25475711e694450489ab00 " ARG SUPERCRONIC_SHA1SUM_AMD64="71b0d58cc53f6bd72cf2f293e09e294b79c666d8 " ARG SUPERCRONIC_VERSION="0.2.33" -ARG DEPOT_DOWNLOADER_VERSION="2.7.4" +ARG DEPOT_DOWNLOADER_VERSION="3.0.0" # update and install dependencies # hadolint ignore=DL3008 diff --git a/scripts/helper_install.sh b/scripts/helper_install.sh index 13fe9613..2718fa0b 100644 --- a/scripts/helper_install.sh +++ b/scripts/helper_install.sh @@ -49,6 +49,22 @@ cat > /palworld/steamapps/appmanifest_2394010.acf << EOL EOL } + +GetManifestIdDepotDownloader() { + local directory="$1" + local filename=$(ls -1 "$directory" | head -n 1) + + if [ -z "$filename" ]; then + echo "No file found in directory" >&2 + return 1 + fi + + local temp=${filename#manifest_*_} + local manifest_id=${temp%%.*} + + echo "$manifest_id" +} + # Returns 0 if Update Required # Returns 1 if Update NOT Required # Returns 2 if Check Failed @@ -125,51 +141,76 @@ InstallServer() { kernel_page_size=$(getconf PAGESIZE) # Check kernel page size for arm64 hosts before running steamcmd - if [ "$architecture" == "arm64" ] && [ "$kernel_page_size" != "4096" ] && [ "${USE_DEPOT_DOWNLOADER}" != true ]; then - LogWarn "WARNING: Only ARM64 hosts with 4k page size is supported when running steamcmd. Please set USE_DEPOT_DOWNLOADER to true." + if [ "$architecture" == "arm64" ] && [ "$kernel_page_size" != "4096" ]; then + LogWarn "WARNING: ARM64 host detected with non-4k page size. Forcing DepotDownloader usage." + USE_DEPOT_DOWNLOADER=true fi + UseSteamCmd() { + if [ "${1}" == "beta" ]; then + if /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 -beta insiderprogram validate +quit; then + return 0 + fi + elif [ -n "${2}" ]; then + if /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login "${STEAM_USERNAME}" "${STEAM_PASSWORD}" +download_depot 2394010 2394012 "${2}" +quit; then + if cp -vr "/home/steam/steamcmd/linux32/steamapps/content/app_2394010/depot_2394012/." "/palworld/"; then + return 0 + fi + fi + else + if /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit; then + return 0 + fi + fi + return 1 + } + + UseDepotDownloader() { + local beta="${1}" + local manifest="${2}" + mkdir -p /palworld/steamapps/ + + if [ -n "$manifest" ]; then + DepotDownloader -app 2394010 -username "${STEAM_USERNAME}" -password "${STEAM_PASSWORD}" -depot 2394012 -manifest "$manifest" -os linux -osarch 64 -dir /palworld -validate + elif [ "$beta" == "beta" ]; then + DepotDownloader -app 2394010 -os linux -osarch 64 -dir /palworld -branch insiderprogram -validate + DepotDownloader -app 2394010 -depot 2394012 -osarch 64 -dir /palworld/.manifest -branch insiderprogram -manifest-only + manifest=$(GetManifestIdDepotDownloader "/palworld/.manifest") + else + DepotDownloader -app 2394010 -os linux -osarch 64 -dir /palworld -validate + DepotDownloader -app 2394010 -depot 2394012 -osarch 64 -dir /palworld/.manifest -manifest-only + manifest=$(GetManifestIdDepotDownloader "/palworld/.manifest") + fi + + CreateACFFile "$manifest" + rm -rf /palworld/.manifest + } + if [ -z "${TARGET_MANIFEST_ID}" ]; then DiscordMessage "Install" "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" "in-progress" "${DISCORD_PRE_UPDATE_BOOT_MESSAGE_ENABLED}" "${DISCORD_PRE_UPDATE_BOOT_MESSAGE_URL}" - ## If INSTALL_BETA_INSIDER is set to true, install the latest beta version + if [ "${INSTALL_BETA_INSIDER}" == true ]; then LogWarn "Installing latest beta version" if [ "${USE_DEPOT_DOWNLOADER}" == true ]; then - LogWarn "Downloading server files using DepotDownloader" - DepotDownloader -app 2394010 -osarch 64 -dir /palworld -beta insiderprogram -validate - DepotDownloader -app 2394010 -depot 2394012 -osarch 64 -dir /tmp -beta insiderprogram -manifest-only + LogWarn "Downloading server files with DepotDownloader" + UseDepotDownloader "beta" else - /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 -beta insiderprogram validate +quit + LogWarn "Downloading server files with SteamCMD" + if ! UseSteamCmd "beta"; then + LogWarn "SteamCMD failed, falling back to DepotDownloader" + UseDepotDownloader "beta" + fi fi else if [ "${USE_DEPOT_DOWNLOADER}" == true ]; then - LogWarn "Downloading server files using DepotDownloader" - DepotDownloader -app 2394010 -osarch 64 -dir /palworld -validate - DepotDownloader -app 2394010 -depot 2394012 -osarch 64 -dir /tmp -manifest-only - else - /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit - fi - fi - - # Create ACF file for DepoDownloader downloads for script compatibility - if [ "${USE_DEPOT_DOWNLOADER}" == true ]; then - local manifestFile - manifestFile=$(find /tmp -type f -name "manifest_2394012_*.txt" | head -n 1) - - if [ -z "$manifestFile" ]; then - echo "DepotDownloader manifest file not found." + LogWarn "Downloading server files with DepotDownloader" + UseDepotDownloader else - local manifestId - manifestId=$(grep -oP 'Manifest ID / date\s*:\s*\K[0-9]+' "$manifestFile") - - if [ -z "$manifestId" ]; then - echo "Manifest ID not found in DepotDownloader manifest file." - else - mkdir -p /palworld/steamapps - CreateACFFile "$manifestId" + LogWarn "Downloading server files with SteamCMD" + if ! UseSteamCmd; then + LogWarn "SteamCMD failed, falling back to DepotDownloader" + UseDepotDownloader fi - - rm -rf "$manifestFile" fi fi @@ -186,15 +227,21 @@ InstallServer() { DiscordMessage "Install" "STEAM_USERNAME or STEAM_PASSWORD is not set. Please set these variables to install a specific version." "failure" return 2 fi + DiscordMessage "Install" "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" "in-progress" "${DISCORD_PRE_UPDATE_BOOT_MESSAGE_ENABLED}" "${DISCORD_PRE_UPDATE_BOOT_MESSAGE_URL}" + if [ "${USE_DEPOT_DOWNLOADER}" == true ]; then - LogWarn "Downloading server files using DepotDownloader" - DepotDownloader -app 2394010 -username "${STEAM_USERNAME}" -password "${STEAM_PASSWORD}" -depot 2394012 -manifest "$targetManifest" -osarch 64 -dir /palworld -validate - DepotDownloader -app 2394010 -username "${STEAM_USERNAME}" -password "${STEAM_PASSWORD}" -depot 1006 -osarch 64 -dir /palworld -validate + LogWarn "Downloading server files with DepotDownloader" + UseDepotDownloader "" "$targetManifest" else - /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login "${STEAM_USERNAME}" "${STEAM_PASSWORD}" +download_depot 2394010 2394012 "$targetManifest" +quit - cp -vr "/home/steam/steamcmd/linux32/steamapps/content/app_2394010/depot_2394012/." "/palworld/" + LogWarn "Downloading server files with SteamCMD" + if ! UseSteamCmd "" "$targetManifest"; then + LogWarn "SteamCMD failed, falling back to DepotDownloader" + UseDepotDownloader "" "$targetManifest" + else + CreateACFFile "$targetManifest" + fi fi - CreateACFFile "$targetManifest" + DiscordMessage "Install" "${DISCORD_POST_UPDATE_BOOT_MESSAGE}" "success" "${DISCORD_POST_UPDATE_BOOT_MESSAGE_ENABLED}" "${DISCORD_POST_UPDATE_BOOT_MESSAGE_URL}" } diff --git a/scripts/start.sh b/scripts/start.sh index d6d4d484..89815533 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -41,6 +41,11 @@ if [ "$architecture" == "arm64" ]; then unset USE_DEPOT_DOWNLOADER fi + if ! fileExists "./PalServer.sh"; then + LogError "Critical server files are missing after installation attempts." + exit 1 + fi + cp ./PalServer.sh ./PalServer-arm64.sh sed -i "s|\(\"\$UE_PROJECT_ROOT\/Pal\/Binaries\/Linux\/PalServer-Linux-Shipping\" Pal \"\$@\"\)|LD_LIBRARY_PATH=/home/steam/steamcmd/linux64:\$LD_LIBRARY_PATH /usr/local/bin/box64 \1|" ./PalServer-arm64.sh From fd08274e1c4181f37274d7b244942797fe7ce1e2 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Sun, 19 Jan 2025 22:04:54 +0000 Subject: [PATCH 2/4] remove depotdownloader retry on start --- scripts/start.sh | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/scripts/start.sh b/scripts/start.sh index 89815533..77674aa6 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -29,37 +29,23 @@ if [ "$ServerInstalled" == 0 ] && [ "${UPDATE_ON_BOOT,,}" == true ]; then InstallServer fi +STARTCOMMAND=("./PalServer.sh") + +#Validate Installation +if ! fileExists "${STARTCOMMAND[0]}"; then + LogError "Server Not Installed Properly" + exit 1 +fi + # Check if the architecture is arm64 if [ "$architecture" == "arm64" ]; then # create an arm64 version of ./PalServer.sh - if ! fileExists "./PalServer.sh" && [ "${USE_DEPOT_DOWNLOADER,,}" != true ]; then - LogInfo "SteamCMD failed to download the server properly, attempting to use DepotDownloader." - export USE_DEPOT_DOWNLOADER=true - InstallServer - - # reset env var after installation - unset USE_DEPOT_DOWNLOADER - fi - - if ! fileExists "./PalServer.sh"; then - LogError "Critical server files are missing after installation attempts." - exit 1 - fi cp ./PalServer.sh ./PalServer-arm64.sh sed -i "s|\(\"\$UE_PROJECT_ROOT\/Pal\/Binaries\/Linux\/PalServer-Linux-Shipping\" Pal \"\$@\"\)|LD_LIBRARY_PATH=/home/steam/steamcmd/linux64:\$LD_LIBRARY_PATH /usr/local/bin/box64 \1|" ./PalServer-arm64.sh chmod +x ./PalServer-arm64.sh STARTCOMMAND=("./PalServer-arm64.sh") -else - STARTCOMMAND=("./PalServer.sh") -fi - - -#Validate Installation -if ! fileExists "${STARTCOMMAND[0]}"; then - LogError "Server Not Installed Properly" - exit 1 fi isReadable "${STARTCOMMAND[0]}" || exit From 4b4c0e9b07d7f53e68b5e3578856b4e437eff927 Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Sun, 19 Jan 2025 22:31:23 +0000 Subject: [PATCH 3/4] add NumberOfWorkerThreadsServer argument to maximize multithreading --- scripts/start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/start.sh b/scripts/start.sh index 77674aa6..8c9a7f59 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -65,7 +65,7 @@ if [ "${COMMUNITY,,}" = true ]; then fi if [ "${MULTITHREADING,,}" = true ]; then - STARTCOMMAND+=("-useperfthreads" "-NoAsyncLoadingThread" "-UseMultithreadForDS") + STARTCOMMAND+=("-useperfthreads" "-NoAsyncLoadingThread" "-UseMultithreadForDS" "-NumberOfWorkerThreadsServer=$(nproc --all)") fi LogAction "Checking for available container updates" From 3332421edeec3024078ae29f678278f4275d750c Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Sun, 19 Jan 2025 23:17:29 +0000 Subject: [PATCH 4/4] fix retrieval of manifest id from depot downloader --- scripts/helper_install.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/helper_install.sh b/scripts/helper_install.sh index 2718fa0b..92cf5ad2 100644 --- a/scripts/helper_install.sh +++ b/scripts/helper_install.sh @@ -51,18 +51,20 @@ EOL } GetManifestIdDepotDownloader() { - local directory="$1" - local filename=$(ls -1 "$directory" | head -n 1) - - if [ -z "$filename" ]; then - echo "No file found in directory" >&2 + local depotManifestDirectory="$1" + local manifestFile + manifestFile=$(find "$depotManifestDirectory" -type f -name "manifest_2394012_*.txt" | head -n 1) + + if [ -z "$manifestFile" ]; then + echo "DepotDownloader manifest file not found." return 1 + + else + local manifestId + manifestId=$(grep -oP 'Manifest ID / date\s*:\s*\K[0-9]+' "$manifestFile") + + echo "$manifestId" fi - - local temp=${filename#manifest_*_} - local manifest_id=${temp%%.*} - - echo "$manifest_id" } # Returns 0 if Update Required