Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor InstallServer function to integrate DepotDownloader better #664

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
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
Expand Down Expand Up @@ -86,7 +86,7 @@
&& mv DepotDownloader /usr/local/bin/DepotDownloader

# hadolint ignore=DL3044
ENV HOME=/home/steam \

Check warning on line 89 in Dockerfile

View workflow job for this annotation

GitHub Actions / Container - Scan

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "ADMIN_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 89 in Dockerfile

View workflow job for this annotation

GitHub Actions / Container - Scan

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SERVER_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 89 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker - Test (amd64)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SERVER_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 89 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker - Test (amd64)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "ADMIN_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 89 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker - Test (arm64)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "SERVER_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 89 in Dockerfile

View workflow job for this annotation

GitHub Actions / Docker - Test (arm64)

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "ADMIN_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
PORT= \
PUID=1000 \
PGID=1000 \
Expand Down
125 changes: 87 additions & 38 deletions scripts/helper_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ cat > /palworld/steamapps/appmanifest_2394010.acf << EOL
EOL

}

GetManifestIdDepotDownloader() {
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
}

# Returns 0 if Update Required
# Returns 1 if Update NOT Required
# Returns 2 if Check Failed
Expand Down Expand Up @@ -125,51 +143,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

Expand All @@ -186,15 +229,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}"
}
27 changes: 9 additions & 18 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +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

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
Expand All @@ -74,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"
Expand Down
Loading