mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-02 19:02:31 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user