#!/bin/bash

DAEMON=/opt/bukts-mfservice/bin/mifare-daemon
CFGFILE=/etc/opt/bukts-mfservice/mifare.conf
PIDFILE=/var/opt/bukts-mfservice/run/mifare-daemon.pid

if [ ! -x ${DAEMON?} ]; then exit 0; fi
if [ ! -f ${CFGFILE?} ]; then exit 0; fi
PIDS=`ps ax | grep ${DAEMON?} | grep -v grep | awk '{print $1}'`
if [ ! -z "${PIDS?}" ]; then  exit 0;  fi
if [ -f "${PIDFILE}" ] ; then  rm -f "${PIDFILE}" 2>/dev/null; fi

${DAEMON} >/dev/null 2>&1

ERR=$?
exit 0
