From c8a48a4b65759f015775df4c1de3e2b6dcfcd43a Mon Sep 17 00:00:00 2001 From: Patrick Veilleux Date: Sun, 11 Dec 2022 14:58:19 -0500 Subject: [PATCH] ready for release --- README.md | 12 +++--- functions/process/Get-Lock.psm1 | 2 +- functions/process/Get-PID.psm1 | 2 +- functions/process/Lock-Process.psm1 | 2 +- functions/process/Register-PID.psm1 | 2 +- functions/process/Unlock-Process.psm1 | 2 +- functions/process/Unregister-PID.psm1 | 2 +- functions/server/Request-Update.psm1 | 11 +----- functions/server/Update-Server.psm1 | 2 +- functions/util/Exit-WithError.psm1 | 4 +- functions/util/Get-TaskConfig.psm1 | 14 +++---- functions/util/Register-Task.psm1 | 4 +- functions/util/Register-TaskConfig.psm1 | 2 +- functions/util/Remove-TaskConfig.psm1 | 2 +- functions/util/Unregister-Task.psm1 | 10 ++--- functions/util/Update-TaskConfig.psm1 | 8 ++-- global.psm1 | 2 +- main.ps1 | 50 +++++++++++++++---------- templates/7daystodie.psm1 | 7 +--- templates/astroneer.psm1 | 7 +--- templates/icarus.psm1 | 7 +--- templates/insurgencysandstorm.psm1 | 7 +--- templates/killingfloor2.psm1 | 9 ++--- templates/left4dead2.psm1 | 7 +--- templates/mordhau.psm1 | 7 +--- templates/paperclip.psm1 | 7 +--- templates/pixark.psm1 | 7 +--- templates/projectzomboid.psm1 | 7 +--- templates/rust.psm1 | 14 ++----- templates/satisfactory.psm1 | 7 +--- templates/squad.psm1 | 7 +--- templates/starbound.psm1 | 7 +--- templates/stationeers.psm1 | 9 ++--- templates/terraria.psm1 | 7 +--- templates/theforest.psm1 | 7 +--- templates/valheim.psm1 | 7 +--- templates/valheim_plus.psm1 | 7 +--- templates/vrising.psm1 | 7 +--- 38 files changed, 113 insertions(+), 171 deletions(-) diff --git a/README.md b/README.md index 2a797c4..37411da 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ # PowerShellGSM - PowerShell Game Server Manager A Modular PowerShell tool to manage game servers. -This PowerShell script will Install, Backup, Update and Start your server when executed. +This PowerShell script will take care of: +- Installation +- Backups +- Updates +- Monitoring +- Restarts -You can create a Scheduled Task to execute run.cmd daily to execute your server maintenance. - -If you enable Auto-Updates in a Server configuration, a Scheduled Task will automatically be created to check for new updates every 15 minutes. +Once started it registers a schedule task to check on your server status. # Supported Games @@ -34,7 +37,6 @@ If you enable Auto-Updates in a Server configuration, a Scheduled Task will auto - Faster than the other available tools - Lighter and more targeted backups -- Lighter shared game servers installation - Modular - Expandable - Customizable diff --git a/functions/process/Get-Lock.psm1 b/functions/process/Get-Lock.psm1 index 48f667c..7e7b216 100644 --- a/functions/process/Get-Lock.psm1 +++ b/functions/process/Get-Lock.psm1 @@ -3,7 +3,7 @@ function Get-Lock { [OutputType([boolean])] param ( ) - if ((Test-Path -Path ".\servers\$($Server.UID).LOCK" -PathType "Leaf" -ErrorAction SilentlyContinue)) { + if ((Test-Path -Path ".\servers\$($Server.Name).LOCK" -PathType "Leaf" -ErrorAction SilentlyContinue)) { return $true } return $false diff --git a/functions/process/Get-PID.psm1 b/functions/process/Get-PID.psm1 index 1de012f..857f579 100644 --- a/functions/process/Get-PID.psm1 +++ b/functions/process/Get-PID.psm1 @@ -5,7 +5,7 @@ function Get-PID { ) try { #Read the process ID from the PID file named by the UID defined in the server cfg file. - $ServerPID = Get-Content -Path ".\servers\$($Server.UID).PID" -ErrorAction SilentlyContinue + $ServerPID = Get-Content -Path ".\servers\$($Server.Name).PID" -ErrorAction SilentlyContinue } catch { return $null diff --git a/functions/process/Lock-Process.psm1 b/functions/process/Lock-Process.psm1 index 7ab39de..fc379fd 100644 --- a/functions/process/Lock-Process.psm1 +++ b/functions/process/Lock-Process.psm1 @@ -4,7 +4,7 @@ function Lock-Process { param ( ) try { - $null = New-Item -Path ".\servers\" -Name "$($Server.UID).LOCK" -ItemType "file" -Force -ErrorAction SilentlyContinue + $null = New-Item -Path ".\servers\" -Name "$($Server.Name).LOCK" -ItemType "file" -Force -ErrorAction SilentlyContinue Write-ScriptMsg "Process Locked." } catch { diff --git a/functions/process/Register-PID.psm1 b/functions/process/Register-PID.psm1 index f310308..1128d2e 100644 --- a/functions/process/Register-PID.psm1 +++ b/functions/process/Register-PID.psm1 @@ -32,7 +32,7 @@ function Register-PID { } $stopwatch.Stop() try { - $null = New-Item -Path ".\servers\" -Name "$($Server.UID).PID" -ItemType "file" -Value "$($ServerProcess.ID)" -Force -ErrorAction SilentlyContinue + $null = New-Item -Path ".\servers\" -Name "$($Server.Name).PID" -ItemType "file" -Value "$($ServerProcess.ID)" -Force -ErrorAction SilentlyContinue Write-ScriptMsg "Process Registered." } catch { diff --git a/functions/process/Unlock-Process.psm1 b/functions/process/Unlock-Process.psm1 index 29eed90..e20a993 100644 --- a/functions/process/Unlock-Process.psm1 +++ b/functions/process/Unlock-Process.psm1 @@ -5,7 +5,7 @@ function Unlock-Process { ) try { #Delete the LOCK file based on the Server UID. - $null = Remove-Item -Path ".\servers\$($Server.UID).LOCK" -Confirm:$false -ErrorAction SilentlyContinue + $null = Remove-Item -Path ".\servers\$($Server.Name).LOCK" -Confirm:$false -ErrorAction SilentlyContinue Write-ScriptMsg "Process Unlocked." } catch { diff --git a/functions/process/Unregister-PID.psm1 b/functions/process/Unregister-PID.psm1 index 584b576..ab91973 100644 --- a/functions/process/Unregister-PID.psm1 +++ b/functions/process/Unregister-PID.psm1 @@ -5,7 +5,7 @@ function Unregister-PID { ) try { #Delete the PID file based on the Server UID. - $null = Remove-Item -Path ".\servers\$($Server.UID).PID" -Confirm:$false -ErrorAction SilentlyContinue + $null = Remove-Item -Path ".\servers\$($Server.Name).PID" -Confirm:$false -ErrorAction SilentlyContinue } catch { return $false diff --git a/functions/server/Request-Update.psm1 b/functions/server/Request-Update.psm1 index c71ccb2..7e7e1cb 100644 --- a/functions/server/Request-Update.psm1 +++ b/functions/server/Request-Update.psm1 @@ -1,11 +1,4 @@ function Request-Update { - $ServerProcess = Get-ServerProcess - if (-not ($ServerProcess)){ - Exit-WithError -ErrorMsg "Server is not active." - } - if (-not ($Server.AutoUpdates)){ - Exit-WithError -ErrorMsg "AutoUpdates are disabled." - } #Create server directory if not found. if (-not (Test-Path -Path $Server.Path -ErrorAction SilentlyContinue)){ $null = New-Item -ItemType "directory" -Path $Server.Path -ErrorAction SilentlyContinue @@ -29,9 +22,9 @@ function Request-Update { #Join each item of the list with an LF $FileContent = $ArgumentList -join "`n" #Define the Script file name - $ScriptFile = "SteamCMD_Update_$($Server.UID).txt" + $ScriptFile = "SteamCMD_Update_$($Server.Name).txt" #Define the Script file name - $UpdateReturnFile = "SteamCMD_Update_$($Server.UID)_Return.txt" + $UpdateReturnFile = "SteamCMD_Update_$($Server.Name)_Return.txt" #Define the full path. $ScriptPath = (Resolve-CompletePath -Path ".\servers\$ScriptFile" -ParentPath ".\servers\") #Create the script. diff --git a/functions/server/Update-Server.psm1 b/functions/server/Update-Server.psm1 index 7da97a2..737cdf3 100644 --- a/functions/server/Update-Server.psm1 +++ b/functions/server/Update-Server.psm1 @@ -47,7 +47,7 @@ function Update-Server { #Join each item of the list with an LF $FileContent = $ArgumentList -join "`n" #Define the Script file name - $ScriptFile = "SteamCMD_$($Server.UID).txt" + $ScriptFile = "SteamCMD_$($Server.Name).txt" #Define the full path. $ScriptPath = (Resolve-CompletePath -Path ".\servers\$ScriptFile" -ParentPath ".\servers\") #Create the script. diff --git a/functions/util/Exit-WithError.psm1 b/functions/util/Exit-WithError.psm1 index 0cc168e..3a23df2 100644 --- a/functions/util/Exit-WithError.psm1 +++ b/functions/util/Exit-WithError.psm1 @@ -7,8 +7,8 @@ function Exit-WithError ) #Write error in red on black, stop logging, pause, exit. Write-Host -ForegroundColor "Red" -BackgroundColor "Black" -Object $ErrorMsg - Unlock-Process - Stop-Transcript + $null = Unlock-Process + $null = Stop-Transcript if ($Global.PauseOnErrors){ Read-Host "Press Enter to close this window." } diff --git a/functions/util/Get-TaskConfig.psm1 b/functions/util/Get-TaskConfig.psm1 index d95359e..5cc9eed 100644 --- a/functions/util/Get-TaskConfig.psm1 +++ b/functions/util/Get-TaskConfig.psm1 @@ -1,12 +1,12 @@ function Get-TaskConfig { Write-ScriptMsg "Getting Tasks Schedule..." - $NextAlive = Get-IniValue -file ".\servers\$($Server.UID).INI" -key "NextAlive" - $NextUpdate = Get-IniValue -file ".\servers\$($Server.UID).INI" -key "NextUpdate" - $NextRestart = Get-IniValue -file ".\servers\$($Server.UID).INI" -key "NextRestart" - return { - NextAlive: $NextAlive, - NextUpdate: $NextUpdate, - NextRestart: $NextRestart + $NextAlive = Get-IniValue -file ".\servers\$($Server.Name).INI" -category "Schedule" -key "NextAlive" + $NextUpdate = Get-IniValue -file ".\servers\$($Server.Name).INI" -category "Schedule" -key "NextUpdate" + $NextRestart = Get-IniValue -file ".\servers\$($Server.Name).INI" -category "Schedule" -key "NextRestart" + return [hashtable] @{ + NextAlive=$NextAlive; + NextUpdate=$NextUpdate; + NextRestart=$NextRestart; } } Export-ModuleMember -Function Get-TaskConfig \ No newline at end of file diff --git a/functions/util/Register-Task.psm1 b/functions/util/Register-Task.psm1 index fc4a9fe..8991083 100644 --- a/functions/util/Register-Task.psm1 +++ b/functions/util/Register-Task.psm1 @@ -2,8 +2,8 @@ function Register-Task { $action = New-ScheduledTaskAction -Execute "Powershell.exe" -Argument "-WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File $scriptpath -ServerCfg `"$ServerCfg`" -Task" -WorkingDirectory $dir $trigger = New-ScheduledTaskTrigger -Daily -At 12am -RandomDelay (New-TimeSpan -Minutes $Global.TaskCheckFrequency) $settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Minutes 10) - $description = "Run Tasks for $($server.UID)" - $title = "Tasks-$($server.UID)" + $description = "Run Tasks for $($server.Name)" + $title = "Tasks-$($server.Name)" $task = New-ScheduledTask -Description $description -Action $action -Trigger $trigger -Settings $settings $RegisteredTask = Register-ScheduledTask $title -InputObject $task $RegisteredTask.Triggers.Repetition.Duration = "P1D" #Repeat for a duration of one day diff --git a/functions/util/Register-TaskConfig.psm1 b/functions/util/Register-TaskConfig.psm1 index 7b689de..cebb263 100644 --- a/functions/util/Register-TaskConfig.psm1 +++ b/functions/util/Register-TaskConfig.psm1 @@ -1,7 +1,7 @@ function Register-TaskConfig { Write-ScriptMsg "Registering Tasks Schedule..." try { - $null = New-Item -Path ".\servers\" -Name "$($Server.UID).INI" -ItemType "file" -Force -ErrorAction SilentlyContinue + $null = New-Item -Path ".\servers\" -Name "$($Server.Name).INI" -ItemType "file" -Force -ErrorAction SilentlyContinue Write-ScriptMsg "Tasks Schedule Registered." } catch { diff --git a/functions/util/Remove-TaskConfig.psm1 b/functions/util/Remove-TaskConfig.psm1 index ff6457e..6516d5e 100644 --- a/functions/util/Remove-TaskConfig.psm1 +++ b/functions/util/Remove-TaskConfig.psm1 @@ -5,7 +5,7 @@ function Remove-TaskConfig { ) try { #Delete the INI file based on the Server UID. - $null = Remove-Item -Path ".\servers\$($Server.UID).INI" -Confirm:$false -ErrorAction SilentlyContinue + $null = Remove-Item -Path ".\servers\$($Server.Name).INI" -Confirm:$false -ErrorAction SilentlyContinue Write-ScriptMsg "Task Config Removed." } catch { diff --git a/functions/util/Unregister-Task.psm1 b/functions/util/Unregister-Task.psm1 index f44a086..fdee81c 100644 --- a/functions/util/Unregister-Task.psm1 +++ b/functions/util/Unregister-Task.psm1 @@ -1,6 +1,6 @@ -function Unregister-UpdateTask { - $title = "Tasks-$($server.UID)" - $null = Unregister-ScheduledTask -TaskName $title -Confirm:$false -ErrorAction SilentlyContinue - Remove-TaskConfig +function Unregister-Task { + $title = "Tasks-$($server.Name)" + $null = Unregister-ScheduledTask -TaskName $title -Confirm:$false + $null = Remove-TaskConfig } -Export-ModuleMember -Function Unregister-UpdateTask \ No newline at end of file +Export-ModuleMember -Function Unregister-Task \ No newline at end of file diff --git a/functions/util/Update-TaskConfig.psm1 b/functions/util/Update-TaskConfig.psm1 index 0c4a72d..85ba253 100644 --- a/functions/util/Update-TaskConfig.psm1 +++ b/functions/util/Update-TaskConfig.psm1 @@ -7,24 +7,24 @@ function Update-TaskConfig { [Parameter(Mandatory=$false)] [switch]$Update, [Parameter(Mandatory=$false)] - [string]$Restart + [switch]$Restart ) Write-ScriptMsg "Updating Tasks Schedule..." if($Alive){ $NextAlive = (Get-Date).AddMinutes($Global.AliveCheckFrequency) - Set-IniValue -file ".\servers\$($Server.UID).INI" -key "NextAlive" -value $NextAlive + Set-IniValue -file ".\servers\$($Server.Name).INI" -category "Schedule" -key "NextAlive" -value $NextAlive } if($Update){ $NextUpdate = (Get-Date).AddMinutes($Global.UpdateCheckFrequency) - Set-IniValue -file ".\servers\$($Server.UID).INI" -key "NextUpdate" -value $NextUpdate + Set-IniValue -file ".\servers\$($Server.Name).INI" -category "Schedule" -key "NextUpdate" -value $NextUpdate } if($Restart){ $NextRestart = (Get-Date -Hour $Server.AutoRestartTime[0] -Minute $Server.AutoRestartTime[1] -Second $Server.AutoRestartTime[2]).AddDays(1) - Set-IniValue -file ".\servers\$($Server.UID).INI" -key "NextRestart" -value $NextRestart + Set-IniValue -file ".\servers\$($Server.Name).INI" -category "Schedule" -key "NextRestart" -value $NextRestart } } Export-ModuleMember -Function Update-TaskConfig \ No newline at end of file diff --git a/global.psm1 b/global.psm1 index dce1483..1da6c2c 100644 --- a/global.psm1 +++ b/global.psm1 @@ -36,7 +36,7 @@ $GlobalDetails = @{ UpdateCheckFrequency = 15 #Check if the server is alive Frequency in Minutes - AliveCheckFrequency = 5 + AliveCheckFrequency = 2 #Should be lower or equal to the two above TaskCheckFrequency = 2 diff --git a/main.ps1 b/main.ps1 index 1805423..e88bf67 100644 --- a/main.ps1 +++ b/main.ps1 @@ -21,7 +21,7 @@ try { } catch { Exit-WithError -ErrorMsg "Unable to import modules." - exit + Exit } #--------------------------------------------------------- @@ -65,7 +65,9 @@ Write-ScriptMsg "Importing Server Configuration..." #Check if requested config exist in the config folder, if not, copy it from the templates. Exit if fails. #In the case of an update check or alive check, remove the check if the configuration is deleted. if (-not (Test-Path -Path ".\configs\$ServerCfg.psm1" -PathType "Leaf" -ErrorAction SilentlyContinue)) { + $Server = New-Object -TypeName PsObject -Property @{Name=$ServerCfg} if($Task){ + Write-ScriptMsg "Server Configuration no longer exists, unregistering Tasks..." Unregister-Task Exit } @@ -89,50 +91,58 @@ Read-Config #Check if script is already running if(Get-Lock){ - exit + Write-ScriptMsg "Process is locked, exiting." + Exit } #Locking Script to avoid double run -Lock-Process +$null = Lock-Process #--------------------------------------------------------- # Checking Scheduled Task #--------------------------------------------------------- if ($Task) { $FullRunRequired = $false - Write-ScriptMsg "Running Tasks for $($Server.UID) ..." - $TasksSchedule = Get-TaskConfig - - if(($Server.AutoRestartOnCrash) -and (($TasksSchedule.NextAlive) -lt (Get-Date))){ + Write-ScriptMsg "Running Tasks for $($ServerCfg) ..." + $TasksSchedule = (Get-TaskConfig) + if(($Server.AutoRestartOnCrash) -and (($TasksSchedule.NextAlive) -le (Get-Date))){ Write-ScriptMsg "Checking Alive State" if(-not (Get-ServerProcess)) { Write-ScriptMsg "Server is Dead, Restarting..." - Update-TaskConfig -Alive $FullRunRequired = $true } else { Write-ScriptMsg "Server is Alive" } + Update-TaskConfig -Alive + } else { + Write-ScriptMsg "Too soon for Alive check" } - if(($Server.AutoUpdates) -and (($TasksSchedule.NextUpdate) -lt (Get-Date))){ - Write-ScriptMsg "Checking on steamCMD if updates are avaiable for $($Server.UID)..." + if(($Server.AutoUpdates) -and (($TasksSchedule.NextUpdate) -le (Get-Date))){ + Write-ScriptMsg "Checking on steamCMD if updates are avaiable for $($Server.Name)..." if (Request-Update){ - Write-ScriptMsg "Updates are available for $($Server.UID), Proceeding with update process..." + Write-ScriptMsg "Updates are available for $($Server.Name), Proceeding with update process..." $FullRunRequired = $true - Update-TaskConfig -Update } else { - Write-ScriptMsg "No updates are available for $($Server.UID)" + Write-ScriptMsg "No updates are available for $($Server.Name)" } + Update-TaskConfig -Update + } else { + Write-ScriptMsg "Too soon for Update check" } - Write-ScriptMsg "Checking if server $($Server.UID) is due for restart" - if(($Server.AutoRestart) -and (($TasksSchedule.NextRestart) -lt (Get-Date))){ + if(($Server.AutoRestart) -and (($TasksSchedule.NextRestart) -le (Get-Date))){ + Write-ScriptMsg "Server is due for Restart" $FullRunRequired = $true Update-TaskConfig -Restart + } else { + Write-ScriptMsg "Too soon for Restart" } if(-not $FullRunRequired) { - exit + $null = Unlock-Process + Write-ScriptMsg "No tasks ready, exiting." + Exit } #Run Launcher as usual } @@ -186,8 +196,8 @@ if (-not $FreshInstall -and $Server.AutoUpdates) { # Register Scheduled Task #--------------------------------------------------------- -if ($Server.AutoUpdates -and -not (Get-ScheduledTask -TaskName "Tasks-$($server.UID)" -ErrorAction SilentlyContinue)) { - Write-ScriptMsg "Registering Scheduled Tasks Check for $($Server.UID)..." +if (($Server.AutoUpdates -or $Server.AutoRestartOnCrash -or $Server.AutoRestart) -and -not (Get-ScheduledTask -TaskName "Tasks-$($server.Name)" -ErrorAction SilentlyContinue)) { + Write-ScriptMsg "Registering Scheduled Tasks Check for $($Server.Name)..." Register-Task } @@ -229,7 +239,7 @@ catch { # Unlock Process #--------------------------------------------------------- -Unlock-Process +$null = Unlock-Process Write-ServerMsg "Script successfully completed." @@ -237,4 +247,4 @@ Write-ServerMsg "Script successfully completed." # Stop Logging #--------------------------------------------------------- -Stop-Transcript \ No newline at end of file +$null = Stop-Transcript \ No newline at end of file diff --git a/templates/7daystodie.psm1 b/templates/7daystodie.psm1 index 00e1426..4074fe0 100644 --- a/templates/7daystodie.psm1 +++ b/templates/7daystodie.psm1 @@ -2,8 +2,8 @@ #Change your servers settings in C:\Users\%username%\AppData\Roaming\7DaysToDie\Saves\serverconfig.xml #> -#Server Name, use the same name to share game files. -$Name = "7DaysToDie" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -11,9 +11,6 @@ $Name = "7DaysToDie" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "7DaysToDie_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/astroneer.psm1 b/templates/astroneer.psm1 index dab058a..40e0c75 100644 --- a/templates/astroneer.psm1 +++ b/templates/astroneer.psm1 @@ -4,8 +4,8 @@ https://blog.astroneer.space/p/astroneer-dedicated-server-details/ #> -#Server Name, use the same name to share game files. -$Name = "Astroneer" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -13,9 +13,6 @@ $Name = "Astroneer" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Astroneer_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/icarus.psm1 b/templates/icarus.psm1 index fdf146a..f3e3830 100644 --- a/templates/icarus.psm1 +++ b/templates/icarus.psm1 @@ -1,8 +1,8 @@ <# Configure server in .\servers\$Name\Saved\Config\WindowsServer\ServerSettings.ini #> -#Server Name, use the same name to share game files. -$Name = "Icarus" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -10,9 +10,6 @@ $Name = "Icarus" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Icarus_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/insurgencysandstorm.psm1 b/templates/insurgencysandstorm.psm1 index c47d1c3..7d94766 100644 --- a/templates/insurgencysandstorm.psm1 +++ b/templates/insurgencysandstorm.psm1 @@ -2,8 +2,8 @@ #Change your servers settings in ".\servers\Insurgency\Saved\Config\WindowsServer" #> -#Server Name, use the same name to share game files. -$Name = "InsurgencySandstorm" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- @@ -12,9 +12,6 @@ $Name = "InsurgencySandstorm" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "InsurgencySandstorm_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/killingfloor2.psm1 b/templates/killingfloor2.psm1 index a1f7771..5d3b7af 100644 --- a/templates/killingfloor2.psm1 +++ b/templates/killingfloor2.psm1 @@ -4,8 +4,8 @@ Edit configuration in ./Servers/KillingFloor2/KFGame/Config/KF[UID].INI bEnabled=true to enable webadmin #> -#Server Name, use the same name to share game files. -$Name = "KillingFloor2" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -13,9 +13,6 @@ $Name = "KillingFloor2" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "KillingFloor2_1" - #Login username used by SteamCMD Login = "anonymous" @@ -206,7 +203,7 @@ $ArgumentList = @( "-QueryPort=$($Server.QueryPort) ", "-WebAdminPort=$($Server.WebAdminPort) ", "-Multihome=$($Global.InternalIP) ", - "-ConfigSubDir=KF$($Server.UID)" + "-ConfigSubDir=KF$($Server.Name)" ) Add-Member -InputObject $Server -Name "ArgumentList" -Type NoteProperty -Value $ArgumentList Add-Member -InputObject $Server -Name "Launcher" -Type NoteProperty -Value "$($Server.Exec)" diff --git a/templates/left4dead2.psm1 b/templates/left4dead2.psm1 index c95662e..fb689bb 100644 --- a/templates/left4dead2.psm1 +++ b/templates/left4dead2.psm1 @@ -2,8 +2,8 @@ Edit configuration in : .\servers\Left4Dead2\left4dead2\cfg\server.cfg #> -#Server Name, use the same name to share game files. -$Name = "Left4Dead2" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -11,9 +11,6 @@ $Name = "Left4Dead2" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Left4Dead2_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/mordhau.psm1 b/templates/mordhau.psm1 index 7142b7a..eef539e 100644 --- a/templates/mordhau.psm1 +++ b/templates/mordhau.psm1 @@ -5,8 +5,8 @@ https://mordhau.fandom.com/wiki/Dedicated_Server_Hosting_Guide#Configuring_and_Running_the_Server #> -#Server Name, use the same name to share game files. -$Name = "Mordhau" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -14,9 +14,6 @@ $Name = "Mordhau" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Mordhau_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/paperclip.psm1 b/templates/paperclip.psm1 index 1fe620b..7c4dd79 100644 --- a/templates/paperclip.psm1 +++ b/templates/paperclip.psm1 @@ -2,8 +2,8 @@ Edit .\servers\Paperclip\server.properties #> -#Server Name, use the same name to share game files. -$Name = "Paperclip" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -11,9 +11,6 @@ $Name = "Paperclip" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Paperclip_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/pixark.psm1 b/templates/pixark.psm1 index f3b281d..db6eb82 100644 --- a/templates/pixark.psm1 +++ b/templates/pixark.psm1 @@ -23,8 +23,8 @@ ServerPVPCanAttack=True #> -#Server Name, use the same name to share game files. -$Name = "PixArk" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -32,9 +32,6 @@ $Name = "PixArk" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "PixArk_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/projectzomboid.psm1 b/templates/projectzomboid.psm1 index ec4bc94..6c53265 100644 --- a/templates/projectzomboid.psm1 +++ b/templates/projectzomboid.psm1 @@ -30,8 +30,8 @@ SteamPort2=8767 You do not need to forward RCON. #> -#Server Name, use the same name to share game files. -$Name = "ProjectZomboid" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -39,9 +39,6 @@ $Name = "ProjectZomboid" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "ProjectZomboid_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/rust.psm1 b/templates/rust.psm1 index 57c9469..34d132b 100644 --- a/templates/rust.psm1 +++ b/templates/rust.psm1 @@ -2,11 +2,8 @@ Edit configuration in ".\servers\Rust\server\[Identity]\cfg\serverauto.cfg" #> -#Server Name, use the same name to share game files. -$Name = "Rust" - -#Identity of the server -$Identity = "RustServer01" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -14,9 +11,6 @@ $Identity = "RustServer01" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Rust_1" - #Login username used by SteamCMD Login = "anonymous" @@ -24,7 +18,7 @@ $ServerDetails = @{ Hostname = "My Rust Server" #Identity of the server - Identity = $Identity + Identity = $Name #Description of the server \n for new line Description = "Welcome to my server" @@ -100,7 +94,7 @@ $ServerDetails = @{ Path = ".\servers\$Name" #Server configuration folder - ConfigFolder = ".\servers\$Name\server\$Identity\cfg\" + ConfigFolder = ".\servers\$Name\server\$Name\cfg\" #Steam Server App Id AppID = 258550 diff --git a/templates/satisfactory.psm1 b/templates/satisfactory.psm1 index 88ff190..ed59d75 100644 --- a/templates/satisfactory.psm1 +++ b/templates/satisfactory.psm1 @@ -5,8 +5,8 @@ https://satisfactory.fandom.com/wiki/Dedicated_servers #> -#Server Name, use the same name to share game files. -$Name = "Satisfactory" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -14,9 +14,6 @@ $Name = "Satisfactory" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Satisfactory_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/squad.psm1 b/templates/squad.psm1 index 969a0fc..7d2ff5c 100644 --- a/templates/squad.psm1 +++ b/templates/squad.psm1 @@ -1,8 +1,8 @@ <# Configure server in .\servers\Squad\SquadGame\ServerConfig\ #> -#Server Name, use the same name to share game files. -$Name = "Squad" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -10,9 +10,6 @@ $Name = "Squad" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Squad_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/starbound.psm1 b/templates/starbound.psm1 index 9352d36..cd642ca 100644 --- a/templates/starbound.psm1 +++ b/templates/starbound.psm1 @@ -3,8 +3,8 @@ https://starbounder.org/Guide:Setting_Up_Multiplayer #> -#Server Name, use the same name to share game files. -$Name = "Starbound" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -12,9 +12,6 @@ $Name = "Starbound" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Starbound_1" - #Login username used by SteamCMD Login = "Username" diff --git a/templates/stationeers.psm1 b/templates/stationeers.psm1 index db45a61..b75d79d 100644 --- a/templates/stationeers.psm1 +++ b/templates/stationeers.psm1 @@ -3,8 +3,8 @@ Edit .\servers\$Name\default.ini to configure this server #> -#Server Name, use the same name to share game files. -$Name = "Stationeers" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -12,9 +12,6 @@ $Name = "Stationeers" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Stationeers_1" - #Login username used by SteamCMD Login = "anonymous" @@ -208,7 +205,7 @@ $Warnings = New-Object -TypeName PsObject -Property $WarningsDetails if ($Server.ModPath -ne ""){ $Server.ModPath = (Resolve-CompletePath -Path $Server.ModPath -ParentPath ".\servers\") } -$LogFilePath = (Resolve-CompletePath -Path "$($Server.Path)\$($Server.UID).txt" -ParentPath ".\servers\") +$LogFilePath = (Resolve-CompletePath -Path "$($Server.Path)\$($Server.Name).txt" -ParentPath ".\servers\") Add-Member -InputObject $Server -Name "LogFile" -Type NoteProperty -Value $LogFilePath #Launch Arguments diff --git a/templates/terraria.psm1 b/templates/terraria.psm1 index 0d3fbb1..82bc1dd 100644 --- a/templates/terraria.psm1 +++ b/templates/terraria.psm1 @@ -2,8 +2,8 @@ ".\servers\$Name\serverconfig.txt" #> -#Server Name, use the same name to share game files. -$Name = "Terraria" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -11,9 +11,6 @@ $Name = "Terraria" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Terraria_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/theforest.psm1 b/templates/theforest.psm1 index 4f654e3..aad7a01 100644 --- a/templates/theforest.psm1 +++ b/templates/theforest.psm1 @@ -2,8 +2,8 @@ ".\servers\TheForest\Multiplayer\config.cfg" #> -#Server Name, use the same name to share game files. -$Name = "TheForest" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -11,9 +11,6 @@ $Name = "TheForest" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "TheForest_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/valheim.psm1 b/templates/valheim.psm1 index 65b68ea..ee28531 100644 --- a/templates/valheim.psm1 +++ b/templates/valheim.psm1 @@ -1,5 +1,5 @@ -#Server Name, use the same name to share game files. -$Name = "Valheim" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -7,9 +7,6 @@ $Name = "Valheim" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Valheim_1" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/valheim_plus.psm1 b/templates/valheim_plus.psm1 index f6d5f01..b630346 100644 --- a/templates/valheim_plus.psm1 +++ b/templates/valheim_plus.psm1 @@ -1,5 +1,5 @@ -#Server Name, use the same name to share game files. -$Name = "Valheim_plus" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -7,9 +7,6 @@ $Name = "Valheim_plus" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "Valheim_Plus" - #Login username used by SteamCMD Login = "anonymous" diff --git a/templates/vrising.psm1 b/templates/vrising.psm1 index 1a7510d..7ecb8d9 100644 --- a/templates/vrising.psm1 +++ b/templates/vrising.psm1 @@ -1,5 +1,5 @@ -#Server Name, use the same name to share game files. -$Name = "VRising" +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg #--------------------------------------------------------- # Server Configuration @@ -7,9 +7,6 @@ $Name = "VRising" $ServerDetails = @{ - #Unique Identifier used to track processes. Must be unique to each servers. - UID = "VRising_1" - #Login username used by SteamCMD Login = "anonymous"