From d1c0d047193d5638dcf42a1bfa37e046abd607cb Mon Sep 17 00:00:00 2001
From: Leonardo Fagundes Luz Serrano
 <Leonardo.FagundesLuzSerrano@windriver.com>
Date: Thu, 15 Sep 2022 15:04:52 -0300
Subject: [PATCH] Debian: Remove conf files from etc-pmon.d

Removed conf files from /etc/pmon.d/
as they are being moved to another location.

This is part of an effort to allow pmon conf files
to be selected at runtime by kickstarts.

The change is debian-only, since centos support
will be dropped soon.
Centos' pmon conf files remain in /etc/pmon.d/

Test Plan:
PASS - deb doesn't install anything to /etc/pmon.d/
PASS - rpm files unchanged
PASS - AIOSX unlocked-enabled-available
PASS - Standard 2+2 unlocked-enabled-available

Story: 2010211
Task: 46306

Depends-On: https://review.opendev.org/c/starlingx/metal/+/855095

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: I086db0750df5626d2a8ba1010153ce4f45535ca5
---
 .../debian/deb_folder/mtce-control.install    |  1 -
 mtce-control/debian/deb_folder/rules          |  3 +-
 mtce-control/src/Makefile                     |  7 ++--
 mtce/debian/deb_folder/mtce-lmon.install      |  1 -
 mtce/debian/deb_folder/mtce.install           |  9 -----
 mtce/debian/deb_folder/rules                  | 38 ++++++-------------
 6 files changed, 16 insertions(+), 43 deletions(-)

diff --git a/mtce-control/debian/deb_folder/mtce-control.install b/mtce-control/debian/deb_folder/mtce-control.install
index 3f191b67..308409df 100644
--- a/mtce-control/debian/deb_folder/mtce-control.install
+++ b/mtce-control/debian/deb_folder/mtce-control.install
@@ -2,5 +2,4 @@ debian/systemd/00-mtce-control.preset etc/systemd/system-preset
 lib/systemd/system/hbsAgent.service
 etc/init.d/goenabledControl
 etc/init.d/hbsAgent
-etc/pmon.d/hbsAgent.conf
 usr/share/starlingx/pmon.d/hbsAgent.conf
diff --git a/mtce-control/debian/deb_folder/rules b/mtce-control/debian/deb_folder/rules
index 54a1530f..8ca4ac1a 100644
--- a/mtce-control/debian/deb_folder/rules
+++ b/mtce-control/debian/deb_folder/rules
@@ -12,10 +12,9 @@ override_dh_auto_install:
 		_sysconfdir=/etc \
 		_unitdir=/lib/systemd/system \
 		_datarootdir=/usr/share \
+		PMONDIR=$(PMONDIR) \
 		install
 
-	install -m 644 -p -D scripts/hbsAgent.conf $(ROOT)/$(PMONDIR)/hbsAgent.conf
-
 	dh_install
 
 override_dh_installsystemd:
diff --git a/mtce-control/src/Makefile b/mtce-control/src/Makefile
index aaa3de7f..f68875c9 100755
--- a/mtce-control/src/Makefile
+++ b/mtce-control/src/Makefile
@@ -4,7 +4,7 @@ SOURCE3 = hbsAgent
 SOURCE4 = hbsAgent.conf
 SOURCE5 = hbsAgent.service
 
-local_etc_pmond = $(_sysconfdir)/pmon.d
+PMONDIR ?= $(_sysconfdir)/pmon.d
 local_etc_goenabledd = $(_sysconfdir)/goenabled.d
 
 .PHONY: default
@@ -21,12 +21,11 @@ install:
 	install -m 755 -p -D scripts/$(SOURCE3) $(buildroot)/$(_sysconfdir)/init.d/hbsAgent
 
 	# Controller-Only Process Monitor Config files
-	install -m 755 -d $(buildroot)/$(local_etc_pmond)
-	install -m 644 -p -D scripts/$(SOURCE4) $(buildroot)/$(local_etc_pmond)/hbsAgent.conf
+	install -m 755 -d $(buildroot)/$(PMONDIR)
+	install -m 644 -p -D scripts/$(SOURCE4) $(buildroot)/$(PMONDIR)/hbsAgent.conf
 
 	# Controller-Only Heartbeat Service file
 	install -m 644 -p -D scripts/$(SOURCE5) $(buildroot)/$(_unitdir)/hbsAgent.service
 
 	# Controller-Only Go Enabled Test
 	install -m 755 -d $(buildroot)/$(local_etc_goenabledd)
-
diff --git a/mtce/debian/deb_folder/mtce-lmon.install b/mtce/debian/deb_folder/mtce-lmon.install
index 585617a8..d8d0bfea 100644
--- a/mtce/debian/deb_folder/mtce-lmon.install
+++ b/mtce/debian/deb_folder/mtce-lmon.install
@@ -1,6 +1,5 @@
 etc/init.d/lmon
 etc/logrotate.d/lmon.logrotate
 etc/mtc/lmond.conf
-etc/pmon.d/lmon.conf
 usr/local/bin/lmond
 usr/share/starlingx/pmon.d/lmon.conf
diff --git a/mtce/debian/deb_folder/mtce.install b/mtce/debian/deb_folder/mtce.install
index 4566f243..3a6dd360 100644
--- a/mtce/debian/deb_folder/mtce.install
+++ b/mtce/debian/deb_folder/mtce.install
@@ -18,15 +18,6 @@ etc/mtc.conf
 etc/mtc.ini
 etc/mtc/fsmond.conf
 etc/mtc/tmp
-etc/pmon.d/acpid.conf
-etc/pmon.d/fsmon.conf
-etc/pmon.d/hbsClient.conf
-etc/pmon.d/mtcClient.conf
-etc/pmon.d/mtcalarm.conf
-etc/pmon.d/mtclogd.conf
-etc/pmon.d/sssd.conf
-etc/pmon.d/sshd.conf
-etc/pmon.d/syslog-ng.conf
 etc/services.d/controller/mtcTest
 etc/services.d/storage/mtcTest
 etc/services.d/worker/mtcTest
diff --git a/mtce/debian/deb_folder/rules b/mtce/debian/deb_folder/rules
index c2f116f4..d377ffd7 100644
--- a/mtce/debian/deb_folder/rules
+++ b/mtce/debian/deb_folder/rules
@@ -9,14 +9,13 @@ export OCFPLATFORMDIR = $(ROOT)/usr/lib/ocf/resource.d/platform
 export SBINDIR = $(ROOT)/usr/sbin
 export LOCAL_SBINDIR = $(ROOT)/usr/local/sbin
 export UNITDIR = $(ROOT)/lib/systemd/system
-export PMONDIR_1 = $(ROOT)/usr/share/starlingx/pmon.d
+export PMONDIR = $(ROOT)/usr/share/starlingx/pmon.d
 
 export SYSCONFDIR = $(ROOT)/etc
 export BMCCONFDIR = $(SYSCONFDIR)/bmc/server_profiles.d
 export COLLECTDIR = $(SYSCONFDIR)/collect.d
 export INITDIR =$(SYSCONFDIR)/init.d
 export LOGDIR = $(SYSCONFDIR)/logrotate.d
-export PMONDIR_2 = $(SYSCONFDIR)/pmon.d
 export SERVICESDIR = $(SYSCONFDIR)/services.d
 
 export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
@@ -107,30 +106,17 @@ override_dh_auto_install:
 	install -m 755 -p -D scripts/dmemchk.sh $(SBINDIR)
 
 	# Process monitor config files
-	install -m 755 -d $(PMONDIR_1)
-	install -m 644 -p -D scripts/mtcClient.conf $(PMONDIR_1)/mtcClient.conf
-	install -m 644 -p -D scripts/hbsClient.conf $(PMONDIR_1)/hbsClient.conf
-	install -m 644 -p -D pmon/scripts/acpid.conf $(PMONDIR_1)/acpid.conf
-	install -m 644 -p -D pmon/scripts/sshd.conf $(PMONDIR_1)/sshd.conf
-	install -m 644 -p -D pmon/scripts/syslog-ng.conf $(PMONDIR_1)/syslog-ng.conf
-	install -m 644 -p -D pmon/scripts/sssd.conf $(PMONDIR_1)/sssd.conf
-	install -m 644 -p -D fsmon/scripts/fsmon.conf $(PMONDIR_1)/fsmon.conf
-	install -m 644 -p -D scripts/mtclogd.conf $(PMONDIR_1)/mtclogd.conf
-	install -m 644 -p -D alarm/scripts/mtcalarm.pmon.conf $(PMONDIR_1)/mtcalarm.conf
-	install -m 644 -p -D lmon/scripts/lmon.pmon.conf $(PMONDIR_1)/lmon.conf
-
-	# Process monitor config files - temporary duplicate of pmon.d files
-	install -m 755 -d $(PMONDIR_2)
-	install -m 644 -p -D scripts/mtcClient.conf $(PMONDIR_2)/mtcClient.conf
-	install -m 644 -p -D scripts/hbsClient.conf $(PMONDIR_2)/hbsClient.conf
-	install -m 644 -p -D pmon/scripts/acpid.conf $(PMONDIR_2)/acpid.conf
-	install -m 644 -p -D pmon/scripts/sshd.conf $(PMONDIR_2)/sshd.conf
-	install -m 644 -p -D pmon/scripts/syslog-ng.conf $(PMONDIR_2)/syslog-ng.conf
-	install -m 644 -p -D pmon/scripts/sssd.conf $(PMONDIR_2)/sssd.conf
-	install -m 644 -p -D fsmon/scripts/fsmon.conf $(PMONDIR_2)/fsmon.conf
-	install -m 644 -p -D scripts/mtclogd.conf $(PMONDIR_2)/mtclogd.conf
-	install -m 644 -p -D alarm/scripts/mtcalarm.pmon.conf $(PMONDIR_2)/mtcalarm.conf
-	install -m 644 -p -D lmon/scripts/lmon.pmon.conf $(PMONDIR_2)/lmon.conf
+	install -m 755 -d $(PMONDIR)
+	install -m 644 -p -D scripts/mtcClient.conf $(PMONDIR)/mtcClient.conf
+	install -m 644 -p -D scripts/hbsClient.conf $(PMONDIR)/hbsClient.conf
+	install -m 644 -p -D pmon/scripts/acpid.conf $(PMONDIR)/acpid.conf
+	install -m 644 -p -D pmon/scripts/sshd.conf $(PMONDIR)/sshd.conf
+	install -m 644 -p -D pmon/scripts/syslog-ng.conf $(PMONDIR)/syslog-ng.conf
+	install -m 644 -p -D pmon/scripts/sssd.conf $(PMONDIR)/sssd.conf
+	install -m 644 -p -D fsmon/scripts/fsmon.conf $(PMONDIR)/fsmon.conf
+	install -m 644 -p -D scripts/mtclogd.conf $(PMONDIR)/mtclogd.conf
+	install -m 644 -p -D alarm/scripts/mtcalarm.pmon.conf $(PMONDIR)/mtcalarm.conf
+	install -m 644 -p -D lmon/scripts/lmon.pmon.conf $(PMONDIR)/lmon.conf
 
 	# Log rotation
 	install -m 755 -d $(LOGDIR)