18922761a6
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
95 lines
2.0 KiB
Bash
95 lines
2.0 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
|
|
|
|
. /etc/init.d/functions
|
|
|
|
DAEMON_NAME="mtclogd"
|
|
DAEMON="/usr/local/bin/${DAEMON_NAME}"
|
|
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}
|