add ZED libnotify patch to zfs
This commit is contained in:
parent
96d7aca602
commit
87bf9f5e0c
|
@ -48,4 +48,8 @@ final: prev: {
|
||||||
|
|
||||||
lix-plugins = prev.callPackage ./pkgs/lix/lix-plugins {};
|
lix-plugins = prev.callPackage ./pkgs/lix/lix-plugins {};
|
||||||
nix-plugins = builtins.throw "nix-plugins is not supported. see pkgs.lix-plugins";
|
nix-plugins = builtins.throw "nix-plugins is not supported. see pkgs.lix-plugins";
|
||||||
|
|
||||||
|
zfs_2_2 = prev.zfs_2_2.overrideAttrs {
|
||||||
|
patches = [ ./pkgs/zfs/0001-ZED-add-support-for-libnotify-notify-send.2.2.7.patch ];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
From 95b873fee26403dbd149e159016eb85c37c07f61 Mon Sep 17 00:00:00 2001
|
||||||
|
From: xenia <xenia@awoo.systems>
|
||||||
|
Date: Mon, 3 Feb 2025 21:36:29 -0500
|
||||||
|
Subject: [PATCH] ZED: add support for libnotify (notify-send)
|
||||||
|
|
||||||
|
---
|
||||||
|
cmd/zed/zed.d/zed-functions.sh | 63 ++++++++++++++++++++++++++++++++++
|
||||||
|
cmd/zed/zed.d/zed.rc | 6 ++++
|
||||||
|
2 files changed, 69 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/cmd/zed/zed.d/zed-functions.sh b/cmd/zed/zed.d/zed-functions.sh
|
||||||
|
index 3a2519633..7a1561ee1 100644
|
||||||
|
--- a/cmd/zed/zed.d/zed-functions.sh
|
||||||
|
+++ b/cmd/zed/zed.d/zed-functions.sh
|
||||||
|
@@ -209,6 +209,10 @@ zed_notify()
|
||||||
|
[ "${rv}" -eq 0 ] && num_success=$((num_success + 1))
|
||||||
|
[ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1))
|
||||||
|
|
||||||
|
+ zed_notify_libnotify "${subject}" "${pathname}"; rv=$?
|
||||||
|
+ [ "${rv}" -eq 0 ] && num_success=$((num_success + 1))
|
||||||
|
+ [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1))
|
||||||
|
+
|
||||||
|
[ "${num_success}" -gt 0 ] && return 0
|
||||||
|
[ "${num_failure}" -gt 0 ] && return 1
|
||||||
|
return 2
|
||||||
|
@@ -624,6 +628,65 @@ zed_notify_ntfy()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+# zed_notify_libnotify (subject, pathname)
|
||||||
|
+#
|
||||||
|
+# Send a notification via libnotify <https://gitlab.gnome.org/GNOME/libnotify>.
|
||||||
|
+# The variable (ZED_USE_LIBNOTIFY) defines whether to use libnotify.
|
||||||
|
+#
|
||||||
|
+# Requires libnotify executables to be installed in the standard PATH.
|
||||||
|
+#
|
||||||
|
+# References
|
||||||
|
+# https://man.archlinux.org/man/notify-send.1.en
|
||||||
|
+#
|
||||||
|
+# Arguments
|
||||||
|
+# subject: notification subject
|
||||||
|
+# pathname: pathname containing the notification message (OPTIONAL)
|
||||||
|
+#
|
||||||
|
+# Globals
|
||||||
|
+# ZED_USE_LIBNOTIFY
|
||||||
|
+#
|
||||||
|
+# Return
|
||||||
|
+# 0: notification sent
|
||||||
|
+# 1: notification failed
|
||||||
|
+# 2: not configured
|
||||||
|
+#
|
||||||
|
+zed_notify_libnotify()
|
||||||
|
+{
|
||||||
|
+ local subject="$1"
|
||||||
|
+ local pathname="${2:-"/dev/null"}"
|
||||||
|
+ local msg_body
|
||||||
|
+ local msg_out
|
||||||
|
+ local msg_err
|
||||||
|
+
|
||||||
|
+ [ -n "${ZED_USE_LIBNOTIFY}" ] || return 2
|
||||||
|
+
|
||||||
|
+ if [ ! -r "${pathname}" ]; then
|
||||||
|
+ zed_log_err "libnotify cannot read \"${pathname}\""
|
||||||
|
+ return 1
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
+ zed_check_cmd "notify-send" || return 1
|
||||||
|
+
|
||||||
|
+ # Read the message body in.
|
||||||
|
+ #
|
||||||
|
+ msg_body="$(cat "${pathname}")"
|
||||||
|
+
|
||||||
|
+ if [ -z "${msg_body}" ]
|
||||||
|
+ then
|
||||||
|
+ msg_body=$subject
|
||||||
|
+ subject=""
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
+ # Send the notification and check for errors.
|
||||||
|
+ notify-send -a ZFS -u critical -i drive-harddisk-symbolic "$subject" "$msg_body"; rv=$?
|
||||||
|
+
|
||||||
|
+ if [ "${rv}" -ne 0 ]; then
|
||||||
|
+ zed_log_err "notify-send exit=${rv}"
|
||||||
|
+ return 1
|
||||||
|
+ fi
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
|
||||||
|
# zed_rate_limit (tag, [interval])
|
||||||
|
#
|
||||||
|
diff --git a/cmd/zed/zed.d/zed.rc b/cmd/zed/zed.d/zed.rc
|
||||||
|
index 859c6f9cb..60ab46b8a 100644
|
||||||
|
--- a/cmd/zed/zed.d/zed.rc
|
||||||
|
+++ b/cmd/zed/zed.d/zed.rc
|
||||||
|
@@ -176,3 +176,9 @@ ZED_SYSLOG_SUBCLASS_EXCLUDE="history_event"
|
||||||
|
# <https://docs.ntfy.sh/install/>
|
||||||
|
# https://ntfy.sh by default; uncomment to enable an alternative service url.
|
||||||
|
#ZED_NTFY_URL="https://ntfy.sh"
|
||||||
|
+
|
||||||
|
+##
|
||||||
|
+# Whether to send notifications via libnotify
|
||||||
|
+# If defined, notify-send(1) will be used to send notifications
|
||||||
|
+# Disabled by default; uncomment to enable.
|
||||||
|
+#ZED_USE_LIBNOTIFY=1
|
||||||
|
--
|
||||||
|
2.47.0
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
From 2bcec9d74e3bf5d963ecb21bc96233e0989587dd Mon Sep 17 00:00:00 2001
|
||||||
|
From: xenia <xenia@awoo.systems>
|
||||||
|
Date: Mon, 3 Feb 2025 21:36:29 -0500
|
||||||
|
Subject: [PATCH] ZED: add support for libnotify (notify-send)
|
||||||
|
|
||||||
|
---
|
||||||
|
cmd/zed/zed.d/zed-functions.sh | 63 ++++++++++++++++++++++++++++++++++
|
||||||
|
cmd/zed/zed.d/zed.rc | 6 ++++
|
||||||
|
2 files changed, 69 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/cmd/zed/zed.d/zed-functions.sh b/cmd/zed/zed.d/zed-functions.sh
|
||||||
|
index 470739d16..579600624 100644
|
||||||
|
--- a/cmd/zed/zed.d/zed-functions.sh
|
||||||
|
+++ b/cmd/zed/zed.d/zed-functions.sh
|
||||||
|
@@ -213,6 +213,10 @@ zed_notify()
|
||||||
|
[ "${rv}" -eq 0 ] && num_success=$((num_success + 1))
|
||||||
|
[ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1))
|
||||||
|
|
||||||
|
+ zed_notify_libnotify "${subject}" "${pathname}"; rv=$?
|
||||||
|
+ [ "${rv}" -eq 0 ] && num_success=$((num_success + 1))
|
||||||
|
+ [ "${rv}" -eq 1 ] && num_failure=$((num_failure + 1))
|
||||||
|
+
|
||||||
|
[ "${num_success}" -gt 0 ] && return 0
|
||||||
|
[ "${num_failure}" -gt 0 ] && return 1
|
||||||
|
return 2
|
||||||
|
@@ -719,6 +723,65 @@ zed_notify_gotify()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+# zed_notify_libnotify (subject, pathname)
|
||||||
|
+#
|
||||||
|
+# Send a notification via libnotify <https://gitlab.gnome.org/GNOME/libnotify>.
|
||||||
|
+# The variable (ZED_USE_LIBNOTIFY) defines whether to use libnotify.
|
||||||
|
+#
|
||||||
|
+# Requires libnotify executables to be installed in the standard PATH.
|
||||||
|
+#
|
||||||
|
+# References
|
||||||
|
+# https://man.archlinux.org/man/notify-send.1.en
|
||||||
|
+#
|
||||||
|
+# Arguments
|
||||||
|
+# subject: notification subject
|
||||||
|
+# pathname: pathname containing the notification message (OPTIONAL)
|
||||||
|
+#
|
||||||
|
+# Globals
|
||||||
|
+# ZED_USE_LIBNOTIFY
|
||||||
|
+#
|
||||||
|
+# Return
|
||||||
|
+# 0: notification sent
|
||||||
|
+# 1: notification failed
|
||||||
|
+# 2: not configured
|
||||||
|
+#
|
||||||
|
+zed_notify_libnotify()
|
||||||
|
+{
|
||||||
|
+ local subject="$1"
|
||||||
|
+ local pathname="${2:-"/dev/null"}"
|
||||||
|
+ local msg_body
|
||||||
|
+ local msg_out
|
||||||
|
+ local msg_err
|
||||||
|
+
|
||||||
|
+ [ -n "${ZED_USE_LIBNOTIFY}" ] || return 2
|
||||||
|
+
|
||||||
|
+ if [ ! -r "${pathname}" ]; then
|
||||||
|
+ zed_log_err "libnotify cannot read \"${pathname}\""
|
||||||
|
+ return 1
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
+ zed_check_cmd "notify-send" || return 1
|
||||||
|
+
|
||||||
|
+ # Read the message body in.
|
||||||
|
+ #
|
||||||
|
+ msg_body="$(cat "${pathname}")"
|
||||||
|
+
|
||||||
|
+ if [ -z "${msg_body}" ]
|
||||||
|
+ then
|
||||||
|
+ msg_body=$subject
|
||||||
|
+ subject=""
|
||||||
|
+ fi
|
||||||
|
+
|
||||||
|
+ # Send the notification and check for errors.
|
||||||
|
+ notify-send -a ZFS -u critical -i drive-harddisk-symbolic "$subject" "$msg_body"; rv=$?
|
||||||
|
+
|
||||||
|
+ if [ "${rv}" -ne 0 ]; then
|
||||||
|
+ zed_log_err "notify-send exit=${rv}"
|
||||||
|
+ return 1
|
||||||
|
+ fi
|
||||||
|
+ return 0
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
|
||||||
|
# zed_rate_limit (tag, [interval])
|
||||||
|
#
|
||||||
|
diff --git a/cmd/zed/zed.d/zed.rc b/cmd/zed/zed.d/zed.rc
|
||||||
|
index af56147a9..ed71ede8c 100644
|
||||||
|
--- a/cmd/zed/zed.d/zed.rc
|
||||||
|
+++ b/cmd/zed/zed.d/zed.rc
|
||||||
|
@@ -197,3 +197,9 @@ ZED_SYSLOG_SUBCLASS_EXCLUDE="history_event"
|
||||||
|
# Gotify application associated with ZED_GOTIFY_APPTOKEN.
|
||||||
|
# Value is an integer 0 and up.
|
||||||
|
#ZED_GOTIFY_PRIORITY=""
|
||||||
|
+
|
||||||
|
+##
|
||||||
|
+# Whether to send notifications via libnotify
|
||||||
|
+# If defined, notify-send(1) will be used to send notifications
|
||||||
|
+# Disabled by default; uncomment to enable.
|
||||||
|
+#ZED_USE_LIBNOTIFY=1
|
||||||
|
--
|
||||||
|
2.47.0
|
||||||
|
|
Loading…
Reference in New Issue