diff --git a/README.md b/README.md index cad749819..b947e7fec 100644 --- a/README.md +++ b/README.md @@ -197,45 +197,46 @@ It is highly recommended you set the following environment values before startin * PUID * PGID -| Variable | Info | Default Values | Allowed Values | -|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------|---------------------------------------------------------------------------------------| -| TZ | Timezone used for time stamping backup server | UTC | See [TZ Identifiers](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#Time_Zone_abbreviations) | -| PLAYERS* | Max amount of players that are able to join the server | 16 | 1-32 | -| PORT* | UDP port that the server will expose | 8211 | 1024-65535 | -| PUID* | The uid of the user the server should run as | 1000 | !0 | -| PGID* | The gid of the group the server should run as | 1000 | !0 | -| MULTITHREADING** | Improves performance in multi-threaded CPU environments. It is effective up to a maximum of about 4 threads, and allocating more than this number of threads does not make much sense. | false | true/false | -| COMMUNITY | Whether or not the server shows up in the community server browser (USE WITH SERVER_PASSWORD) | false | true/false | -| PUBLIC_IP | You can manually specify the global IP address of the network on which the server running. If not specified, it will be detected automatically. If it does not work well, try manual configuration. | | x.x.x.x | -| PUBLIC_PORT | You can manually specify the port number of the network on which the server running. If not specified, it will be detected automatically. If it does not work well, try manual configuration. | | 1024-65535 | -| SERVER_NAME | A name for your server | | "string" | -| SERVER_DESCRIPTION | Your server Description | | "string" | -| SERVER_PASSWORD | Secure your community server with a password | | "string" | -| ADMIN_PASSWORD | Secure administration access in the server with a password | | "string" | -| UPDATE_ON_BOOT** | Update/Install the server when the docker container starts (THIS HAS TO BE ENABLED THE FIRST TIME YOU RUN THE CONTAINER) | true | true/false | -| RCON_ENABLED*** | Enable RCON for the Palworld server | true | true/false | -| RCON_PORT | RCON port to connect to | 25575 | 1024-65535 | -| QUERY_PORT | Query port used to communicate with Steam servers | 27015 | 1024-65535 | -| BACKUP_CRON_EXPRESSION | Setting affects frequency of automatic backups. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | -| BACKUP_ENABLED | Enables automatic backups | true | true/false | -| DELETE_OLD_BACKUPS | Delete backups after a certain number of days | false | true/false | -| OLD_BACKUP_DAYS | How many days to keep backups | 30 | any positive integer | -| AUTO_UPDATE_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 \* \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | -| AUTO_UPDATE_ENABLED | Enables automatic updates | false | true/false | -| AUTO_UPDATE_WARN_MINUTES | How long to wait to update the server, after the player were informed. (This will be ignored, if no Players are connected) | 30 | !0 | -| AUTO_REBOOT_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-reboots-with-cron) | -| AUTO_REBOOT_ENABLED | Enables automatic reboots | false | true/false | -| AUTO_REBOOT_WARN_MINUTES | How long to wait to reboot the server, after the player were informed. | 5 | !0 | -| AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE | Restart the Server even if there are players online. | false | true/false | -| DISCORD_WEBHOOK_URL | Discord webhook url found after creating a webhook on a discord server | | `https://discord.com/api/webhooks/` | -| DISCORD_CONNECT_TIMEOUT | Discord command initial connection timeout | 30 | !0 | -| DISCORD_MAX_TIMEOUT | Discord total hook timeout | 30 | !0 | -| DISCORD_PRE_UPDATE_BOOT_MESSAGE | Discord message sent when server begins updating | Server is updating... | "string" | -| DISCORD_POST_UPDATE_BOOT_MESSAGE | Discord message sent when server completes updating | Server update complete! | "string" | -| DISCORD_PRE_START_MESSAGE | Discord message sent when server begins to start | Server is started! | "string" | -| DISCORD_PRE_SHUTDOWN_MESSAGE | Discord message sent when server begins to shutdown | Server is shutting down... | "string" | -| DISCORD_POST_SHUTDOWN_MESSAGE | Discord message sent when server has stopped | Server is stopped! | "string" | -| DISABLE_GENERATE_SETTINGS | Whether to automatically generate the PalWorldSettings.ini | false | true/false | +| Variable | Info | Default Values | Allowed Values | +|------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|-------------------------------------------------------------------------------------------------------------------| +| TZ | Timezone used for time stamping backup server | UTC | See [TZ Identifiers](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#Time_Zone_abbreviations) | +| PLAYERS* | Max amount of players that are able to join the server | 16 | 1-32 | +| PORT* | UDP port that the server will expose | 8211 | 1024-65535 | +| PUID* | The uid of the user the server should run as | 1000 | !0 | +| PGID* | The gid of the group the server should run as | 1000 | !0 | +| MULTITHREADING** | Improves performance in multi-threaded CPU environments. It is effective up to a maximum of about 4 threads, and allocating more than this number of threads does not make much sense. | false | true/false | +| COMMUNITY | Whether or not the server shows up in the community server browser (USE WITH SERVER_PASSWORD) | false | true/false | +| PUBLIC_IP | You can manually specify the global IP address of the network on which the server running. If not specified, it will be detected automatically. If it does not work well, try manual configuration. | | x.x.x.x | +| PUBLIC_PORT | You can manually specify the port number of the network on which the server running. If not specified, it will be detected automatically. If it does not work well, try manual configuration. | | 1024-65535 | +| SERVER_NAME | A name for your server | | "string" | +| SERVER_DESCRIPTION | Your server Description | | "string" | +| SERVER_PASSWORD | Secure your community server with a password | | "string" | +| ADMIN_PASSWORD | Secure administration access in the server with a password | | "string" | +| UPDATE_ON_BOOT** | Update/Install the server when the docker container starts (THIS HAS TO BE ENABLED THE FIRST TIME YOU RUN THE CONTAINER) | true | true/false | +| RCON_ENABLED*** | Enable RCON for the Palworld server | true | true/false | +| RCON_PORT | RCON port to connect to | 25575 | 1024-65535 | +| QUERY_PORT | Query port used to communicate with Steam servers | 27015 | 1024-65535 | +| BACKUP_CRON_EXPRESSION | Setting affects frequency of automatic backups. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | +| BACKUP_ENABLED | Enables automatic backups | true | true/false | +| DELETE_OLD_BACKUPS | Delete backups after a certain number of days | false | true/false | +| OLD_BACKUP_DAYS | How many days to keep backups | 30 | any positive integer | +| AUTO_UPDATE_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 \* \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-backups-with-cron) | +| AUTO_UPDATE_ENABLED | Enables automatic updates | false | true/false | +| AUTO_UPDATE_WARN_MINUTES | How long to wait to update the server, after the player were informed. (This will be ignored, if no Players are connected) | 30 | !0 | +| AUTO_REBOOT_CRON_EXPRESSION | Setting affects frequency of automatic updates. | 0 0 \* \* \* | Needs a Cron-Expression - See [Configuring Automatic Backups with Cron](#configuring-automatic-reboots-with-cron) | +| AUTO_REBOOT_ENABLED | Enables automatic reboots | false | true/false | +| AUTO_REBOOT_WARN_MINUTES | How long to wait to reboot the server, after the player were informed. | 5 | !0 | +| AUTO_REBOOT_EVEN_IF_PLAYERS_ONLINE | Restart the Server even if there are players online. | false | true/false | +| TARGET_MANIFEST_ID | Locks game version to corespond with Manfiest ID from Steam Download Depot. | | See [Manifest ID Table](#locking-specific-game-version) | +| DISCORD_WEBHOOK_URL | Discord webhook url found after creating a webhook on a discord server | | `https://discord.com/api/webhooks/` | +| DISCORD_CONNECT_TIMEOUT | Discord command initial connection timeout | 30 | !0 | +| DISCORD_MAX_TIMEOUT | Discord total hook timeout | 30 | !0 | +| DISCORD_PRE_UPDATE_BOOT_MESSAGE | Discord message sent when server begins updating | Server is updating... | "string" | +| DISCORD_POST_UPDATE_BOOT_MESSAGE | Discord message sent when server completes updating | Server update complete! | "string" | +| DISCORD_PRE_START_MESSAGE | Discord message sent when server begins to start | Server is started! | "string" | +| DISCORD_PRE_SHUTDOWN_MESSAGE | Discord message sent when server begins to shutdown | Server is shutting down... | "string" | +| DISCORD_POST_SHUTDOWN_MESSAGE | Discord message sent when server has stopped | Server is stopped! | "string" | +| DISABLE_GENERATE_SETTINGS | Whether to automatically generate the PalWorldSettings.ini | false | true/false | *highly recommended to set @@ -516,6 +517,24 @@ send discord messages with docker compose: - DISCORD_PRE_UPDATE_BOOT_MESSAGE=Server is updating... ``` +## Locking Specific Game Version + +>[!WARNING] +>Downgrading to a lower game version is possible, but it is unknown what impact it will have on existing saves. +> +>**Please do so at your own risk!** + +If **TARGET_MANIFEST_ID** environment variable is set, will lock server version to specific manifest. +The manifest corresponds to the release date/update versions. Manifests can be found using SteamCMD or websites like [SteamDB](https://steamdb.info/depot/2394012/manifests/). + +### Version To Manifest ID Table + +| Version | Manifest ID | +|---------|----------------------| +| 1.3.0 | 1354752814336157338 | +| 1.4.0 | 4190579964382773830 | +| 1.4.1 | 6370735655629434989 | + ## Reporting Issues/Feature Requests Issues/Feature requests can be submitted by using [this link](https://github.com/thijsvanloef/palworld-server-docker/issues/new/choose). diff --git a/docusaurus/docs/getting-started/configuration/game-settings.md b/docusaurus/docs/getting-started/configuration/game-settings.md index 2af0efa2c..5e268e47a 100644 --- a/docusaurus/docs/getting-started/configuration/game-settings.md +++ b/docusaurus/docs/getting-started/configuration/game-settings.md @@ -81,6 +81,7 @@ For example: | REGION | Region | | String | | USEAUTH | Use authentication | True | Boolean | | BAN_LIST_URL | Which ban list to use | [https://api.palworldgame.com/api/banlist.txt](https://api.palworldgame.com/api/banlist.txt) | string | +| TARGET_MANIFEST_ID | Locks game version to corespond with Manfiest ID from Steam Download Depot. | | See [Manifest ID Table](https://palworld-server-docker.loef.dev/guides/pinning-game-version) | ### Manually diff --git a/docusaurus/docs/guides/pinning-game-version.md b/docusaurus/docs/guides/pinning-game-version.md new file mode 100644 index 000000000..abcd4a4bc --- /dev/null +++ b/docusaurus/docs/guides/pinning-game-version.md @@ -0,0 +1,22 @@ +--- +sidebar_position: 7 +--- + +# Pinning a Game Version + +:::warning +Downgrading to a lower game version is possible, but it is unknown what impact it will have on existing saves. + +**Please do so at your own risk!** +::: + +If **TARGET_MANIFEST_ID** environment variable is set, will lock server version to specific manifest. +The manifest corresponds to the release date/update versions. Manifests can be found using SteamCMD or websites like [SteamDB](https://steamdb.info/depot/2394012/manifests/). + +## Version To Manifest ID Table + +| Version | Manifest ID | +|---------|----------------------| +| 1.3.0 | 1354752814336157338 | +| 1.4.0 | 4190579964382773830 | +| 1.4.1 | 6370735655629434989 | diff --git a/scripts/helper_functions.sh b/scripts/helper_functions.sh index 85b69f513..41921f1c7 100644 --- a/scripts/helper_functions.sh +++ b/scripts/helper_functions.sh @@ -131,58 +131,9 @@ DiscordMessage() { # RCON Call RCON() { local args="$1" - echo rcon-cli -c /home/steam/server/rcon.yaml "$args" + rcon-cli -c /home/steam/server/rcon.yaml "$args" } - -# Returns 0 if Update Required -# Returns 1 if Update NOT Required -# Returns 2 if Check Failed -UpdateRequired() { -LogAction "Checking for new update" - -temp_file=$(mktemp) -http_code=$(curl https://api.steamcmd.net/v1/info/2394010 --output "$temp_file" --silent --location --write-out "%{http_code}") -TARGET_MANIFEST=$(grep -Po '"2394012".*"gid": "\d+"' <"$temp_file" | sed -r 's/.*("[0-9]+")$/\1/') - -CURRENT_MANIFEST=$(awk '/manifest/{count++} count==2 {print $2; exit}' /palworld/steamapps/appmanifest_2394010.acf) -rm "$temp_file" - -if [ "$http_code" -ne 200 ]; then - LogError "There was a problem reaching the Steam api. Unable to check for updates!" - DiscordMessage "There was a problem reaching the Steam api. Unable to check for updates!" "failure" - return 2 -fi - -if [ -z "$TARGET_MANIFEST" ]; then - LogError "The server response does not contain the expected BuildID. Unable to check for updates!" - DiscordMessage "Steam servers response does not contain the expected BuildID. Unable to check for updates!" "failure" - return 2 -fi - -if [ "$CURRENT_MANIFEST" != "$TARGET_MANIFEST" ]; then - LogInfo "An Update Is Available." - LogInfo "Current Version: $CURRENT_MANIFEST" - LogInfo "Latest Version: $TARGET_MANIFEST." - return 0 -fi - -LogSuccess "The Server is up to date!" -return 1 - -} - -InstallServer() { - DiscordMessage "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" "in-progress" - /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit - DiscordMessage "${DISCORD_POST_UPDATE_BOOT_MESSAGE}" "success" -} - -# Returns 0 if game is installed -# Returns 1 if game is not installed -IsInstalled() { - if [ -e /palworld/PalServer.sh ] && [ -e /palworld/steamapps/appmanifest_2394010.acf ]; then - return 0 - fi - return 1 -} \ No newline at end of file +# Helper Functions for installation & updates +# shellcheck source=/dev/null +source "/home/steam/server/helper_install.sh" \ No newline at end of file diff --git a/scripts/helper_install.sh b/scripts/helper_install.sh new file mode 100644 index 000000000..268ed4180 --- /dev/null +++ b/scripts/helper_install.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# This file contains functions which can be used in multiple scripts + +# Returns 0 if game is installed +# Returns 1 if game is not installed +IsInstalled() { + if [ -e /palworld/PalServer.sh ] && [ -e /palworld/steamapps/appmanifest_2394010.acf ]; then + return 0 + fi + return 1 +} +CreateACFFile() { + local manifestId="$1" +cat > /palworld/steamapps/appmanifest_2394010.acf << EOL +"AppState" { + "appid" "2394010" + "Universe" "1" + "name" "Palworld Dedicated Server" + "StateFlags" "4" + "installdir" "PalServer" + "StagingSize" "0" + "buildid" "13378465" + "UpdateResult" "0" + "TargetBuildID" "0" + "AutoUpdateBehavior" "0" + "AllowOtherDownloadsWhileRunning" "0" + "ScheduledAutoUpdate" "0" + "InstalledDepots" + { + "1006" + { + "manifest" "4884950798805348056" + } + "2394012" + { + "manifest" "${manifestId}" + } + } + "UserConfig" + { + } + "MountedConfig" + { + } +} +EOL + +} +# Returns 0 if Update Required +# Returns 1 if Update NOT Required +# Returns 2 if Check Failed +UpdateRequired() { + LogAction "Checking for new update" + + #define local variables + local CURRENT_MANIFEST LATEST_MANIFEST temp_file http_code updateAvailable + + #check steam for latest version + temp_file=$(mktemp) + http_code=$(curl https://api.steamcmd.net/v1/info/2394010 --output "$temp_file" --silent --location --write-out "%{http_code}") + + if [ "$http_code" -ne 200 ]; then + LogError "There was a problem reaching the Steam api. Unable to check for updates!" + DiscordMessage "There was a problem reaching the Steam api. Unable to check for updates!" "failure" + return 2 + fi + + # Parse temp file for manifest id + LATEST_MANIFEST=$(grep -Po '"2394012".*"gid": "\d+"' <"$temp_file" | sed -r 's/.*("[0-9]+")$/\1/' | tr -d '"') + rm "$temp_file" + + if [ -z "$LATEST_MANIFEST" ]; then + LogError "The server response does not contain the expected BuildID. Unable to check for updates!" + DiscordMessage "Steam servers response does not contain the expected BuildID. Unable to check for updates!" "failure" + return 2 + fi + + # Parse current manifest from steam files + CURRENT_MANIFEST=$(awk '/manifest/{count++} count==2 {print $2; exit}' /palworld/steamapps/appmanifest_2394010.acf | tr -d '"') + LogInfo "Current Version: $CURRENT_MANIFEST" + + # Log any updates available + local updateAvailable=false + if [ "$CURRENT_MANIFEST" != "$LATEST_MANIFEST" ]; then + LogInfo "An Update Is Available. Latest Version: $LATEST_MANIFEST." + updateAvailable=true + fi + + # No TARGET_MANIFEST_ID env set & update needed + if [ "$updateAvailable" == true ] && [ -z "${TARGET_MANIFEST_ID}" ]; then + return 0 + fi + + if [ "$CURRENT_MANIFEST" != "${TARGET_MANIFEST_ID}" ]; then + LogInfo "Game not at target version. Target Version: ${TARGET_MANIFEST_ID}" + return 0 + fi + + # Warn if version is locked + if [ "$updateAvailable" == false ]; then + LogSuccess "The Server is up to date!" + return 1 + fi + + if [ -n "${TARGET_MANIFEST_ID}" ]; then + LogWarn "Unable to update. Locked by TARGET_MANIFEST_ID." + return 1 + fi +} + +InstallServer() { + + if [ -z "${TARGET_MANIFEST_ID}" ]; then + DiscordMessage "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" "in-progress" + /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit + DiscordMessage "${DISCORD_POST_UPDATE_BOOT_MESSAGE}" "success" + return + fi + + local targetManifest + targetManifest="${TARGET_MANIFEST_ID}" + + LogWarn "Installing Target Version: $targetManifest" + DiscordMessage "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" "in-progress" + /home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +download_depot 2394010 2394012 "$targetManifest" +quit + cp -vr "/home/steam/steamcmd/linux32/steamapps/content/app_2394010/depot_2394012/." "/palworld/" + CreateACFFile "$targetManifest" + DiscordMessage "${DISCORD_POST_UPDATE_BOOT_MESSAGE}" "success" +}