Automatisches Update – Überarbeitet am 15.08.2015

Dieses Thema im Forum "Neuigkeiten" wurde erstellt von Nakusha, 4. März 2016.

  1. Nakusha

    Nakusha Stammi

    Beiträge:
    409
    Punkte für Erfolge:
    20
    Da die fleißigen ARK-Entwickler ihre Updates in sehr kurzen Intervallen veröffentlichen, sollte euch folgendes Skript als Serveradministrator hoffentlich stark entlasten. Dieses wurde mit Hilfe der Windows PowerShell erstellt und benötigt dieses mindestens in der Version 3.0! Es warnt die Spieler vor dem Update und lässt ihnen 10 Minuten Zeit sich in Sicherheit zu bringen.

    Systemvoraussetungen

    • PowerShell 3.0 oder höher: für 2008 R2 oder Windows 7 könnt ihr dieses hier herunterladen.
    • mcrcon
    • Steamcmd
    Installation


    Speichert diesen Text als update.cmd ab


    @echo off
    ver | find "2003" > nul
    if %ERRORLEVEL% == 0 goto ver_2003

    if not exist "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" goto install

    "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" -command "exit $PSVersionTable.PSVersion.Major"
    set PSVer=%ERRORLEVEL%
    if %PSVer% LSS 3 goto ps1

    powershell -ExecutionPolicy unrestricted -File "%~dp0mainscript.ps1"

    exit

    :ps1
    echo Powershell 2 is not supported.
    pause
    exit

    :ver_2003
    echo Windows 2003 is not supported.
    pause
    exit

    :install
    echo PowerShell is not installed
    pause
    exit




    Speichert diesen Text als mainscript.ps1 ab


    $steamcmdFolder="C:\steamcmd"
    $arksurvivalFolder="C:\arkserver"
    $arksurvivalSteamScript="update_ark.txt"
    $rconIP="127.0.0.1"
    $rconPort=32330
    $rconPassword="YOURPASSWORD"
    $arkSurvivalStartArguments=$("TheIsland?QueryPort=27015?Port=7777?SetCheatPlayer=True?RCONEnabled=True?RCONPort="+$rconPort+"?listen")
    $mcrconExec="C:\ARK-Scripts\mcrcon.exe"
    $steamAppID="376030"
    # Without clearing cache app_info_update may return old informations!
    $clearCache=1

    $scriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition
    $dataPath = $scriptPath+"\data"
    $steamcmdExec = $steamcmdFolder+"\steamcmd.exe"
    $steamcmdCache = $steamcmdFolder+"\appcache"
    $latestAppInfo = $dataPath+"\latestappinfo.json"
    $updateinprogress = $arksurvivalFolder+"\updateinprogress.dat"
    $latestAvailableUpdate = $dataPath+"\latestavailableupdate.txt"
    $latestInstalledUpdate = $dataPath+"\latestinstalledupdate.txt"
    If (Test-Path $updateinprogress) {
    Write-Host Update is already in progress
    } Else {
    Get-Date | Out-File $updateinprogress
    Write-Host Creating data Directory
    New-Item -Force -ItemType directory -Path $dataPath
    If ($clearCache) {
    Write-Host Removing Cache Folder
    Remove-Item $steamcmdCache -Force -Recurse
    }
    Write-Host Checking for an update
    & $steamcmdExec +login anonymous +app_info_update 1 +app_info_print $steamAppID +app_info_print $steamAppID +quit | Out-File $latestAppInfo
    Get-Content $latestAppInfo -RAW | Select-String -pattern '(?m)"public"\s*\{\s*"buildid"\s*"\d{6,}"' -AllMatches | %{$_.matches[0].value} | Select-String -pattern '\d{6,}' -AllMatches | %{$_.matches} | %{$_.value} | Out-File $latestAvailableUpdate
    If (Test-Path $latestInstalledUpdate) {
    $installedVersion = Get-Content $latestInstalledUpdate
    } Else {
    $installedVersion = 0
    }
    $availableVersion = Get-Content $latestAvailableUpdate
    if ($installedVersion -ne $availableVersion) {
    Write-Host Update Available
    Write-Host Installed build: $installedVersion - available build: $availableVersion
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast New update available, server is restarting in 10 minutes!"
    Start-Sleep -s 300
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast New update available, server is restarting in 5 minutes!"
    Start-Sleep -s 240
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast New update available, server is restarting in 1 minute!"
    Start-Sleep -s 60
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast New update available, server is restarting!"
    & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "saveworld"
    Start-Sleep -s 10
    #Does not work atm
    # & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "quit"
    $pidARK = (Wmic process where "Commandline like '%$rconPort%' and Name='ShooterGameServer.exe'" get ProcessId | findstr /r "[1-9][0-9]")
    & taskkill /PID $pidARK
    Start-Sleep -s 20
    & $steamcmdExec +runscript $arksurvivalSteamScript
    & $arksurvivalFolder"\ShooterGame\Binaries\Win64\ShooterGameServer.exe" $arkSurvivalStartArguments -nosteamclient -game -lowmemory -nosound -sm4 -server -log
    $availableVersion | Out-File $latestInstalledUpdate
    Write-Host Update Done!
    }
    Remove-Item $updateinprogress -Force
    }


    Ein Beispiel meines Steam Skripts (dieses sollte im steamCMD Verzeichnis liegen!):



    //ark
    @ShutdownOnFailedCommand 1
    @NoPromptForPassword 1
    nSubscribedAutoDownloadMaxSimultaneous 32
    @cMaxContentServersToRequest 16
    @cMaxInitialDownloadSources 1
    @fMinDataRateToAttemptTwoConnectionsMbps 0.01
    @fDownloadRateImprovementToAddAnotherConnection 0.01
    login anonymous
    force_install_dir C:\arkserver\
    app_update 376030
    // validate
    quit
    Wie Benutze ich es?


    Ein paar Kenntnisse in der Powershell sollten schon vorhanden sein, diese Grundlagen können wir euch leider nicht beibringen. Passt die Variablen im oberen Bereich der mainscript.ps1 an, so dass diese mit eure Windowsumgebung funktionieren. Um es regelmäßig auszuführen, könnt ihr die update.cmd einfach in die Aufgabenplanung hinzufügen.



    Der Beitrag Automatisches Update – Überarbeitet am 15.08.2015 erschien zuerst auf ARK: Survival Evolved.

    Weiterlesen...
     

Diese Seite empfehlen