Skip to content

Commit

Permalink
feat: install condition check & version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Jun 1, 2024
1 parent ce5cfe5 commit d2db4a9
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/playbook/Configuration/custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ actions:
# Do not change the line position of this, otherwise things will break when using local-build
# - !run: {exe: 'cmd.exe', args: '/c start "AME Wizard Live Log" PowerShell -NoP -C "gc -Wait Logs\TIOutput.txt -EA SilentlyContinue | Write-Output; pause"', baseDir: true, wait: false}

# Check various conditions to see if the user should run Atlas or not
- !powerShell:
command: '.\UPGRADECHECK.ps1'
exeDir: true
wait: true

- !writeStatus: {status: 'Copying files'}
- !cmd:
command: 'robocopy "AtlasModules" "%windir%\AtlasModules" /E /PURGE /IM /IT /NP > nul'
Expand Down
2 changes: 1 addition & 1 deletion src/playbook/Configuration/tweaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ tasks:
- tweaks\statuses\status-misc.yml
- tweaks\misc\config-time.yml
- tweaks\misc\delete-windows-specific-files.yml
- tweaks\misc\config-oem-information.yml
- tweaks\misc\rebuild-perf-counters.yml
- tweaks\misc\create-shortcuts.yml
- tweaks\misc\add-music-videos-to-home.yml
- tweaks\misc\add-newUsers-script.yml
- tweaks\scripts\script-power.yml # Done last on purpose
- tweaks\misc\enable-notifications.yml
- tweaks\misc\config-oem-information.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
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: 'Manufacturer'
data: 'Atlas Team'
type: REG_SZ
- !registryValue:
path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation'
value: 'Model'
data: 'AtlasOS v0.4.0'
type: REG_SZ
- !registryValue:
path: 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation'
value: 'SupportURL'
Expand Down
74 changes: 74 additions & 0 deletions src/playbook/Executables/UPGRADECHECK.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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 = $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 ($version -gt $installedVersion) {
@"
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
}
6 changes: 3 additions & 3 deletions src/playbook/playbook.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Playbook>
<Name>AtlasOS</Name>
<Username>Atlas</Username>
<Title>AtlasOS Playbook v0.4.0</Title>
<Title>AtlasOS Playbook v0.5.0 (dev)</Title>
<ShortDescription>AtlasOS Playbook for Windows 10 and 11</ShortDescription>
<Description><![CDATA[╭───────────── ⚠️ 𝗖𝗿𝗶𝘁𝗶𝗰𝗮𝗹 ⚠️ ─────────────╮
│    Read the Atlas documentation first.   │
Expand All @@ -12,15 +12,15 @@
Atlas makes your computer snappier and more private with lots of usability improvements.]]></Description>
<Details>An open and lightweight modification to Windows, designed to optimize performance, privacy and security.</Details>
<ProgressText><![CDATA[Atlas is currently installing software, copying its configuration folders, and tweaking Windows. If you are not already, we recommend following our documentation.]]></ProgressText>
<Version>0.4.0</Version>
<Version>0.5.0</Version>
<SupportedBuilds>
<string>19045</string>
<string>22631</string>
</SupportedBuilds>
<Requirements>
<Requirement>DefenderToggled</Requirement>
<Requirement>Internet</Requirement>
<Requirement>NoAntivirus</Requirement>
<Requirement>Internet</Requirement>
<Requirement>NoPendingUpdates</Requirement>
<Requirement>PluggedIn</Requirement>
</Requirements>
Expand Down

0 comments on commit d2db4a9

Please sign in to comment.