Skip to content

Commit 4c8af2f

Browse files
committed
internal/worker/scripts: Add logging to powershell scripts
Signed-off-by: Max Asnaashari <max.asna@futurfusion.io>
1 parent 23ae9aa commit 4c8af2f

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
$ErrorActionPreference = 'Stop'
22

3+
set-content -path "C:\AppData\migration-manager\first-boot.log" -value "Beginning post-migration first-boot service"
4+
35
# Delete the service so it doesn't run again.
46
reg delete "hklm\system\currentcontrolset\services\migrationmanagerfirstboot" /f
57

@@ -9,19 +11,28 @@ remove-item "C:\migration-manager-first-boot.ps1"
911
# Run the Incus agent if present.
1012
foreach ($drive in get-psdrive -psprovider filesystem) {
1113
if (test-path "$($drive.Root)\incus-agent") {
12-
start-process powershell.exe -argumentlist "-file `"$($drive.Root)\install.ps1`"" -wait
14+
add-content -path "C:\AppData\migration-manager\first-boot.log" -value "Installing Incus Agent"
15+
#start-process powershell.exe -argumentlist "-file `"$($drive.Root)\install.ps1`"" -wait
16+
17+
$cmd = '-command "& ''{0}\install.ps1'' *> ''C:\AppData\migration-manager\incus-agent.log''"' -f "$($drive.Root)"
18+
start-process powershell.exe -argumentlist $cmd -wait
1319
break
1420
}
1521
}
1622

1723
# Bring disks that had a drive letter online.
1824
if (test-path "C:\migration-manager-virtio-assign-diskcfg.ps1") {
19-
start-process powershell.exe -argumentlist "-file `"C:\migration-manager-virtio-assign-diskcfg.ps1`"" -wait
25+
add-content -path "C:\AppData\migration-manager\first-boot.log" -value "Reassigning drive letters"
26+
27+
$cmd = '-command "& ''C:\migration-manager-virtio-assign-diskcfg.ps1'' *> ''C:\AppData\migration-manager\disk-assign.log''"'
28+
start-process powershell.exe -argumentlist $cmd -wait
2029
}
2130

2231
# Run network config reassignment if present.
2332
if (test-path "C:\migration-manager-virtio-assign-netcfg.ps1") {
24-
$cmd = '-command "& ''C:\migration-manager-virtio-assign-netcfg.ps1'' *> ''C:\migration-manager-net.log''"'
33+
add-content -path "C:\AppData\migration-manager\first-boot.log" -value "Reassigning network configs"
34+
35+
$cmd = '-command "& ''C:\migration-manager-virtio-assign-netcfg.ps1'' *> ''C:\AppData\migration-manager\net-assign.log''"'
2536
start-process powershell.exe -argumentlist $cmd -wait
2637
}
2738

internal/worker/scripts/virtio-assign-diskcfg.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
$ErrorActionPreference = 'Stop'
22

3+
write-output "Starting Drive letter reassignment"
4+
35
# Delete the script file before continuing any further.
46
remove-item "C:\migration-manager-virtio-assign-diskcfg.ps1"
57

@@ -12,17 +14,22 @@ remove-item "C:\migration_manager_disk_ids"
1214
$disks = @()
1315
$ids | foreach-object {
1416
$id = $_
17+
18+
write-output (" Checking ID {0}" -f $id)
1519
if ($id -match '^{') {
1620
# GPT
1721
$part = get-partition | where-object { $_.guid -eq $id }
1822
$disk = get-disk -number $part.disknumber
1923
$disks += $disk
24+
25+
write-output (" Matching GPT Disk: {0} Part: {1}" -f $disk.number, $part.disknumber)
2026
} else {
2127
# MBR
2228
$disk = get-disk | where-object { $_.signature -eq $id }
2329
$disks += $disk
24-
}
2530

31+
write-output (" Matching MBR Disk: {0}" -f $disk.number)
32+
}
2633
}
2734

2835
# Bring online each disk that had a drive letter assigned in the previous boot.

0 commit comments

Comments
 (0)