Skip to content

Commit

Permalink
Fix wierd quotation issues again.
Browse files Browse the repository at this point in the history
Fix potential Update issues.
  • Loading branch information
patrix87 committed Nov 3, 2023
1 parent 62ddc0c commit aad64ba
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
19 changes: 17 additions & 2 deletions functions/server/Request-Update.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,30 @@ 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")
}
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"
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions functions/server/Start-Server.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 9 additions & 13 deletions functions/server/Update-Server.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions templates/ark_survival_ascended.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand All @@ -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.
Expand Down

0 comments on commit aad64ba

Please sign in to comment.