Updated Manager.ps1 - more Linux support, still Work In Progress.

This commit is contained in:
Yuuki Chan 2023-03-06 18:58:06 +09:00
parent bd9d97f6d8
commit 4e06e4e496

View file

@ -59,16 +59,28 @@ function check_software ($app)
} }
function check_ram ($in) function check_ram ($in)
{ {
$total = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb if ($IsWindows)
{
$total = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb
if ($total -gt $in) if ($total -gt $in)
{ {
success "$total GB RAM detected." success "$total GB RAM detected."
$global:check += 1 $global:check += 1
}
else
{
error "$in GB RAM detected. You need at least 3 GB."
}
} }
else elseif ($IsLinux)
{ {
error "$in GB RAM detected. You need at least 3 GB." $total = $(awk '{ print $2 }' /proc/meminfo | head -n1) / 1024 / 1024
if ($total -lt 2.79369)
{
error "Not enough RAM installed. You need AT LEAST 3GB."
}
} }
} }
function check_arch function check_arch
@ -217,63 +229,77 @@ check_ram(3) # argument is amount of (required) RAM in GB.
check_arch check_arch
check_os check_os
if ($check -eq 6) if ($IsWindows)
{ {
Write-Host "Cloning Longvinter Windows Server repository..." if ($check -eq 6)
git clone -q https://github.com/Uuvana-Studios/longvinter-windows-server.git
# Fail-safe for Game.ini.default
if (Test-Path ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini.default" -PathType Leaf)
{ {
Copy-Item ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini.default" ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini" Write-Host "Cloning Longvinter Windows Server repository..."
git clone -q https://github.com/Uuvana-Studios/longvinter-windows-server.git
# Fail-safe for Game.ini.default
if (Test-Path ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini.default" -PathType Leaf)
{
Copy-Item ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini.default" ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini"
}
else
{
Set-Content -Path ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini" -Value "[/game/blueprints/server/gi_advancedsessions.gi_advancedsessions_c]
ServerName=Unnamed Island
ServerTag=Default
MaxPlayers=32
ServerMOTD=Welcome to Longvinter Island!
Password=
CommunityWebsite=www.longvinter.com
[/game/blueprints/server/gm_longvinter.gm_longvinter_c]
AdminEosID=97615967659669198
PVP=true
TentDecay=true
MaxTents=2
ChestRespawnTime=600"
}
Write-Host "> It is suggested to edit the Game.ini to your liking."
$edit = Read-Host "> Do you want to edit Game.ini? y/n"
if ($edit.ToLower() -eq "yes" -or $edit.ToLower() -eq "y")
{
notepad ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini"
}
$TargetFile = "$PWD\longvinter-windows-server\LongvinterServer.exe"
$ShortcutFile = "$PWD\Longvinter.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Arguments = "-log"
$Shortcut.Save()
Write-Host "> Shortcut created."
Write-Host "Adding firewall rules..."
New-NetFirewallRule -DisplayName "LongvinterServer UDP" -Action Allow -Protocol UDP -Direction Inbound -LocalPort 7777, 27015, 27016 | Out-Null
New-NetFirewallRule -DisplayName "LongvinterServer UDP" -Action Allow -Protocol UDP -Direction Outbound -LocalPort 7777, 27015, 2701 | Out-Null
New-NetFirewallRule -DisplayName "LongvinterServer TCP" -Action Allow -Protocol TCP -Direction Inbound -LocalPort 27015, 27016 | Out-Null
New-NetFirewallRule -DisplayName "LongvinterServer TCP" -Action Allow -Protocol TCP -Direction Outbound -LocalPort 27015, 27016 | Out-Null
Write-Host "> Press enter to continue..." -NoNewLine
$Host.UI.ReadLine()
Write-Host ""
Write-Host "You can now run the shortcut in the current directory."
} }
else else
{ {
Set-Content -Path ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini" -Value "[/game/blueprints/server/gi_advancedsessions.gi_advancedsessions_c] Write-Host "One or more checks failed. Cannot install Longvinter (Windows) Server."
ServerName=Unnamed Island Exit
ServerTag=Default
MaxPlayers=32
ServerMOTD=Welcome to Longvinter Island!
Password=
CommunityWebsite=www.longvinter.com
[/game/blueprints/server/gm_longvinter.gm_longvinter_c]
AdminEosID=97615967659669198
PVP=true
TentDecay=true
MaxTents=2
ChestRespawnTime=600"
} }
Write-Host "> It is suggested to edit the Game.ini to your liking."
$edit = Read-Host "> Do you want to edit Game.ini? y/n"
if ($edit.ToLower() -eq "yes" -or $edit.ToLower() -eq "y")
{
notepad ".\longvinter-windows-server\Longvinter\Saved\Config\WindowsServer\Game.ini"
}
$TargetFile = "$PWD\longvinter-windows-server\LongvinterServer.exe"
$ShortcutFile = "$PWD\Longvinter.lnk"
$WScriptShell = New-Object -ComObject WScript.Shell
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
$Shortcut.TargetPath = $TargetFile
$Shortcut.Arguments = "-log"
$Shortcut.Save()
Write-Host "> Shortcut created."
Write-Host "Adding firewall rules..."
New-NetFirewallRule -DisplayName "LongvinterServer UDP" -Action Allow -Protocol UDP -Direction Inbound -LocalPort 7777, 27015, 27016 | Out-Null
New-NetFirewallRule -DisplayName "LongvinterServer UDP" -Action Allow -Protocol UDP -Direction Outbound -LocalPort 7777, 27015, 2701 | Out-Null
New-NetFirewallRule -DisplayName "LongvinterServer TCP" -Action Allow -Protocol TCP -Direction Inbound -LocalPort 27015, 27016 | Out-Null
New-NetFirewallRule -DisplayName "LongvinterServer TCP" -Action Allow -Protocol TCP -Direction Outbound -LocalPort 27015, 27016 | Out-Null
Write-Host "> Press enter to continue..." -NoNewLine
$Host.UI.ReadLine()
Write-Host ""
Write-Host "You can now run the shortcut in the current directory."
} }
else elseif ($IsLinux)
{ {
Write-Host "One or more checks failed. Cannot install Longvinter Server." if ((id -u) -eq 0)
Exit {
}
else
{
error "Please run the script as root."
}
} }