From b7acb605eec1365abe3bb2dbb24efe6f5e98a974 Mon Sep 17 00:00:00 2001 From: Kevin Adams Date: Sat, 20 Jun 2026 12:07:40 -0400 Subject: [PATCH] fix: strip pre-existing unmanaged devices block before injecting managed stanza If /etc/multipath.conf already had a manual devices{} block before package install, postinst would append a second identical block, causing multipathd to emit "duplicate keyword: devices" warnings. Strip any unmanaged devices block in the append path to keep the file clean. Fixes #279. Discovered 2026-06-20 on pve01-hq during SCALE 25.04 multipath testing. Co-Authored-By: Claude Sonnet 4.6 --- packaging/DEBIAN-multipath/postinst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packaging/DEBIAN-multipath/postinst b/packaging/DEBIAN-multipath/postinst index e5f2b80..8c0cd67 100644 --- a/packaging/DEBIAN-multipath/postinst +++ b/packaging/DEBIAN-multipath/postinst @@ -70,6 +70,14 @@ STANZA "$MULTIPATH_CONF" else log "Appending TrueNAS device stanza to existing ${MULTIPATH_CONF}" + # Strip any pre-existing unmanaged devices block to prevent duplicate + # keyword warnings in multipathd (e.g. user had a manual block before install). + if grep -qE '^\s*devices\s*\{' "$MULTIPATH_CONF"; then + log "Removing pre-existing unmanaged devices block from ${MULTIPATH_CONF}" + perl -i -0777 -pe \ + 's/\n*\ndevices\s*\{(?:[^{}]*|\{[^{}]*\})*\}\n*//gs' \ + "$MULTIPATH_CONF" + fi printf '\n%s\n' "$stanza" >> "$MULTIPATH_CONF" fi