From 4c8abe18d3e7447c425b19f93d7959a15ac729c0 Mon Sep 17 00:00:00 2001 From: Matheus Machado Guilhermino Date: Fri, 14 Jan 2022 10:50:09 -0300 Subject: [PATCH] Fix failing mtce services on Debian Modified mtce and mtce-control to address the following failing services on Debian: hbsAgent.service hbsClient.service hwmon.service lmon.service mtcalarm.service mtclog.service runservices.service Applied fix: - Included modified .service files for debian directly into into the deb_folder. - Changed the init files to account for the different locations of the init-functions and service daemons on Debian and CentOS - Included "override_dh_installsystemd" section to rules in order to start services at boot. Test Plan: PASS: Package installed and ISO built successfully PASS: Ran "systemctl list-units --failed" and verified that the services are not failing PASS: Ran "systemctl status " for each service and verified that they are active Story: 2009101 Task: 44192 Signed-off-by: Matheus Machado Guilhermino Change-Id: I50915c17d6f50f5e20e6448d3e75bfe54a75acc0 --- .../debian/deb_folder/hbsAgent.service | 13 +++++++++++ .../debian/deb_folder/mtce-control.install | 1 - mtce-control/debian/deb_folder/rules | 6 ++--- mtce-control/src/scripts/hbsAgent | 16 +++++++++++-- mtce/debian/deb_folder/hbsClient.service | 23 +++++++++++++++++++ mtce/debian/deb_folder/hwmon.service | 16 +++++++++++++ mtce/debian/deb_folder/lmon.service | 17 ++++++++++++++ mtce/debian/deb_folder/mtcalarm.service | 14 +++++++++++ mtce/debian/deb_folder/mtce-hwmon.install | 3 +-- mtce/debian/deb_folder/mtce-lmon.install | 1 - mtce/debian/deb_folder/mtce-pmon.install | 2 +- mtce/debian/deb_folder/mtce.install | 6 +---- mtce/debian/deb_folder/mtclog.service | 23 +++++++++++++++++++ mtce/debian/deb_folder/rules | 14 ++++++----- mtce/debian/deb_folder/runservices.service | 12 ++++++++++ mtce/debian/mtce-hostw.install | 2 +- mtce/src/alarm/scripts/mtcalarm.init | 16 +++++++++++-- mtce/src/hwmon/scripts/lsb/hwmon | 16 +++++++++++-- mtce/src/lmon/scripts/lmon | 16 +++++++++++-- mtce/src/scripts/hbsClient | 16 +++++++++++-- mtce/src/scripts/mtclog | 16 +++++++++++-- 21 files changed, 217 insertions(+), 32 deletions(-) create mode 100644 mtce-control/debian/deb_folder/hbsAgent.service create mode 100644 mtce/debian/deb_folder/hbsClient.service create mode 100644 mtce/debian/deb_folder/hwmon.service create mode 100644 mtce/debian/deb_folder/lmon.service create mode 100644 mtce/debian/deb_folder/mtcalarm.service create mode 100644 mtce/debian/deb_folder/mtclog.service create mode 100644 mtce/debian/deb_folder/runservices.service diff --git a/mtce-control/debian/deb_folder/hbsAgent.service b/mtce-control/debian/deb_folder/hbsAgent.service new file mode 100644 index 00000000..ca7df3d0 --- /dev/null +++ b/mtce-control/debian/deb_folder/hbsAgent.service @@ -0,0 +1,13 @@ +[Unit] +Description=StarlingX Maintenance Heartbeat Agent +After=hbsClient.service +Before=pmon.service + +[Service] +Type=forking +ExecStart=/etc/init.d/hbsAgent start +ExecStop=/etc/init.d/hbsAgent stop +PIDFile=/var/run/hbsAgent.pid + +[Install] +WantedBy=multi-user.target diff --git a/mtce-control/debian/deb_folder/mtce-control.install b/mtce-control/debian/deb_folder/mtce-control.install index 3c041774..1bdf964d 100644 --- a/mtce-control/debian/deb_folder/mtce-control.install +++ b/mtce-control/debian/deb_folder/mtce-control.install @@ -1,4 +1,3 @@ etc/init.d/goenabledControl etc/init.d/hbsAgent etc/pmon.d/hbsAgent.conf -lib/systemd/system/hbsAgent.service diff --git a/mtce-control/debian/deb_folder/rules b/mtce-control/debian/deb_folder/rules index b69755d5..95a8b796 100644 --- a/mtce-control/debian/deb_folder/rules +++ b/mtce-control/debian/deb_folder/rules @@ -4,7 +4,6 @@ export ROOT = debian/tmp export INITDIR = $(ROOT)/etc/init.d export PMONDIR = $(ROOT)/etc/pmon.d -export SYSTEMDDIR = $(ROOT)/lib/systemd/system %: dh $@ @@ -15,5 +14,6 @@ override_dh_auto_install: install -m 755 -p -D scripts/hbsAgent $(INITDIR) install -m 755 -d $(PMONDIR) install -m 644 -p -D scripts/hbsAgent.conf $(PMONDIR) - install -m 755 -d $(SYSTEMDDIR) - install -m 644 -p -D scripts/hbsAgent.service $(SYSTEMDDIR) + +override_dh_installsystemd: + dh_installsystemd --name hbsAgent diff --git a/mtce-control/src/scripts/hbsAgent b/mtce-control/src/scripts/hbsAgent index d05177d8..1d9ebf02 100644 --- a/mtce-control/src/scripts/hbsAgent +++ b/mtce-control/src/scripts/hbsAgent @@ -17,10 +17,22 @@ # Short-Description: Heartbeat Agent Daemon ### END INIT INFO -. /etc/init.d/functions +CENTOS_FUNCTIONS="/etc/init.d/functions" +DEBIAN_FUNCTIONS="/lib/lsb/init-functions" +if [ ! -f ${CENTOS_FUNCTIONS} ] ; then + . ${DEBIAN_FUNCTIONS} +else + . ${CENTOS_FUNCTIONS} +fi DAEMON_NAME="hbsAgent" -DAEMON="/usr/local/bin/${DAEMON_NAME}" +DAEMON_CENTOS_PATH="/usr/local/bin/${DAEMON_NAME}" +DAEMON_DEBIAN_PATH="/usr/bin/${DAEMON_NAME}" +if [ ! -f ${DAEMON_CENTOS_PATH} ] ; then + DAEMON=${DAEMON_DEBIAN_PATH} +else + DAEMON=${DAEMON_CENTOS_PATH} +fi PIDFILE="/var/run/${DAEMON_NAME}.pid" VIRT_TOOL='virt-what' diff --git a/mtce/debian/deb_folder/hbsClient.service b/mtce/debian/deb_folder/hbsClient.service new file mode 100644 index 00000000..db6d724a --- /dev/null +++ b/mtce/debian/deb_folder/hbsClient.service @@ -0,0 +1,23 @@ +[Unit] +Description=StarlingX Maintenance Heartbeat Client +After=network.target syslog.service config.service +Before=pmon.service mtcClient.service + +[Service] +Type=forking +ExecStart=/etc/init.d/hbsClient start +ExecStop=/etc/init.d/hbsClient stop +ExecReload=/etc/init.d/hbsClient reload +PIDFile=/var/run/hbsClient.pid + +# Failure handling +TimeoutStartSec=10s +TimeoutStopSec=10s + +# process recovery is handled by pmond +Restart=no +RestartSec=5 + +[Install] +WantedBy=multi-user.target + diff --git a/mtce/debian/deb_folder/hwmon.service b/mtce/debian/deb_folder/hwmon.service new file mode 100644 index 00000000..04f0f5b7 --- /dev/null +++ b/mtce/debian/deb_folder/hwmon.service @@ -0,0 +1,16 @@ +[Unit] +Description=StarlingX Hardware Monitor +After=network.target syslog.service + +[Service] +Type=forking +ExecStart=/etc/init.d/hwmon start +ExecStop=/etc/init.d/hwmon stop +ExecReload=/etc/init.d/hwmon reload +PIDFile=/var/run/hwmond.pid + +Restart=no + +[Install] +WantedBy=multi-user.target + diff --git a/mtce/debian/deb_folder/lmon.service b/mtce/debian/deb_folder/lmon.service new file mode 100644 index 00000000..0bf32a6a --- /dev/null +++ b/mtce/debian/deb_folder/lmon.service @@ -0,0 +1,17 @@ +[Unit] +Description=Starling-X Maintenance Link Monitor + +After=config.service +After=syslog-ng.service +Before=pmon.service + +[Service] +Type=forking +ExecStart=/etc/init.d/lmon start +ExecStop=/etc/init.d/lmon stop +ExecReload=/etc/init.d/lmon reload +PIDFile=/var/run/lmond.pid +KillMode=process + +[Install] +WantedBy=multi-user.target diff --git a/mtce/debian/deb_folder/mtcalarm.service b/mtce/debian/deb_folder/mtcalarm.service new file mode 100644 index 00000000..cd97d008 --- /dev/null +++ b/mtce/debian/deb_folder/mtcalarm.service @@ -0,0 +1,14 @@ +[Unit] +Description=StarlingX Maintenance Alarm Handler Client +After=network.target syslog.service config.service +Before=pmon.service + +[Service] +Type=forking +ExecStart=/etc/init.d/mtcalarm start +ExecStop=/etc/init.d/mtcalarm stop +ExecReload=/etc/init.d/mtcalarm reload +PIDFile=/var/run/mtcalarmd.pid + +[Install] +WantedBy=multi-user.target diff --git a/mtce/debian/deb_folder/mtce-hwmon.install b/mtce/debian/deb_folder/mtce-hwmon.install index c9646958..6fe75196 100644 --- a/mtce/debian/deb_folder/mtce-hwmon.install +++ b/mtce/debian/deb_folder/mtce-hwmon.install @@ -1,6 +1,5 @@ etc/init.d/hwmon etc/logrotate.d/hwmon.logrotate etc/mtc/hwmond.conf -lib/systemd/system/hwmon.service -usr/lib/ocf/resource.d/platform/hwmon usr/bin/hwmond +usr/lib/ocf/resource.d/platform/hwmon diff --git a/mtce/debian/deb_folder/mtce-lmon.install b/mtce/debian/deb_folder/mtce-lmon.install index 8ed84365..99505e19 100644 --- a/mtce/debian/deb_folder/mtce-lmon.install +++ b/mtce/debian/deb_folder/mtce-lmon.install @@ -2,5 +2,4 @@ etc/init.d/lmon etc/logrotate.d/lmon.logrotate etc/mtc/lmond.conf etc/pmon.d/lmon.conf -lib/systemd/system/lmon.service usr/bin/lmond diff --git a/mtce/debian/deb_folder/mtce-pmon.install b/mtce/debian/deb_folder/mtce-pmon.install index 3181aee7..1e9ec0e6 100644 --- a/mtce/debian/deb_folder/mtce-pmon.install +++ b/mtce/debian/deb_folder/mtce-pmon.install @@ -2,10 +2,10 @@ etc/init.d/pmon etc/logrotate.d/pmon.logrotate etc/mtc/pmond.conf lib/systemd/system/pmon.service +usr/bin/pmond usr/lib/libamon.so usr/lib/libamon.so.1 usr/lib/libamon.so.1.0 -usr/bin/pmond usr/sbin/pmon-restart usr/sbin/pmon-start usr/sbin/pmon-stop diff --git a/mtce/debian/deb_folder/mtce.install b/mtce/debian/deb_folder/mtce.install index 49d49441..c965978e 100644 --- a/mtce/debian/deb_folder/mtce.install +++ b/mtce/debian/deb_folder/mtce.install @@ -34,11 +34,8 @@ etc/syslog-ng/conf.d/mtce.conf lib/systemd/system/crashDumpMgr.service lib/systemd/system/fsmon.service lib/systemd/system/goenabled.service -lib/systemd/system/hbsClient.service lib/systemd/system/mtcClient.service -lib/systemd/system/mtcalarm.service -lib/systemd/system/mtclog.service -lib/systemd/system/runservices.service +usr/lib/ocf/resource.d/platform/mtcAgent usr/bin/fsmond usr/bin/hbsAgent usr/bin/hbsClient @@ -47,7 +44,6 @@ usr/bin/mtcClient usr/bin/mtcalarmd usr/bin/mtclogd usr/bin/wipedisk -usr/lib/ocf/resource.d/platform/mtcAgent usr/sbin/dmemchk.sh usr/sbin/fsync usr/share/mtce/hwclock.service diff --git a/mtce/debian/deb_folder/mtclog.service b/mtce/debian/deb_folder/mtclog.service new file mode 100644 index 00000000..888c35ec --- /dev/null +++ b/mtce/debian/deb_folder/mtclog.service @@ -0,0 +1,23 @@ +[Unit] +Description=StarlingX Maintenance Logger +After=network.target syslog.service config.service +Before=pmon.service + +[Service] +Type=forking +ExecStart=/etc/init.d/mtclog start +ExecStop=/etc/init.d/mtclog stop +ExecReload=/etc/init.d/mtclog reload +PIDFile=/var/run/mtclogd.pid + +# Failure handling +TimeoutStartSec=10s +TimeoutStopSec=10s + +# process recovery is handled by pmond +Restart=no +RestartSec=5 + +[Install] +WantedBy=multi-user.target + diff --git a/mtce/debian/deb_folder/rules b/mtce/debian/deb_folder/rules index 3c82dd26..3c0b5d4c 100644 --- a/mtce/debian/deb_folder/rules +++ b/mtce/debian/deb_folder/rules @@ -91,17 +91,11 @@ override_dh_auto_install: # systemd service files install -m 755 -d $(UNITDIR) install -m 644 -p -D fsmon/scripts/fsmon.service $(UNITDIR)/fsmon.service - install -m 644 -p -D hwmon/scripts/hwmon.service $(UNITDIR)/hwmon.service install -m 644 -p -D pmon/scripts/pmon.service $(UNITDIR)/pmon.service install -m 644 -p -D hostw/scripts/hostw.service $(UNITDIR)/hostw.service install -m 644 -p -D scripts/crashDumpMgr.service $(UNITDIR)/crashDumpMgr.service install -m 644 -p -D scripts/mtcClient.service $(UNITDIR)/mtcClient.service - install -m 644 -p -D scripts/hbsClient.service $(UNITDIR)/hbsClient.service - install -m 644 -p -D scripts/mtclog.service $(UNITDIR)/mtclog.service install -m 644 -p -D scripts/goenabled.service $(UNITDIR)/goenabled.service - install -m 644 -p -D scripts/runservices.service $(UNITDIR)/runservices.service - install -m 644 -p -D alarm/scripts/mtcalarm.service $(UNITDIR)/mtcalarm.service - install -m 644 -p -D lmon/scripts/lmon.service $(UNITDIR)/lmon.service # go enabled script install -m 755 -p -D scripts/goenabled $(INITDIR)/goenabled @@ -162,5 +156,13 @@ override_dh_auto_install: install -m 755 -d $(ROOT)/var install -m 755 -d $(ROOT)/var/run +override_dh_installsystemd: + dh_installsystemd --name hbsClient + dh_installsystemd --name hwmon + dh_installsystemd --name lmon + dh_installsystemd --name mtcalarm + dh_installsystemd --name mtclog + dh_installsystemd --name runservices + override_dh_usrlocal: echo "SKIPPING DH USRLOCAL" diff --git a/mtce/debian/deb_folder/runservices.service b/mtce/debian/deb_folder/runservices.service new file mode 100644 index 00000000..d5829eb5 --- /dev/null +++ b/mtce/debian/deb_folder/runservices.service @@ -0,0 +1,12 @@ +[Unit] +Description=StarlingX Run Host Services +After=network.target syslog.service + +[Service] +Type=simple +ExecStart=/etc/init.d/runservices start +ExecStop=/etc/init.d/runservices stop + +[Install] +WantedBy=multi-user.target + diff --git a/mtce/debian/mtce-hostw.install b/mtce/debian/mtce-hostw.install index 5ff01728..7bedc11f 100644 --- a/mtce/debian/mtce-hostw.install +++ b/mtce/debian/mtce-hostw.install @@ -1,4 +1,4 @@ etc/init.d/hostw etc/logrotate.d/hostw.logrotate etc/mtc/hostwd.conf -usr/local/bin/hostwd +usr/bin/hostwd diff --git a/mtce/src/alarm/scripts/mtcalarm.init b/mtce/src/alarm/scripts/mtcalarm.init index 57f348f2..52b9b06d 100644 --- a/mtce/src/alarm/scripts/mtcalarm.init +++ b/mtce/src/alarm/scripts/mtcalarm.init @@ -17,10 +17,22 @@ # Short-Description: Maintenance Alarm Daemon ### END INIT INFO -. /etc/init.d/functions +CENTOS_FUNCTIONS="/etc/init.d/functions" +DEBIAN_FUNCTIONS="/lib/lsb/init-functions" +if [ ! -f ${CENTOS_FUNCTIONS} ] ; then + . ${DEBIAN_FUNCTIONS} +else + . ${CENTOS_FUNCTIONS} +fi DAEMON_NAME="mtcalarmd" -DAEMON="/usr/local/bin/${DAEMON_NAME}" +DAEMON_CENTOS_PATH="/usr/local/bin/${DAEMON_NAME}" +DAEMON_DEBIAN_PATH="/usr/bin/${DAEMON_NAME}" +if [ ! -f ${DAEMON_CENTOS_PATH} ] ; then + DAEMON=${DAEMON_DEBIAN_PATH} +else + DAEMON=${DAEMON_CENTOS_PATH} +fi PIDFILE="/var/run/${DAEMON_NAME}.pid" PLATFORM_CONF="/etc/platform/platform.conf" diff --git a/mtce/src/hwmon/scripts/lsb/hwmon b/mtce/src/hwmon/scripts/lsb/hwmon index 4596a36d..4445183b 100644 --- a/mtce/src/hwmon/scripts/lsb/hwmon +++ b/mtce/src/hwmon/scripts/lsb/hwmon @@ -17,10 +17,22 @@ # Short-Description: hwmon daemon ### END INIT INFO -. /etc/init.d/functions +CENTOS_FUNCTIONS="/etc/init.d/functions" +DEBIAN_FUNCTIONS="/lib/lsb/init-functions" +if [ ! -f ${CENTOS_FUNCTIONS} ] ; then + . ${DEBIAN_FUNCTIONS} +else + . ${CENTOS_FUNCTIONS} +fi DAEMON_NAME="hwmond" -DAEMON="/usr/local/bin/${DAEMON_NAME}" +DAEMON_CENTOS_PATH="/usr/local/bin/${DAEMON_NAME}" +DAEMON_DEBIAN_PATH="/usr/bin/${DAEMON_NAME}" +if [ ! -f ${DAEMON_CENTOS_PATH} ] ; then + DAEMON=${DAEMON_DEBIAN_PATH} +else + DAEMON=${DAEMON_CENTOS_PATH} +fi PIDFILE="/var/run/${DAEMON_NAME}.pid" # Linux Standard Base (LSB) Error Codes diff --git a/mtce/src/lmon/scripts/lmon b/mtce/src/lmon/scripts/lmon index 6024e169..3d25c002 100644 --- a/mtce/src/lmon/scripts/lmon +++ b/mtce/src/lmon/scripts/lmon @@ -17,10 +17,22 @@ # Short-Description: Link Monitor daemon ### END INIT INFO -. /etc/init.d/functions +CENTOS_FUNCTIONS="/etc/init.d/functions" +DEBIAN_FUNCTIONS="/lib/lsb/init-functions" +if [ ! -f ${CENTOS_FUNCTIONS} ] ; then + . ${DEBIAN_FUNCTIONS} +else + . ${CENTOS_FUNCTIONS} +fi DAEMON_NAME="lmond" -DAEMON="/usr/local/bin/${DAEMON_NAME}" +DAEMON_CENTOS_PATH="/usr/local/bin/${DAEMON_NAME}" +DAEMON_DEBIAN_PATH="/usr/bin/${DAEMON_NAME}" +if [ ! -f ${DAEMON_CENTOS_PATH} ] ; then + DAEMON=${DAEMON_DEBIAN_PATH} +else + DAEMON=${DAEMON_CENTOS_PATH} +fi IFACE="" if [ ! -e "$DAEMON" ] ; then diff --git a/mtce/src/scripts/hbsClient b/mtce/src/scripts/hbsClient index 67d7e84c..e321a001 100644 --- a/mtce/src/scripts/hbsClient +++ b/mtce/src/scripts/hbsClient @@ -17,10 +17,22 @@ # Short-Description: Heartbeat Client Daemon ### END INIT INFO -. /etc/init.d/functions +CENTOS_FUNCTIONS="/etc/init.d/functions" +DEBIAN_FUNCTIONS="/lib/lsb/init-functions" +if [ ! -f ${CENTOS_FUNCTIONS} ] ; then + . ${DEBIAN_FUNCTIONS} +else + . ${CENTOS_FUNCTIONS} +fi DAEMON_NAME="hbsClient" -DAEMON="/usr/local/bin/${DAEMON_NAME}" +DAEMON_CENTOS_PATH="/usr/local/bin/${DAEMON_NAME}" +DAEMON_DEBIAN_PATH="/usr/bin/${DAEMON_NAME}" +if [ ! -f ${DAEMON_CENTOS_PATH} ] ; then + DAEMON=${DAEMON_DEBIAN_PATH} +else + DAEMON=${DAEMON_CENTOS_PATH} +fi PIDFILE="/var/run/${DAEMON_NAME}.pid" IFACE="" diff --git a/mtce/src/scripts/mtclog b/mtce/src/scripts/mtclog index 80db22a9..b8cdf019 100644 --- a/mtce/src/scripts/mtclog +++ b/mtce/src/scripts/mtclog @@ -19,10 +19,22 @@ # Short-Description: mtclog daemon ### END INIT INFO -. /etc/init.d/functions +CENTOS_FUNCTIONS="/etc/init.d/functions" +DEBIAN_FUNCTIONS="/lib/lsb/init-functions" +if [ ! -f ${CENTOS_FUNCTIONS} ] ; then + . ${DEBIAN_FUNCTIONS} +else + . ${CENTOS_FUNCTIONS} +fi DAEMON_NAME="mtclogd" -DAEMON="/usr/local/bin/${DAEMON_NAME}" +DAEMON_CENTOS_PATH="/usr/local/bin/${DAEMON_NAME}" +DAEMON_DEBIAN_PATH="/usr/bin/${DAEMON_NAME}" +if [ ! -f ${DAEMON_CENTOS_PATH} ] ; then + DAEMON=${DAEMON_DEBIAN_PATH} +else + DAEMON=${DAEMON_CENTOS_PATH} +fi PIDFILE="/var/run/${DAEMON_NAME}.pid" PLATFORM_CONF="/etc/platform/platform.conf"