From 130d665f1a07a24923e18be2354bfceffcddb693 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Fri, 16 Oct 2015 21:02:42 +1000 Subject: [PATCH] Add support for downloading updates before applying --- tools/arkmanager | 70 ++++++++++++++++++++++++++++++++++++-------- tools/arkmanager.cfg | 1 + 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/tools/arkmanager b/tools/arkmanager index 14bcbf5..8c7ed59 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -749,6 +749,7 @@ doUpdate() { local validate= local modupdate= local saveworld= + local downloadonly= for arg in "$@"; do if [ "$arg" == "--force" ]; then @@ -766,6 +767,10 @@ doUpdate() { modupdate=1 elif [ "$arg" == "--backup" ]; then arkBackupPreUpdate=true + elif [ "$arg" =~ "^--stagingdir=" ]; then + arkStagingDir="${ark#--stagingdir=}" + elif [ "$arg" == "--downloadonly" ]; then + downloadonly=1 fi done @@ -782,9 +787,37 @@ doUpdate() { if isUpdateNeeded; then appupdate=1 + + if [ -n "${arkStagingDir}" -a "${arkStagingDir}" != "${arkserverroot}" ]; then + if [ ! -d "$arkStagingDir/ShooterGame" ]; then + cp -al "$arkserverroot/ShooterGame/." "$arkStagingDir/ShooterGame" + cp -al "$arkserverroot/Engine/." "$arkStagingDir/Engine" + cp -al "$arkserverroot/linux64/." "$arkStagingDir/linux64" + cp -al "$arkserverroot/PackageInfo.bin" "$arkStagingDir/PackageInfo.bin" + cp -al "$arkserverroot/steamclient.so" "$arkStagingDir/steamclient.so" + cp -a "$arkserverroot/steamapps/." "$arkStagingDir/steamapps" + rm -rf "$arkStagingDir/ShooterGame/Content/Mods/"* + rm -rf "$arkStagingDir/ShooterGame/Saved/"* + fi + + cd "$steamcmdroot" + ./$steamcmdexec +@NoPromptForPassword 1 +login ${steamlogin:-anonymous} +force_install_dir "$arkStagingDir" +app_update $appid $validate +quit + if [ -d "${arkStagingDir}/steamapps/downloading/${appid}" ]; then + echo "Update download interrupted" + return 1 + fi + fi fi - if [ -n "$appupdate" -o -n "$modupdate" ]; then + if [ -n "$downloadonly" ]; then + if [ -n "$appupdate" -a -n "$arkStagingDir" -a "$arkStagingDir" != "$arkserverroot" ]; then + echo "Server update downloaded" + fi + if [ -n "$modupdate" ]; then + echo "Mod update downloaded" + fi + echo "Not applying update - download-only enabled" + elif [ -n "$appupdate" -o -n "$modupdate" ]; then if isTheServerRunning; then if [ "$updatetype" == "safe" ]; then while [ ! `find $arkserverroot/ShooterGame/Saved/SavedArks -mmin -1 -name ${serverMap##*/}.ark` ]; do @@ -811,16 +844,25 @@ doUpdate() { fi doStop - + # If user wants to back-up, we do it here. - + if [ "$arkBackupPreUpdate" == "true" ]; then doBackup fi if [ -n "$appupdate" ]; then - cd "$steamcmdroot" - ./$steamcmdexec +@NoPromptForPassword 1 +login ${steamlogin:-anonymous} +force_install_dir "$arkserverroot" +app_update $appid $validate +quit + if [ -d "${arkStagingDir}" -a "${arkStagingDir}" != "${arkserverroot}" ]; then + cp -alu --remove-destination "$arkStagingDir/ShooterGame/." "$arkserverroot/ShooterGame" + cp -alu --remove-destination "$arkStagingDir/Engine/." "$arkserverroot/Engine" + cp -alu --remove-destination "$arkStagingDir/linux64/." "$arkserverroot/linux64" + cp -alu --remove-destination "$arkStagingDir/PackageInfo.bin" "$arkserverroot/PackageInfo.bin" + cp -alu --remove-destination "$arkStagingDir/steamclient.so" "$arkserverroot/steamclient.so" + cp -au --remove-destination "$arkStagingDir/steamapps/." "$arkserverroot/steamapps" + else + cd "$steamcmdroot" + ./$steamcmdexec +@NoPromptForPassword 1 +login ${steamlogin:-anonymous} +force_install_dir "$arkserverroot" +app_update $appid $validate +quit + fi # the current version should be the last version. We set our version getCurrentVersion echo "`timestamp`: update to $instver complete" >> "$logdir/update.log" @@ -834,7 +876,7 @@ doUpdate() { fi done fi - + # we restart the server only if it was started before the update if [ $serverWasAlive -eq 1 ]; then doStart @@ -1365,13 +1407,15 @@ while true; do echo "useconfig Use the configuration overrides in the specified config name or file" echo echo "Update command takes the below options:" - echo " --force Apply update without checking the current version" - echo " --safe Wait for server to perform world save and update." - echo " --warn Warn players before updating server" - echo " --validate Validates all ARK server files" - echo " --saveworld Saves world before update" - echo " --update-mods Updates installed and requested mods" - echo " --backup Takes a backup of the save files before updating" + echo " --force Apply update without checking the current version" + echo " --safe Wait for server to perform world save and update." + echo " --warn Warn players before updating server" + echo " --validate Validates all ARK server files" + echo " --saveworld Saves world before update" + echo " --update-mods Updates installed and requested mods" + echo " --backup Takes a backup of the save files before updating" + echo " --downloadonly Download the mod and/or server update without applying it" + echo " Requires arkStagingDir be set to a staging directory on the same filesystem as the server" exit 1 ;; *) diff --git a/tools/arkmanager.cfg b/tools/arkmanager.cfg index b2a174f..22ef80d 100644 --- a/tools/arkmanager.cfg +++ b/tools/arkmanager.cfg @@ -18,6 +18,7 @@ arkwarnminutes="60" # number of arkautorestartfile="ShooterGame/Saved/.autorestart" # path to autorestart file arkBackupPreUpdate="false" # set this to true if you want to perform a backup before updating arkTimeToKeepBackupFiles="10" #Set to Automatically Remove backups older than n days +#arkStagingDir="/home/steam/ARK-Staging" # Uncomment to enable downloading updates before restarting the server # Update warning messages # Modify as desired, putting the %d replacement operator where the number belongs