Skip to content

Commit

Permalink
Fix import
Browse files Browse the repository at this point in the history
Signed-off-by: Jorgen Lundman <[email protected]>
  • Loading branch information
lundman committed Nov 22, 2024
1 parent 5830fcb commit c53bd2a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 45 deletions.
9 changes: 3 additions & 6 deletions cmd/zed/os/windows/zed.d/system_boot.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ if (Test-Path $zpoolCachePath) {
zed_log_msg LOG_NOTICE "zpool.cache found. Importing ZFS pools"

# Import ZFS pools using the zpool command and the cache file
$zpoolImportCommand = "$env:ZPOOL import -c $zpoolCachePath"

# Execute the command
$result = Invoke-Expression $zpoolImportCommand
& "$env:ZPOOL" import -c "$zpoolCachePath" -a

# Optionally, log the result or handle any output
Write-Host "ZFS Pools Imported: $result"
zed_log_msg "ZFS Pools Imported."
zed_notify "ZFS Pools Imported" "path"
} else {
Write-Host "zpool.cache not found. No pools imported."
zed_log_msg "zpool.cache not found. No pools imported."
}
37 changes: 0 additions & 37 deletions cmd/zed/os/windows/zed.d/zed-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -128,43 +128,6 @@ function zed_notify_burnttoast()

function zed_notify_toast
{
param (
[string]$title,
[string]$message
)

# Ensure UWP assemblies are loaded manually
try {
# Attempt to load the necessary UWP notifications assembly
Add-Type -AssemblyName 'Windows.Foundation.UniversalApiContract'
Add-Type -AssemblyName 'Windows.UI.Notifications'

# Create the toast notification
$toastXml = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastGeneric)

# Set up the XML toast notification content
$toastElements = $toastXml.GetElementsByTagName("binding")
$toastElements.Item(0).SetAttribute("template", "ToastGeneric")

# Set title and message
$toastXml.SelectSingleNode("//text[@id='1']").InnerText = $title
$toastXml.SelectSingleNode("//text[@id='2']").InnerText = $message

# Create the toast notification
$toast = New-Object Windows.UI.Notifications.ToastNotification $toastXml

# Create a ToastNotificationManager
$toastNotifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("OpenZFS")

# Show the notification
$toastNotifier.Show($toast)

} catch {
# If something fails (UWP API issues), log the error and return failure
zed_log_err "Failed to send toast notification: $_"
return 1
}

# If the toast notification was successfully sent, return success
return 0
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/zed/os/windows/zed.d/zed.rc
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ $env:ZED_SYSLOG_SUBCLASS_EXCLUDE="history_event"
# Use Toast notification (optional)
# If defined, use system Toast notifications
# Value is an integer 0 and up.
$env:ZED_TOAST_NOTIFICATIONS = 1
# $env:ZED_TOAST_NOTIFICATIONS=1

##
# Use BurntToast notification(optional)
# If defined, use Burnt Toast notifications
# Installed with "Install-Module -Name BurntToast -Force -AllowClobber"
# Value is an integer 0 and up.
$env:ZED_BURNTTOAST_NOTIFICATIONS = 1
# $env:ZED_BURNTTOAST_NOTIFICATIONS=1

0 comments on commit c53bd2a

Please sign in to comment.