metal/mtce/src/scripts/mtclog
Matheus Machado Guilhermino 4c8abe18d3 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 <service_name>" for
each service and verified that they are active

Story: 2009101
Task: 44192

Signed-off-by: Matheus Machado Guilhermino <Matheus.MachadoGuilhermino@windriver.com>
Change-Id: I50915c17d6f50f5e20e6448d3e75bfe54a75acc0
2022-01-14 10:50:09 -03:00

119 lines
2.6 KiB
Bash

#! /bin/sh
#
# Copyright (c) 2013-2014, 2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# This script starts and stops a mtclogd Daemon process
#
# chkconfig: 2345 95 95
#
### BEGIN INIT INFO
# Provides: mtclog
# Required-Start: $null
# Required-Stop: $null
# Default-Start: $null
# Default-Stop: $null
# Short-Description: mtclog daemon
### END INIT INFO
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_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"
# Linux Standard Base (LSB) Error Codes
RETVAL=0
GENERIC_ERROR=1
INVALID_ARGS=2
UNSUPPORTED_FEATURE=3
NOT_INSTALLED=5
NOT_RUNNING=7
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
export PATH
if [ ! -e "${DAEMON}" ] ; then
logger "${DAEMON} is missing"
exit ${NOT_INSTALLED}
fi
case "$1" in
start)
logger "Starting ${DAEMON_NAME}"
echo -n "Starting ${DAEMON_NAME}: "
if [ -n "`pidof ${DAEMON_NAME}`" ] ; then
echo -n "is already running "
RETVAL=0
else
start-stop-daemon --start -b -x ${DAEMON} -- -l
RETVAL=$?
fi
if [ ${RETVAL} -eq 0 ] ; then
pid=`pidof ${DAEMON_NAME}`
echo "OK"
logger "${DAEMON} (${pid})"
else
echo "FAIL"
RETVAL=${GENERIC_ERROR}
fi
;;
stop)
logger "Stopping ${DAEMON_NAME}"
echo -n "Stopping ${DAEMON_NAME}: "
if [ -n "`pidof ${DAEMON_NAME}`" ] ; then
killproc ${DAEMON_NAME}
fi
if [ -n "`pidof ${DAEMON_NAME}`" ] ; then
echo "FAIL"
RETVAL=${NOT_RUNNING}
else
echo "OK"
fi
rm -f ${PIDFILE}
;;
restart)
$0 stop
$0 start
;;
status)
pid=`pidof ${DAEMON_NAME}`
RETVAL=$?
if [ ${RETVAL} -eq 0 ] ; then
echo "${DAEMON_NAME} is running"
else
echo "${DAEMON_NAME} is NOT running"
RETVAL=${NOT_RUNNING}
fi
;;
condrestart)
$0 restart
;;
*)
echo "usage: $0 { start | stop | status | restart | condrestart | status }"
;;
esac
exit ${RETVAL}