[pve-devel] [PATCH manager] debian: postinst: copy notifications.cfg from /usr/share/pve-manager

Lukas Wagner l.wagner at proxmox.com
Thu Nov 9 14:50:07 CET 2023


... instead of using a heredoc in postinst script.

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
Requires
"debian: postinst: create notifications.cfg if it does not exist "[1]

from the 
"overhaul notification system, use matchers instead of filters"
patch series

[1] https://lists.proxmox.com/pipermail/pve-devel/2023-November/059824.html

 configs/Makefile          |  1 +
 configs/notifications.cfg |  7 +++++++
 debian/postinst           | 17 +----------------
 3 files changed, 9 insertions(+), 16 deletions(-)
 create mode 100644 configs/notifications.cfg

diff --git a/configs/Makefile b/configs/Makefile
index fd446b5b..575c48b9 100644
--- a/configs/Makefile
+++ b/configs/Makefile
@@ -13,6 +13,7 @@ install: country.dat vzdump.conf pve-sources.list pve-initramfs.conf pve-blackli
 	install -D -m 0644 vzdump.conf $(DESTDIR)/etc/vzdump.conf
 	install -D -m 0644 pve-initramfs.conf $(DESTDIR)/etc/initramfs-tools/conf.d/pve-initramfs.conf
 	install -D -m 0644 country.dat $(DESTDIR)/usr/share/$(PACKAGE)/country.dat
+	install -D -m 0644 notifications.cfg $(DESTDIR)/usr/share/$(PACKAGE)/notifications.cfg
 
 clean:
 	rm -f country.dat
diff --git a/configs/notifications.cfg b/configs/notifications.cfg
new file mode 100644
index 00000000..57c496c5
--- /dev/null
+++ b/configs/notifications.cfg
@@ -0,0 +1,7 @@
+sendmail: default-target
+        mailto-user root at pam
+        comment Send mails to root at pam's email address
+
+matcher: default-matcher
+        target default-target
+        comment Send all notifications to 'default-target'
diff --git a/debian/postinst b/debian/postinst
index 7dad2b1a..3f941486 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -93,27 +93,12 @@ migrate_apt_auth_conf() {
     fi
 }
 
-write_notification_cfg() {
-        # Create default config:
-        # A sendmail-target that sends to root at pam, and a
-        # matcher that sends all notifications to this target
-        cat >> /etc/pve/notifications.cfg <<EOF
-sendmail: default-target
-        mailto-user root at pam
-        comment Send mails to root at pam's email address
-
-matcher: default-matcher
-        target default-target
-        comment Send all notifications to 'default-target'
-EOF
-}
-
 create_default_notification_cfg() {
     if ! test -f /etc/pve/notifications.cfg ; then
         echo "Creating default 'notifications.cfg' file"
 
         # Only warn in case we cannot write to pmxcfs
-        if ! write_notification_cfg ; then
+        if ! cp /usr/share/pve-manager/notifications.cfg /etc/pve/notifications.cfg ; then
             echo "Could not create default 'notifications.cfg' file"
         fi
     fi
-- 
2.39.2






More information about the pve-devel mailing list