From aad64baaa49f5c57c7ee926c3b81f0ce4c6ea44b Mon Sep 17 00:00:00 2001 From: Patrick Veilleux Date: Fri, 3 Nov 2023 11:03:33 -0400 Subject: [PATCH] Fix wierd quotation issues again. Fix potential Update issues. --- functions/server/Request-Update.psm1 | 19 +++++++++++++++++-- functions/server/Start-Server.psm1 | 2 ++ functions/server/Update-Server.psm1 | 22 +++++++++------------- templates/ark_survival_ascended.psm1 | 6 +++--- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/functions/server/Request-Update.psm1 b/functions/server/Request-Update.psm1 index 55903ca..4fc05a5 100644 --- a/functions/server/Request-Update.psm1 +++ b/functions/server/Request-Update.psm1 @@ -8,6 +8,8 @@ function Request-Update { return } [System.Collections.ArrayList]$ArgumentList = @() + #Server Directory + $null = $ArgumentList.Add("force_install_dir `"$($Server.Path)`"") #Login if ($Server.Login -eq "anonymous") { $null = $ArgumentList.Add("@ShutdownOnFailedCommand 1`n@NoPromptForPassword 1`n@sSteamCmdForcePlatformType windows`nlogin anonymous") @@ -15,10 +17,21 @@ function Request-Update { else { $null = $ArgumentList.Add("@sSteamCmdForcePlatformType windows`nlogin $($Server.Login)") } - $null = $ArgumentList.Add("force_install_dir `"$($Server.Path)`"") $null = $ArgumentList.Add("app_info_update 1") - $null = $ArgumentList.Add("app_status $($Server.AppID)") + #Action String Construction + [System.Collections.ArrayList]$ActionList = @() + $null = $ActionList.Add("app_status $($Server.AppID)") + $VersionString = "Regular" + if ($Server.BetaBuild -ne "") { + $VersionString = "Beta" + $null = $ActionList.Add("-beta $($Server.BetaBuild)") + } + if ($Server.BetaBuildPassword -ne "") { + $null = $ActionList.Add("-betapassword $($Server.BetaBuildPassword)") + } #join each part of the string and add it to the list + $null = $ArgumentList.Add($ActionList -join " ") + #Quit to close the script once it is done. $null = $ArgumentList.Add("quit") #Join each item of the list with an LF $FileContent = $ArgumentList -join "`n" @@ -41,7 +54,9 @@ function Request-Update { $State = Select-String -Path ".\servers\$UpdateReturnFile" -Pattern " - install state:" #Delete the script and update return file. $null = Remove-Item -Path $ScriptPath -Confirm:$false -ErrorAction SilentlyContinue + #$null = Rename-Item -Path $ScriptPath -NewName "$ScriptFile.$(Get-TimeStamp).txt" -ErrorAction SilentlyContinue $null = Remove-Item -Path ".\servers\$UpdateReturnFile" -Confirm:$false -ErrorAction SilentlyContinue + #$null = Rename-Item -Path ".\servers\$UpdateReturnFile" -NewName "$UpdateReturnFile.$(Get-TimeStamp).txt" -ErrorAction SilentlyContinue if ($State.Line -match "Update Required") { return $true } diff --git a/functions/server/Start-Server.psm1 b/functions/server/Start-Server.psm1 index d156ad4..835e0bb 100644 --- a/functions/server/Start-Server.psm1 +++ b/functions/server/Start-Server.psm1 @@ -7,9 +7,11 @@ function Start-Server { $timestamp = Get-Date Add-Member -InputObject $Server -Name "StartTime" -Type NoteProperty -Value $timestamp if ($Server.Arguments.length -gt 0) { + Write-ServerMsg "Starting Server $($Server.Launcher) with Arguments: $($Server.Arguments)" $ServerProcess = Start-Process -FilePath $Server.Launcher -WorkingDirectory $($Server.WorkingDirectory) -ArgumentList $Server.Arguments -PassThru } else { + Write-ServerMsg "Starting Server $($Server.Launcher) with no Arguments." $ServerProcess = Start-Process -FilePath $Server.Launcher -WorkingDirectory $($Server.WorkingDirectory) -PassThru } #Wait to see if the server is stable. diff --git a/functions/server/Update-Server.psm1 b/functions/server/Update-Server.psm1 index 0d45385..464ed06 100644 --- a/functions/server/Update-Server.psm1 +++ b/functions/server/Update-Server.psm1 @@ -12,13 +12,8 @@ function Update-Server { if ($Server.AppID -eq 0) { return } - <# - String Part if value is null or false or empty string - if () { - String Part if value is defined - } - #> [System.Collections.ArrayList]$ArgumentList = @() + #Server Directory $null = $ArgumentList.Add("force_install_dir `"$($Server.Path)`"") #Login if ($Server.Login -eq "anonymous") { @@ -27,23 +22,24 @@ function Update-Server { else { $null = $ArgumentList.Add("@sSteamCmdForcePlatformType windows`nlogin $($Server.Login)") } - #Install String Building - [System.Collections.ArrayList]$InstallList = @() - $null = $InstallList.Add("app_update $($Server.AppID)") + #Action String Construction + [System.Collections.ArrayList]$ActionList = @() + $null = $ActionList.Add("app_update $($Server.AppID)") $VersionString = "Regular" if ($Server.BetaBuild -ne "") { $VersionString = "Beta" - $null = $InstallList.Add("-beta $($Server.BetaBuild)") + $null = $ActionList.Add("-beta $($Server.BetaBuild)") } if ($Server.BetaBuildPassword -ne "") { - $null = $InstallList.Add("-betapassword $($Server.BetaBuildPassword)") + $null = $ActionList.Add("-betapassword $($Server.BetaBuildPassword)") } if ($Server.Validate) { $ValidatingString = "and Validating" - $null = $InstallList.Add("validate") + $null = $ActionList.Add("validate") } #join each part of the string and add it to the list - $null = $ArgumentList.Add($InstallList -join " ") + $null = $ArgumentList.Add($ActionList -join " ") + #Quit to close the script once it is done. $null = $ArgumentList.Add("quit") #Join each item of the list with an LF $FileContent = $ArgumentList -join "`n" diff --git a/templates/ark_survival_ascended.psm1 b/templates/ark_survival_ascended.psm1 index 94931f1..4ae2447 100644 --- a/templates/ark_survival_ascended.psm1 +++ b/templates/ark_survival_ascended.psm1 @@ -200,8 +200,8 @@ $Warnings = New-Object -TypeName PsObject -Property $WarningsDetails $ArgumentList = @( "$($Server.WorldName)", "?listen", - "?SessionName=`"`"`"$($Server.SessionName)`"`"`"", #Triple double-quotes here. - "?ServerPassword=`"`"$($Server.Password)`"`"", + "?SessionName=`"`"`"$($Server.SessionName)`"`"`"", #Yes, triple double quotes are needed only here. + "?ServerPassword=`"$($Server.Password)`"", "?Port=$($Server.Port)", "?QueryPort=$($Server.QueryPort)", "?RCONEnabled=$($Server.EnableRcon)", @@ -215,7 +215,7 @@ if ($Server.SaveFolder) { } if ($Server.ManagementPassword) { - $ArgumentList += "?ServerAdminPassword=`"`"$($Server.ManagementPassword)`"`"" #Fix Server Admin Password Issues. + $ArgumentList += "?ServerAdminPassword=`"$($Server.ManagementPassword)`"" #Fix Server Admin Password Issues. } $ArgumentList += " -WinLiveMaxPlayers=$($Server.MaxPlayers)" #Fix MaxPlayers not working.