diff --git a/Manager.ps1 b/Manager.ps1 index 54e82b0..3a821c0 100644 --- a/Manager.ps1 +++ b/Manager.ps1 @@ -87,30 +87,42 @@ function check_arch } function check_os { - $win10 = "Microsoft Windows 10" - $win11 = "Microsoft Windows 11" - $os = [string](Get-CimInstance Win32_OperatingSystem).Name - - if ($os.Contains($win11)) + if ($IsWindows) { - success "$win11 detected." - $global:check += 1 + $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 + } } - elseif ($os.Contains($win10)) + elseif ($IsMacOS) { - success "$win10 detected." + error "Operating System is not supported yet." + } + elseif ($IsLinux) + { + success "Linux detected." $global:check += 1 } else { - error "Operating System is not supported." + error "Couldn't detect Operating System." } } 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 } @@ -169,19 +181,21 @@ function uninstall # Handle commandline arguments if ($args.Count -eq 1) { - if ($args[0].ToString().ToLower() -eq "getkey") + $arg = $args[0].ToString().ToLower() + + if ($arg -eq "getkey") { getkey } - elseif ($args[0].ToString().ToLower() -eq "update") + elseif ($arg -eq "update") { update } - elseif ($args[0].ToString().ToLower() -eq "backup") + elseif ($arg -eq "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." $answer = Read-Host "> Are you sure you want to uninstall the server? y/n"