nut: fix custom notification messages

Messages with spaces must be enclosed in double-quotes.

Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
This commit is contained in:
Daniel F. Dickinson authored and Josef Schlehofer committed 2026-09-10 10:22:36 +02:00
1 parent cf415f3e64
commit 5bdf894102
1 file changed
+2 -1
@@ -61,7 +61,8 @@ nut_get_notifications() {
if [ "${event_types#*" $event "}" != "${event_types}" ]; then
config_get val "$event" message
if [ -n "$val" ]; then
if ! printf 'NOTIFYMSG %s %s\n' "$event" "$val" >>"$config_file"; then
val="$(printf '%s' "$val" | tr -d '"')"
if ! printf 'NOTIFYMSG %s "%s"\n' "$event" "$val" >>"$config_file"; then
log_error "upsmon section '$event' failed to write 'NOTIFYMSG' for '$event'" nut-monitor-config.sh nut-monitor-config
return 1
fi