# PowerShell Kill Process Clear-Host $ShooterGameprocess = Get-Process ShooterGameServer #CHANGE ME - Folder where SteamCMD is: $steamcmdFolder="X:\SERVER\steamcmd" #CHANGE ME - Folder for Ark Survival eveloved $arksurvivalFolder="X:\SERVER\ARK" #not used anymore as the update is done in this script $arksurvivalSteamScript="update_ark.txt" #CHANGE ME - Startup arguments for the server $arkSurvivalStartArguments="TheIsland?QueryPort=27015?MultiHome=meindyndnsname?RCONEnabled=true?RCONPort=32330?MaxPlayers=10?Port=7777?listen -nosteamclient -game -server -log" #CHANGE ME - path to mrcon.exe $mcrconExec="X:\server\mcrcon\mcrcon.exe" #CHANGE ME -RCON IP (same as the server ip) $rconIP="meindyndnsname" #CHANGE ME - RCON Port $rconPort=32330 #CHANGE ME - RCON Password $rconPassword="" #The ID of the App Your Updating $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 +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 Current version: $installedVersion - Latest version: $availableVersion Write-Host Update Available #Server Message 1 hr warning & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Ein Neues Update ist verfuegbar, Server startet in 60 Minuten neu..." Write-Host 1 hr warning given Start-Sleep -s 900 #Server Message 45 minute warning & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 45 Minuten neu..." Write-Host 45 min warning given Start-Sleep -s 900 #Server Message 30 minute warning & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 30 Minuten neu... Es wird Zeit nach Hause zu gehn ;)" Write-Host 30 min warning given Start-Sleep -s 900 #Server Message 15 minute warning & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 15 Minuten neu... Ihr solltet wirklich darueber nachdenken, an einen sicheren Ort zu gehen!" Write-Host 15 min warning given Start-Sleep -s 300 #Server Message 10 minute warning & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 10 Minuten neu... Wenn der Server heruntergefahren ist, dauert es etwa 5-10 Minuten bis er wieder Online ist." Start-Sleep -s 300 #Server Message 5 minute warning given & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 5 Minuten neu... Schnell nach Hause!" Start-Sleep -s 240 #Server Message 1 minute Warning & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Neues Update verfuegbar, Server startet in 1 Minuten neu... Nicht vergessen ihr muesst euren Client auch Updaten - Bis gleich ;)" Write-Host 1 min warning given Start-Sleep -s 10 #Save World admin command & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "saveworld" Start-Sleep -s 10 Write-Host world saving #Server Message Shutting Down & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast World Saved" Start-Sleep -s 15 #Server Admin Command Quit Write-Host Quit Server & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "quit" #Kill The Server by Ending the process kill -processname ShooterGameServer Start-Sleep -s 10 #update server Write-Host Update Script Initialising #CHANGE ME - you need to enter & $steamcmdExec +login anonymous +force_install_dir $arksurvivalFolder +app_update 376030 +exit #restart server Write-Host Restarting Server! & $arksurvivalFolder"\ShooterGame\Binaries\Win64\ShooterGameServer.exe" $arkSurvivalStartArguments #update current version $availableVersion | Out-File $latestInstalledUpdate #remove currently being updated block Write-Host Update Done! Remove-Item $updateinprogress -Force } ELSE { #remove currently being updated block Remove-Item $updateinprogress -Force Write-Host Running Latest Version $installedVersion #CHANGE ME These are the messages that are shown over an hr when no update is required # Server Message MOTD & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Der Server intalliert neue Updates automatisch, ihr werdet eine Stunde davor gewarnt." Write-Host MOTD auto update message Displayed Start-Sleep -s 900 # Server Message MOTD & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Bitte baut nicht vor oder an den Hoehlen." Write-Host MOTD message Displayed Start-Sleep -s 600 # Server Message MOTD & $mcrconExec -c -H $rconIP -P $rconPort -p $rconPassword "broadcast Wenn es dir bei uns gefaellt, schau doch mal auf unserem TS vorbei." Write-Host MOTD teamspeak message Displayed } }