From 39985e7ea37a62e5a507026bfcb4ad64287294b8 Mon Sep 17 00:00:00 2001 From: Patrick Veilleux Date: Thu, 25 Jan 2024 09:24:13 -0500 Subject: [PATCH 1/3] first draft --- .vscode/launch.json | 8 +- templates/enshrouded.psm1 | 218 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 templates/enshrouded.psm1 diff --git a/.vscode/launch.json b/.vscode/launch.json index 2c1cb37..a58f085 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,20 +5,20 @@ "version": "0.2.0", "configurations": [ { - "name": "PowerShell: Launch Palworld", + "name": "PowerShell: Launch enshrouded", "type": "PowerShell", "request": "launch", "script": "${workspaceFolder}\\main.ps1", - "args": ["-ServerCfg \"palworld\""], + "args": ["-ServerCfg \"enshrouded\""], "cwd": "${workspaceFolder}", "createTemporaryIntegratedConsole": true }, { - "name": "PowerShell: Launch palworld Update Check", + "name": "PowerShell: Launch enshrouded Update Check", "type": "PowerShell", "request": "launch", "script": "${workspaceFolder}\\main.ps1", - "args": ["-ServerCfg \"palworld\" -UpdateCheck"], + "args": ["-ServerCfg \"enshrouded\" -UpdateCheck"], "cwd": "${workspaceFolder}", "createTemporaryIntegratedConsole": true } diff --git a/templates/enshrouded.psm1 b/templates/enshrouded.psm1 new file mode 100644 index 0000000..c3428db --- /dev/null +++ b/templates/enshrouded.psm1 @@ -0,0 +1,218 @@ +#Server Name, Always Match the Launcher and config file name. +$Name = $ServerCfg + +#--------------------------------------------------------- +# Server Configuration +#--------------------------------------------------------- + +$ServerDetails = @{ + + #Login username used by SteamCMD + Login = "anonymous" + + #Server Name + ServerName = "My Enshrouded Server" + + #Server Password + Password = "CHANGEME" + + #Maximum number of players + MaxPlayers = 16 + + #Server Port + Port = 15636 + + #Query Port + QueryPort = 15637 + + #Rcon IP (Not available yet) + ManagementIP = "127.0.0.1" + + #Rcon Port + ManagementPort = "15638" + + #Rcon Password + ManagementPassword = "CHANGEMETOO" + + #--------------------------------------------------------- + # Server Installation Details + #--------------------------------------------------------- + + #Name of the Server Instance + Name = $Name + + #Server Installation Path + Path = ".\servers\$Name" + + #Server configuration folder + ConfigFolder = ".\servers\$Name\" + + #Steam Server App Id + AppID = 2278520 + + #Name of the Beta Build + BetaBuild = "" + + #Beta Build Password + BetaBuildPassword = "" + + #Set to $true if you want this server to automatically update. + AutoUpdates = $true + + #Set to $true if you want this server to automatically restart on crash. + AutoRestartOnCrash = $true + + #Set to $true if you want this server to automatically restart at set hour. + AutoRestart = $true + + #The time at which the server will restart daily. + #(Hour, Minute, Seconds) + AutoRestartTime = @(3, 0, 0) + + #Process name in the task manager + ProcessName = "enshrouded_server" + + #Use PID instead of Process Name. + UsePID = $true + + #Server Executable + Exec = ".\servers\$Name\enshrouded_server.exe" + + #Allow force close, usefull for server without RCON and Multiple instances. + AllowForceClose = $true + + #Process Priority Realtime, High, AboveNormal, Normal, BelowNormal, Low + UsePriority = $true + AppPriority = "High" + + <# + Process Affinity (Core Assignation) + Core 1 = > 00000001 = > 1 + Core 2 = > 00000010 = > 2 + Core 3 = > 00000100 = > 4 + Core 4 = > 00001000 = > 8 + Core 5 = > 00010000 = > 16 + Core 6 = > 00100000 = > 32 + Core 7 = > 01000000 = > 64 + Core 8 = > 10000000 = > 128 + ---------------------------- + 8 Cores = > 11111111 = > 255 + 4 Cores = > 00001111 = > 15 + 2 Cores = > 00000011 = > 3 + #> + + UseAffinity = $false + AppAffinity = 15 + + #Should the server validate install after installation or update *(recommended) + Validate = $true + + #How long should it wait to check if the server is stable + StartupWaitTime = 10 +} +#Create the object +$Server = New-Object -TypeName PsObject -Property $ServerDetails + +#--------------------------------------------------------- +# Backups +#--------------------------------------------------------- + +$BackupsDetails = @{ + #Do Backups + Use = $true + + #Backup Folder + Path = ".\backups\$($Server.Name)" + + #Number of days of backups to keep. + Days = 7 + + #Number of weeks of weekly backups to keep. + Weeks = 4 + + #Folder to include in backup + Saves = ".\servers\$($Server.Name)\savegame\" + + #Exclusions (Regex use | as separator) + Exclusions = "()" +} +#Create the object +$Backups = New-Object -TypeName PsObject -Property $BackupsDetails + +#--------------------------------------------------------- +# Restart Warnings (Require RCON, Telnet or WebSocket API) +#--------------------------------------------------------- + +$WarningsDetails = @{ + #Use Rcon to restart server softly. + Use = $false + + #What protocol to use : RCON, ARRCON, Telnet, Websocket + Protocol = "ARRCON" + + #Times at which the servers will warn the players that it is about to restart. (in seconds between each timers) + Timers = [System.Collections.ArrayList]@(240, 50, 10) #Total wait time is 240+50+10 = 300 seconds or 5 minutes + + #message that will be sent. % is a wildcard for the timer. + MessageMin = "The server will restart in % minutes !" + + #message that will be sent. % is a wildcard for the timer. + MessageSec = "The server will restart in % seconds !" + + #command to send a message. + CmdMessage = "Broadcast" + + #command to save the server + CmdSave = "Save" + + #How long to wait in seconds after the save command is sent. + SaveDelay = 75 + + #command to stop the server + CmdStop = "Shutdown" +} +#Create the object +$Warnings = New-Object -TypeName PsObject -Property $WarningsDetails + +#--------------------------------------------------------- +# Launch Arguments +#--------------------------------------------------------- + +#Launch Arguments +$ArgumentList = @( + "-name=$($Server.ServerName) ", + "-gamePort=$($Server.Port) ", + "-queryPort=$($Server.QueryPort) ", + "-slotCount=$($Server.MaxPlayers) ", + "-ip=$($Global.InternalIP) ", + "-log" +) +Add-Member -InputObject $Server -Name "ArgumentList" -Type NoteProperty -Value $ArgumentList +Add-Member -InputObject $Server -Name "Launcher" -Type NoteProperty -Value "$($Server.Exec)" +Add-Member -InputObject $Server -Name "WorkingDirectory" -Type NoteProperty -Value "$($Server.Path)" + +#--------------------------------------------------------- +# Function that runs just before the server starts. +#--------------------------------------------------------- + +function Start-ServerPrep { + # Check if the config file is almost empty and if so, write the default config to it. + Write-ScriptMsg "Writing configuration to $($Server.ConfigFolder)\enshrouded_server.ini" + $jsonObject = @{ + "name"= $Server.ServerName + "password" = $Server.Password + "saveDirectory" = "./savegame" + "logDirectory" = "./logs" + "ip" = $Global.InternalIP + "gamePort" = $Server.Port + "queryPort" = $Server.QueryPort + "slotCount" = $Server.MaxPlayers + } + $content = $jsonObject | ConvertTo-Json + + Set-Content -Path "$($Server.ConfigFolder)/enshrouded_server.ini" -Value $content + + Write-ScriptMsg "Port Forward : $($Server.Port) and $($Server.QueryPort) in TCP and UDP to $($Global.InternalIP)" +} + +Export-ModuleMember -Function Start-ServerPrep -Variable @("Server", "Backups", "Warnings") From 02cf41a11a34360d82cd92270c0fc1834188c26b Mon Sep 17 00:00:00 2001 From: Patrick Veilleux Date: Thu, 25 Jan 2024 09:43:33 -0500 Subject: [PATCH 2/3] Add Enshrouded Support Fix Extentionless files backup Disable Debug Mode --- functions/server/Backup-Server.psm1 | 2 +- global.psm1 | 4 ++-- templates/enshrouded.psm1 | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/server/Backup-Server.psm1 b/functions/server/Backup-Server.psm1 index 1f22d02..014017e 100644 --- a/functions/server/Backup-Server.psm1 +++ b/functions/server/Backup-Server.psm1 @@ -32,7 +32,7 @@ try { } # Define the filter to exclude certain files from the backup $ExcludeFilter = { - $_.Name -notmatch $Backups.Exclusions -and $_.Extension -notin $Global.Exclusions + ($_.Name -notmatch $Backups.Exclusions -and $_.Extension -notin $Global.Exclusions) -or $null -eq $_.Extension -or $_.Extension -eq '' } # Get all files that should be included in the backup diff --git a/global.psm1 b/global.psm1 index 08fe032..e643c16 100644 --- a/global.psm1 +++ b/global.psm1 @@ -15,7 +15,7 @@ $GlobalDetails = @{ LogFolder = ".\logs" #File extensions to exclude from backups - Exclusions = @(".tmp", ".bak", ".log", ".old", ".temp") + Exclusions = @(".tmp", ".bak", ".log", ".old", ".temp", ".backup") #Number of days to keep server logs Days = 30 @@ -61,7 +61,7 @@ $GlobalDetails = @{ # Debug Mode (will not delete any logs or script files and will ignore script locks) # !!! DO NOT ENABLE IN PRODUCTION !!! - Debug = $true + Debug = $false } #Create the object diff --git a/templates/enshrouded.psm1 b/templates/enshrouded.psm1 index c3428db..14ba14d 100644 --- a/templates/enshrouded.psm1 +++ b/templates/enshrouded.psm1 @@ -197,7 +197,7 @@ Add-Member -InputObject $Server -Name "WorkingDirectory" -Type NoteProperty -Val function Start-ServerPrep { # Check if the config file is almost empty and if so, write the default config to it. - Write-ScriptMsg "Writing configuration to $($Server.ConfigFolder)\enshrouded_server.ini" + Write-ScriptMsg "Writing configuration to $($Server.ConfigFolder)\enshrouded_server.json" $jsonObject = @{ "name"= $Server.ServerName "password" = $Server.Password @@ -210,7 +210,7 @@ function Start-ServerPrep { } $content = $jsonObject | ConvertTo-Json - Set-Content -Path "$($Server.ConfigFolder)/enshrouded_server.ini" -Value $content + Set-Content -Path "$($Server.ConfigFolder)/enshrouded_server.json" -Value $content Write-ScriptMsg "Port Forward : $($Server.Port) and $($Server.QueryPort) in TCP and UDP to $($Global.InternalIP)" } From 2bb061ee30e279ccadcca0a690cc3e05aad07dc5 Mon Sep 17 00:00:00 2001 From: Patrick Veilleux Date: Thu, 25 Jan 2024 09:47:15 -0500 Subject: [PATCH 3/3] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b3a0fdd..f970d5a 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Once started it registers a schedule task to check on your server status. - Ark: Survival Ascended - Astroneer - Conan Exiles +- Enshrouded - Icarus - Insurgency Sandstorm - Killing Floor 2