Updated Manager.ps1 with W.I.P. Linux support.

This commit is contained in:
Yuuki Chan 2023-03-06 18:33:09 +09:00
parent b0302f8950
commit bd9d97f6d8

View file

@ -87,6 +87,8 @@ function check_arch
} }
function check_os function check_os
{ {
if ($IsWindows)
{
$win10 = "Microsoft Windows 10" $win10 = "Microsoft Windows 10"
$win11 = "Microsoft Windows 11" $win11 = "Microsoft Windows 11"
$os = [string](Get-CimInstance Win32_OperatingSystem).Name $os = [string](Get-CimInstance Win32_OperatingSystem).Name
@ -101,16 +103,26 @@ function check_os
success "$win10 detected." success "$win10 detected."
$global:check += 1 $global:check += 1
} }
}
elseif ($IsMacOS)
{
error "Operating System is not supported yet."
}
elseif ($IsLinux)
{
success "Linux detected."
$global:check += 1
}
else else
{ {
error "Operating System is not supported." error "Couldn't detect Operating System."
} }
} }
function getkey function getkey
{ {
$exists = Test-Path -Path ".\longvinter-windows-server\Longvinter\Saved\Logs\Longvinter.log" -PathType Leaf $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 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
} }
@ -169,19 +181,21 @@ function uninstall
# Handle commandline arguments # Handle commandline arguments
if ($args.Count -eq 1) if ($args.Count -eq 1)
{ {
if ($args[0].ToString().ToLower() -eq "getkey") $arg = $args[0].ToString().ToLower()
if ($arg -eq "getkey")
{ {
getkey getkey
} }
elseif ($args[0].ToString().ToLower() -eq "update") elseif ($arg -eq "update")
{ {
update update
} }
elseif ($args[0].ToString().ToLower() -eq "backup") elseif ($arg -eq "backup")
{ {
backup backup
} }
elseif ($args[0].ToString().ToLower() -eq "uninstall") elseif ($arg -eq "uninstall")
{ {
Write-Host "Uninstalling the server will delete everything in this folder, including backups." 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" $answer = Read-Host "> Are you sure you want to uninstall the server? y/n"