Compare commits
3 commits
9536ec9f8d
...
7bb0f9b6a3
Author | SHA1 | Date | |
---|---|---|---|
Manuel Thalmann | 7bb0f9b6a3 | ||
Manuel Thalmann | 242a6f1e94 | ||
Manuel Thalmann | 79aafce443 |
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.fish text eol=lf
|
||||||
|
*.sh text eol=lf
|
|
@ -11,11 +11,18 @@ enum WindowsInstallerStage {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SetupStage {
|
enum SetupStage {
|
||||||
|
Initialize
|
||||||
Configure
|
Configure
|
||||||
Install
|
Install
|
||||||
CreateUser
|
CreateUser
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum BackupStage {
|
||||||
|
Initialize
|
||||||
|
Backup
|
||||||
|
BackupUsers
|
||||||
|
}
|
||||||
|
|
||||||
enum UserStage {
|
enum UserStage {
|
||||||
Create
|
Create
|
||||||
Configure
|
Configure
|
||||||
|
@ -27,6 +34,7 @@ $null = New-Module {
|
||||||
[string] $configRoot = "HKLM:\Software\PortValhalla";
|
[string] $configRoot = "HKLM:\Software\PortValhalla";
|
||||||
[string] $stageOption = "Stage";
|
[string] $stageOption = "Stage";
|
||||||
[string] $setupStageOption = "SetupStage";
|
[string] $setupStageOption = "SetupStage";
|
||||||
|
[string] $backupStageOption = "BackupStage";
|
||||||
[string] $userOption = "SetupUser";
|
[string] $userOption = "SetupUser";
|
||||||
[string] $userStageOption = "UserStage";
|
[string] $userStageOption = "UserStage";
|
||||||
[string] $accountOption = "MSAccount";
|
[string] $accountOption = "MSAccount";
|
||||||
|
@ -164,7 +172,7 @@ $null = New-Module {
|
||||||
|
|
||||||
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
||||||
|
|
||||||
if ($env:CONFIG_NAME) {
|
if ($env:CONFIG_NAME -or ($Script -eq "getProfiles")) {
|
||||||
$output = & {
|
$output = & {
|
||||||
if (-not $IsWindows) {
|
if (-not $IsWindows) {
|
||||||
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
||||||
|
@ -408,6 +416,39 @@ $null = New-Module {
|
||||||
$null = Set-SetupOption $setupStageOption $Name;
|
$null = Set-SetupOption $setupStageOption $Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the name of the current stage of the backup.
|
||||||
|
#>
|
||||||
|
function Get-BackupStage {
|
||||||
|
$stage = Get-SetupOption $backupStageOption;
|
||||||
|
|
||||||
|
if ($null -ne $stage) {
|
||||||
|
$stage = [BackupStage]$stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sets the current stage of the backup.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name to set the current stage to.
|
||||||
|
#>
|
||||||
|
function Set-BackupStage {
|
||||||
|
param(
|
||||||
|
$Name
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not (($null -eq $Name) -or ($Name -is [string]))) {
|
||||||
|
$Name = ([BackupStage]$Name).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
$null = Set-SetupOption $backupStageOption $Name;
|
||||||
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Gets the current user to set up.
|
Gets the current user to set up.
|
||||||
|
|
|
@ -259,6 +259,10 @@ $null = New-Module {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (-not $env:CONFIG_NAME) {
|
||||||
|
Show-ProfileNamePrompt;
|
||||||
|
}
|
||||||
|
|
||||||
$initialized = $true;
|
$initialized = $true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
scripts/Windows/OS/Backup.ps1
Normal file
4
scripts/Windows/OS/Backup.ps1
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/pwsh
|
||||||
|
. "$PSScriptRoot/Manage.ps1";
|
||||||
|
$env:INSTALLER_SCRIPT = "$PSCommandPath";
|
||||||
|
Start-WindowsBackup;
|
|
@ -35,6 +35,16 @@ $null = New-Module {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Creates a backup of the current Windows machine.
|
||||||
|
#>
|
||||||
|
function Start-WindowsBackup {
|
||||||
|
Start-Operation -NoImplicitCleanup {
|
||||||
|
Start-InstallationLoop ([WindowsInstallerAction]::Backup);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Starts the installation loop.
|
Starts the installation loop.
|
||||||
|
@ -86,9 +96,12 @@ $null = New-Module {
|
||||||
|
|
||||||
switch (Get-SetupStage) {
|
switch (Get-SetupStage) {
|
||||||
($null) {
|
($null) {
|
||||||
Set-SetupStage ([SetupStage]::Configure);
|
Set-SetupStage ([SetupStage]::Initialize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
([SetupStage]::Initialize) {
|
||||||
|
Set-SetupStage ([SetupStage]::Configure);
|
||||||
|
}
|
||||||
([SetupStage]::Configure) {
|
([SetupStage]::Configure) {
|
||||||
if (Get-Config "valhalla.windows.dualboot.enable") {
|
if (Get-Config "valhalla.windows.dualboot.enable") {
|
||||||
if (-not (Test-Qemu)) {
|
if (-not (Test-Qemu)) {
|
||||||
|
@ -120,6 +133,8 @@ $null = New-Module {
|
||||||
Write-Host "Entering install phase";
|
Write-Host "Entering install phase";
|
||||||
Deploy-SoftwareAction;
|
Deploy-SoftwareAction;
|
||||||
Set-SetupStage ([SetupStage]::CreateUser);
|
Set-SetupStage ([SetupStage]::CreateUser);
|
||||||
|
Restart-Intermediate;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
([SetupStage]::CreateUser) {
|
([SetupStage]::CreateUser) {
|
||||||
Install-ValhallaUsers;
|
Install-ValhallaUsers;
|
||||||
|
@ -128,6 +143,61 @@ $null = New-Module {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
([WindowsInstallerAction]::Backup) {
|
||||||
|
$finished = $false;
|
||||||
|
|
||||||
|
$adminGroup = @{
|
||||||
|
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
||||||
|
};
|
||||||
|
|
||||||
|
while (-not $finished) {
|
||||||
|
switch (Get-BackupStage) {
|
||||||
|
$null {
|
||||||
|
Set-BackupStage ([BackupStage]::Initialize);
|
||||||
|
}
|
||||||
|
([BackupStage]::Initialize) {
|
||||||
|
$user = Get-SetupUser;
|
||||||
|
Add-LocalUser $user;
|
||||||
|
Add-LocalGroupMember -Member "$user" @adminGroup;
|
||||||
|
Set-AutologinUser $user;
|
||||||
|
Disable-UAC;
|
||||||
|
Set-BackupStage ([BackupStage]::Backup);
|
||||||
|
Restart-Intermediate;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
([BackupStage]::Backup) {
|
||||||
|
Deploy-SoftwareAction ([InstallerAction]::Backup);
|
||||||
|
Set-BackupStage ([BackupStage]::BackupUsers);
|
||||||
|
}
|
||||||
|
([BackupStage]::BackupUsers) {
|
||||||
|
$users = @(Get-Users);
|
||||||
|
$i = Get-CurrentUser;
|
||||||
|
|
||||||
|
for (; $i -lt $users.Count; $i++) {
|
||||||
|
Set-CurrentUser $i;
|
||||||
|
$user = $users[$i];
|
||||||
|
|
||||||
|
if ($env:UserName -ne $user) {
|
||||||
|
Set-BootMessage "Please Log In" "Please log in with the user ``$user``";
|
||||||
|
Add-LocalGroupMember -Member "$user" @adminGroup -ErrorAction SilentlyContinue;
|
||||||
|
Restart-Intermediate;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Deploy-SoftwareAction -Action ([InstallerAction]::BackupUser);
|
||||||
|
Remove-LocalGroupMember -Member "$user" @adminGroup;
|
||||||
|
|
||||||
|
foreach ($group in Get-UserConfig -UserName "$user" "groups") {
|
||||||
|
Add-LocalGroupMember -Member "$user" $group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Disable-BootMessage;
|
||||||
|
$finished = $true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Set-Stage ([WindowsInstallerStage]::Cleanup);
|
Set-Stage ([WindowsInstallerStage]::Cleanup);
|
||||||
|
|
|
@ -53,7 +53,7 @@ $null = New-Module {
|
||||||
function Get-StartupCommand {
|
function Get-StartupCommand {
|
||||||
($env:PWSH_PATH ? "`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);" : "") +
|
($env:PWSH_PATH ? "`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);" : "") +
|
||||||
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
||||||
($env:BACKUP_ARCHIVE ? "`$env:BACKUP_ARCHIVE = $(ConvertTo-Injection (Resolve-Path $env:BACKUP_ARCHIVE));" : "") +
|
($env:BACKUP_ARCHIVE ? "`$env:BACKUP_ARCHIVE = $(ConvertTo-Injection ([System.IO.Path]::GetFullPath($env:BACKUP_ARCHIVE)));" : "") +
|
||||||
"`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" +
|
"`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" +
|
||||||
"`$env:CONFIG_NAME = $(ConvertTo-Injection $env:CONFIG_NAME);" +
|
"`$env:CONFIG_NAME = $(ConvertTo-Injection $env:CONFIG_NAME);" +
|
||||||
"& `$env:INSTALLER_SCRIPT;";
|
"& `$env:INSTALLER_SCRIPT;";
|
||||||
|
|
Loading…
Reference in a new issue