fix(monitor): write Proxmox's notification settings only while /etc/pve is mounted

- Nothing is written under /etc/pve unless it is the mounted cluster
  filesystem; a Monitor that starts while pve-cluster is being restarted
  waits for it and registers its webhook afterwards.
- The Monitor service is ordered after pve-cluster.service.
- The settings are written only when they have to change. The copies
  taken before a change are kept in
  /usr/local/share/proxmenux/backups/pve-notifications, and the ones left
  in /etc/pve by earlier versions are moved there.
- Uninstalling the Monitor removes its target and matcher from Proxmox.

Reported in #427.
This commit is contained in:
MacRimi
2026-10-08 17:14:36 +02:00
parent 053b6c81f8
commit 07713d5365
10 changed files with 355 additions and 83 deletions
+14 -1
View File
@@ -71,6 +71,17 @@ BACKTITLE="$(translate "$BACKTITLE")"
# ==========================================================
# Proxmox would keep sending every notification to a Monitor that is gone.
# Its own interface removes the target and the rule that feeds it; the copies
# of the settings that earlier versions left in /etc/pve are removed too.
remove_monitor_notification_target() {
mountpoint -q /etc/pve || return 0
pvesh delete /cluster/notifications/matchers/proxmenux-default > /dev/null 2>&1 || true
pvesh delete /cluster/notifications/endpoints/webhook/proxmenux-webhook > /dev/null 2>&1 || true
rm -f /etc/pve/notifications.cfg.proxmenux_backup_* /etc/pve/priv/notifications.cfg.proxmenux_backup_*
echo " - Notification target removed from Proxmox"
}
uninstall_proxmenux_monitor() {
# 1. Stop service if it is running
@@ -81,6 +92,8 @@ uninstall_proxmenux_monitor() {
echo " - Service is not running (ok)"
fi
remove_monitor_notification_target
# 2. Disable service if enabled
if systemctl is-enabled --quiet "${MONITOR_SERVICE}"; then
echo " - Disabling service..."
@@ -213,7 +226,7 @@ normalize_stable_monitor_service() {
cat > "$MONITOR_UNIT_FILE" << EOF
[Unit]
Description=ProxMenux Monitor - Web Dashboard
After=network.target
After=network.target pve-cluster.service
[Service]
Type=simple