From e6a891cb229fb042c4414280b6152b07b753d032 Mon Sep 17 00:00:00 2001 From: he3als <65787561+he3als@users.noreply.github.com> Date: Sat, 15 Jun 2024 09:32:53 +0100 Subject: [PATCH] refactor: remove old checks for upgrade/downgrade --- src/playbook/Configuration/custom.yml | 4 +- .../tweaks/misc/config-oem-information.yml | 11 ++- src/playbook/Executables/INSTALLCHECK.ps1 | 13 ++++ src/playbook/Executables/UPGRADECHECK.ps1 | 74 ------------------- 4 files changed, 22 insertions(+), 80 deletions(-) create mode 100644 src/playbook/Executables/INSTALLCHECK.ps1 delete mode 100644 src/playbook/Executables/UPGRADECHECK.ps1 diff --git a/src/playbook/Configuration/custom.yml b/src/playbook/Configuration/custom.yml index 0d7203e0b9..86e4f234a1 100644 --- a/src/playbook/Configuration/custom.yml +++ b/src/playbook/Configuration/custom.yml @@ -2,9 +2,9 @@ title: Root Playbook File description: Runs all of the Playbook files actions: - # Check various conditions to see if the user should run Atlas or not + # Warn user if their Windows install is old - !powerShell: - command: '.\UPGRADECHECK.ps1' + command: '.\INSTALLCHECK.ps1' exeDir: true wait: true diff --git a/src/playbook/Configuration/tweaks/misc/config-oem-information.yml b/src/playbook/Configuration/tweaks/misc/config-oem-information.yml index 951e2ed8d5..33f4f03322 100644 --- a/src/playbook/Configuration/tweaks/misc/config-oem-information.yml +++ b/src/playbook/Configuration/tweaks/misc/config-oem-information.yml @@ -2,10 +2,11 @@ title: Configure OEM Information description: Configures OEM information to contain the Atlas version and the Atlas Discord server actions: - - !powerShell: - command: '.\UPGRADECHECK.ps1 -SetVersion' - exeDir: true - wait: true + - !registryValue: + path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation' + value: 'Model' + data: 'AtlasOS v0.5.0 (dev)' + type: REG_SZ - !registryValue: path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation' value: 'Manufacturer' @@ -21,6 +22,8 @@ actions: value: 'SupportPhone' data: 'https://github.com/Atlas-OS/Atlas' type: REG_SZ + + # Legacy, not used for anything significant - !registryValue: path: 'HKLM\SOFTWARE\Atlas' value: 'WinreFallbackFixed' diff --git a/src/playbook/Executables/INSTALLCHECK.ps1 b/src/playbook/Executables/INSTALLCHECK.ps1 new file mode 100644 index 0000000000..4b5c972af1 --- /dev/null +++ b/src/playbook/Executables/INSTALLCHECK.ps1 @@ -0,0 +1,13 @@ +if ((Get-ItemProperty $oemInfo -Name "Model" -EA 0).Model -notlike "*Atlas*") { + Write-Output "Model doesn't contain Atlas, Atlas doesn't seem to be installed currently." + if (20 -lt ((Get-Date) - (Get-CimInstance Win32_OperatingSystem).InstallDate).Days) { + @" +Windows seems to have been installed a while ago. A full Windows reinstall is highly recommended to ensure your initial install of Atlas works without problems. + +Atlas will install anyways, but remember this if there's issues. + +Follow our installation guide: https://docs.atlasos.net/getting-started/installation/ +"@ | msg * + } + exit 2 +} \ No newline at end of file diff --git a/src/playbook/Executables/UPGRADECHECK.ps1 b/src/playbook/Executables/UPGRADECHECK.ps1 deleted file mode 100644 index 8e02f95663..0000000000 --- a/src/playbook/Executables/UPGRADECHECK.ps1 +++ /dev/null @@ -1,74 +0,0 @@ -param ( [switch]$SetVersion ) - -$version = 'v0.5.0 (dev)' -$upgradableFrom = 'v0.4.0' ` - -replace '[^0-9]' -replace '^0+' - -$oemInfo = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation' -if ($SetVersion) { - Set-ItemProperty $oemInfo -Name "Model" -Value "AtlasOS $version" -Force - exit [int]$? -} - -################################################################################ - -# Kill AME and its processes -function KillAme { - $ameProcesses = Get-Process | Where-Object { - ($_.Company -like 'Ameliorated LLC*' -and $_.Description -like 'AME*') -or - $_.Name -like '*TrustedUninstaller*' - } - - if ($null -eq $ameProcesses) { - Write-Error "No AME processes found!" - while ($true) { Start-Sleep 999999999 } - } - - $ameProcesses | Stop-Process -Force - - exit 1 -} - -$version = [int]($version -replace '[^0-9]' -replace '^0+') - -# Check if Atlas is installed -$model = (Get-ItemProperty $oemInfo -Name "Model" -EA 0).Model -$guide = "Follow our installation guide: https://docs.atlasos.net/getting-started/installation/" -if ($model -notlike "*Atlas*") { - Write-Output "Model doesn't contain Atlas, Atlas doesn't seem to be installed currently." - if (20 -lt ((Get-Date) - (Get-CimInstance Win32_OperatingSystem).InstallDate).Days) { - @" -Windows seems to have been installed a while ago. A full Windows reinstall is highly recommended to ensure your initial install of Atlas works without problems. - -Atlas will install anyways, but remember this if there's issues. - -$guide -"@ | msg * - } - exit 2 -} -$installedVersion = [int]($model -replace '[^0-9]' -replace '^0+') - -# Check if you can upgrade -if ($upgradableFrom -gt $installedVersion) { - @" -You can't upgrade from your current version of Atlas to this newer version. Only upgrades from Atlas v0.4.0 and onwards are supported. - -We are sorry for the inconvenience. - -$guide -"@ | msg * - - KillAme -} - -# Check if user is trying to downgrade -if ($installedVersion -gt $version) { - @" -You can't downgrade from your current version of Atlas to this older version. - -If there's an issue with the newest release, consider filing an issue on GitHub: https://github.com/Atlas-OS/Atlas/issues -"@ | msg * - - KillAme -} \ No newline at end of file