Compare commits
2 commits
4e06e4e496
...
5220e576bd
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5220e576bd | ||
![]() |
23f60dbecb |
2 changed files with 326 additions and 116 deletions
250
Manager-Linux.ps1
Normal file
250
Manager-Linux.ps1
Normal file
|
@ -0,0 +1,250 @@
|
|||
#Requires -RunAsAdministrator
|
||||
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2021 v5.8.196
|
||||
Created on: 2022/03/25 05:55:13 PM
|
||||
Created by: Yuuki2012
|
||||
Organization: Raiza.dev
|
||||
Filename: Manager.ps1
|
||||
===========================================================================
|
||||
.DESCRIPTION
|
||||
Manager for Longvinter Windows Server.
|
||||
#>
|
||||
|
||||
if ($IsLinux)
|
||||
{
|
||||
$global:check = 0
|
||||
|
||||
function success ($msg)
|
||||
{
|
||||
Write-Host "[" -NoNewline
|
||||
Write-Host "✓" -NoNewline -ForegroundColor Green
|
||||
Write-Host "]" -NoNewline
|
||||
Write-Host " $msg"
|
||||
}
|
||||
function error ($msg)
|
||||
{
|
||||
Write-Host "[" -NoNewline
|
||||
Write-Host "X" -NoNewline -ForegroundColor Red
|
||||
Write-Host "]" -NoNewline
|
||||
Write-Host " $msg"
|
||||
}
|
||||
function check_software ($app)
|
||||
{
|
||||
$exists_bin = Test-Path -Path "/usr/bin/"$app -PathType Leaf
|
||||
$exists_loc = Test-Path -Path "/usr/local/bin/"$app -PathType Leaf
|
||||
}
|
||||
function check_ram ($in)
|
||||
{
|
||||
eif ($IsLinux)
|
||||
{
|
||||
$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
|
||||
{
|
||||
$arch = $(uname -m)
|
||||
|
||||
if ($arch -eq "x86_64")
|
||||
{
|
||||
success "$arch OS detected."
|
||||
$global:check += 1
|
||||
}
|
||||
else
|
||||
{
|
||||
error "$arch OS detected. You need a 64-bit system to install Longvinter Server."
|
||||
}
|
||||
}
|
||||
function check_os
|
||||
{
|
||||
if ($IsLinux)
|
||||
{
|
||||
success "Linux detected."
|
||||
$global:check += 1
|
||||
}
|
||||
else
|
||||
{
|
||||
error "Please run (one of) the other script(s)"
|
||||
}
|
||||
}
|
||||
function getkey
|
||||
{
|
||||
$exists = Test-Path -Path ".\longvinter-linux-server\Longvinter\Saved\Logs\Longvinter.log" -PathType Leaf
|
||||
|
||||
if ($exists)
|
||||
{
|
||||
Write-Host (Select-String -Pattern "'[0-9a-f]{32}" -Path ".\longvinter-linix-server\Longvinter\Saved\Logs\Longvinter.log").Matches.groups[0].value.ToString().Replace("'", "") -NoNewline -ForegroundColor Green
|
||||
}
|
||||
else
|
||||
{
|
||||
error "Longvinter.log not found. Please run the server first."
|
||||
}
|
||||
|
||||
Exit
|
||||
}
|
||||
function update
|
||||
{
|
||||
if (Test-Path ".\longvinter-linix-server\" -PathType Any)
|
||||
{
|
||||
Set-Location ".\longvinter-linix-server\"
|
||||
git fetch
|
||||
git restore .
|
||||
git pull
|
||||
Set-Location "..\"
|
||||
success "Successfully updated server."
|
||||
}
|
||||
else
|
||||
{
|
||||
error "Longvinter Windows Server is not installed."
|
||||
}
|
||||
}
|
||||
function backup
|
||||
{
|
||||
$ctime = Get-Date -Format "yyyyMMdd-HHmm"
|
||||
mkdir ".\longvinter-linix-server\Longvinter\Backup" -ErrorAction SilentlyContinue
|
||||
tar --exclude="*Logs*" --exclude="*CrashReportClient*" -cvzf ".\longvinter-linix-server\Longvinter\Backup\$ctime.tar.gz" ".\longvinter-linix-server\Longvinter\Saved" 2> $null
|
||||
success "Created backup in .\longvinter-linix-server\Longvinter\Backup\$ctime.tar.gz"
|
||||
}
|
||||
function uninstall
|
||||
{
|
||||
Remove-Item ".\longvinter-linix-server" -Recurse -Force -ErrorAction SilentlyContinue
|
||||
success "Removed longvinter-linix-server."
|
||||
|
||||
$udp = Get-NetFirewallRule -DisplayName "LongvinterServer UDP" 2> $null
|
||||
$tcp = Get-NetFirewallRule -DisplayName "LongvinterServer TCP" 2> $null
|
||||
if ($udp -or $tcp)
|
||||
{
|
||||
Remove-NetFirewallRule -DisplayName "LongvinterServer UDP"
|
||||
Remove-NetFirewallRule -DisplayName "LongvinterServer TCP"
|
||||
success "Removed Firewall rules."
|
||||
}
|
||||
else
|
||||
{
|
||||
success "No firewall rules exist."
|
||||
}
|
||||
|
||||
Remove-Item ".\Longvinter.lnk" -ErrorAction SilentlyContinue
|
||||
success "Removed Longvinter shortcut."
|
||||
}
|
||||
|
||||
# Handle commandline arguments
|
||||
if ($args.Count -eq 1)
|
||||
{
|
||||
$arg = $args[0].ToString().ToLower()
|
||||
|
||||
if ($arg -eq "getkey")
|
||||
{
|
||||
getkey
|
||||
}
|
||||
elseif ($arg -eq "update")
|
||||
{
|
||||
update
|
||||
}
|
||||
elseif ($arg -eq "backup")
|
||||
{
|
||||
backup
|
||||
}
|
||||
elseif ($arg -eq "uninstall")
|
||||
{
|
||||
Write-Host "Uninstalling the server will delete everything in this folder, including backups."
|
||||
$answer = Read-Host "> Are you sure you want to uninstall the server? y/n"
|
||||
|
||||
if ($answer.ToLower() -eq "yes" -or $answer.ToLower() -eq "y")
|
||||
{
|
||||
uninstall
|
||||
}
|
||||
}
|
||||
|
||||
Exit
|
||||
}
|
||||
|
||||
Write-Host "Please wait while everything is being checked..."
|
||||
check_software("Steam") # argument is program name.
|
||||
check_software("/usr/bin/git")
|
||||
check_git-lfs
|
||||
check_ram(3) # argument is amount of (required) RAM in GB.
|
||||
check_arch
|
||||
check_os
|
||||
|
||||
if ($IsWindows)
|
||||
{
|
||||
if ($check -eq 6)
|
||||
{
|
||||
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
|
||||
{
|
||||
Write-Host "One or more checks failed. Cannot install Longvinter (Windows) Server."
|
||||
Exit
|
||||
}
|
||||
}
|
||||
elseif ($IsLinux)
|
||||
{
|
||||
if ((id -u) -eq 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
error "Please run the script as root."
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,28 +59,16 @@ function check_software ($app)
|
|||
}
|
||||
function check_ram ($in)
|
||||
{
|
||||
if ($IsWindows)
|
||||
$total = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb
|
||||
|
||||
if ($total -gt $in)
|
||||
{
|
||||
$total = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb
|
||||
|
||||
if ($total -gt $in)
|
||||
{
|
||||
success "$total GB RAM detected."
|
||||
$global:check += 1
|
||||
}
|
||||
else
|
||||
{
|
||||
error "$in GB RAM detected. You need at least 3 GB."
|
||||
}
|
||||
success "$total GB RAM detected."
|
||||
$global:check += 1
|
||||
}
|
||||
elseif ($IsLinux)
|
||||
else
|
||||
{
|
||||
$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."
|
||||
}
|
||||
error "$in GB RAM detected. You need at least 3 GB."
|
||||
}
|
||||
}
|
||||
function check_arch
|
||||
|
@ -99,42 +87,30 @@ function check_arch
|
|||
}
|
||||
function check_os
|
||||
{
|
||||
if ($IsWindows)
|
||||
$win10 = "Microsoft Windows 10"
|
||||
$win11 = "Microsoft Windows 11"
|
||||
$os = [string](Get-CimInstance Win32_OperatingSystem).Name
|
||||
|
||||
if ($os.Contains($win11))
|
||||
{
|
||||
$win10 = "Microsoft Windows 10"
|
||||
$win11 = "Microsoft Windows 11"
|
||||
$os = [string](Get-CimInstance Win32_OperatingSystem).Name
|
||||
|
||||
if ($os.Contains($win11))
|
||||
{
|
||||
success "$win11 detected."
|
||||
$global:check += 1
|
||||
}
|
||||
elseif ($os.Contains($win10))
|
||||
{
|
||||
success "$win10 detected."
|
||||
$global:check += 1
|
||||
}
|
||||
success "$win11 detected."
|
||||
$global:check += 1
|
||||
}
|
||||
elseif ($IsMacOS)
|
||||
elseif ($os.Contains($win10))
|
||||
{
|
||||
error "Operating System is not supported yet."
|
||||
}
|
||||
elseif ($IsLinux)
|
||||
{
|
||||
success "Linux detected."
|
||||
success "$win10 detected."
|
||||
$global:check += 1
|
||||
}
|
||||
else
|
||||
{
|
||||
error "Couldn't detect Operating System."
|
||||
error "Operating System is not supported."
|
||||
}
|
||||
}
|
||||
function getkey
|
||||
{
|
||||
$exists = Test-Path -Path ".\longvinter-windows-server\Longvinter\Saved\Logs\Longvinter.log" -PathType Leaf
|
||||
|
||||
if ($exists)
|
||||
IF ($exists)
|
||||
{
|
||||
Write-Host (Select-String -Pattern "'[0-9a-f]{32}" -Path ".\longvinter-windows-server\Longvinter\Saved\Logs\Longvinter.log").Matches.groups[0].value.ToString().Replace("'", "") -NoNewline -ForegroundColor Green
|
||||
}
|
||||
|
@ -193,21 +169,19 @@ function uninstall
|
|||
# Handle commandline arguments
|
||||
if ($args.Count -eq 1)
|
||||
{
|
||||
$arg = $args[0].ToString().ToLower()
|
||||
|
||||
if ($arg -eq "getkey")
|
||||
if ($args[0].ToString().ToLower() -eq "getkey")
|
||||
{
|
||||
getkey
|
||||
}
|
||||
elseif ($arg -eq "update")
|
||||
elseif ($args[0].ToString().ToLower() -eq "update")
|
||||
{
|
||||
update
|
||||
}
|
||||
elseif ($arg -eq "backup")
|
||||
elseif ($args[0].ToString().ToLower() -eq "backup")
|
||||
{
|
||||
backup
|
||||
}
|
||||
elseif ($arg -eq "uninstall")
|
||||
elseif ($args[0].ToString().ToLower() -eq "uninstall")
|
||||
{
|
||||
Write-Host "Uninstalling the server will delete everything in this folder, including backups."
|
||||
$answer = Read-Host "> Are you sure you want to uninstall the server? y/n"
|
||||
|
@ -222,84 +196,70 @@ if ($args.Count -eq 1)
|
|||
}
|
||||
|
||||
Write-Host "Please wait while everything is being checked..."
|
||||
check_software("Steam") # argument is program name.
|
||||
check_software("Steam") # argument is program name.
|
||||
check_software("Git")
|
||||
check_git-lfs
|
||||
check_ram(3) # argument is amount of (required) RAM in GB.
|
||||
check_ram(3) # argument is amount of (required) RAM in GB.
|
||||
check_arch
|
||||
check_os
|
||||
|
||||
if ($IsWindows)
|
||||
if ($check -eq 6)
|
||||
{
|
||||
if ($check -eq 6)
|
||||
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)
|
||||
{
|
||||
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
|
||||
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."
|
||||
[/game/blueprints/server/gm_longvinter.gm_longvinter_c]
|
||||
AdminEosID=97615967659669198
|
||||
PVP=true
|
||||
TentDecay=true
|
||||
MaxTents=2
|
||||
ChestRespawnTime=600"
|
||||
}
|
||||
else
|
||||
|
||||
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")
|
||||
{
|
||||
Write-Host "One or more checks failed. Cannot install Longvinter (Windows) Server."
|
||||
Exit
|
||||
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."
|
||||
}
|
||||
elseif ($IsLinux)
|
||||
else
|
||||
{
|
||||
if ((id -u) -eq 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
error "Please run the script as root."
|
||||
}
|
||||
}
|
||||
Write-Host "One or more checks failed. Cannot install Longvinter Server."
|
||||
Exit
|
||||
}
|
Loading…
Add table
Reference in a new issue