Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="PCSC Lite resource manager"
NAME=pcscd
DAEMON=/usr/sbin/${NAME}
IPCDIR=/var/run/pcscd
PIDFILE=${IPCDIR}/${NAME}.pid
SCRIPTNAME=/etc/rc.d/rc.${NAME}

# Read configuration variable file if it is present
[ -r /etc/default/${NAME} ] && . /etc/default/${NAME}

#
# Function that starts the daemon/service
#
do_start()
{
  # create $IPCDIR with correct access rights
  if [ ! -d ${IPCDIR} ] ; then
    rm -rf ${IPCDIR}
    mkdir -p ${IPCDIR}
  fi
  chmod 0755 ${IPCDIR}

  /usr/bin/daemon --pidfile=${PIDFILE} --name=${NAME} -- ${DAEMON} -f ${PCSCD_ARGS}
}

#
# Function that check status  the daemon/service
#
check_status()
{
  /usr/bin/daemon --pidfile=${PIDFILE} --name=${NAME} --running
}

#
# Function that stops the daemon/service
#
do_stop()
{
  /usr/bin/daemon --pidfile=${PIDFILE} --name=${NAME} --stop  1> /dev/null 2>/dev/null
  ret="$?"
  if [ "${ret}" != 0 ] ; then
    return 1
  fi
}

case "$1" in
  start)
    [ "${VERBOSE}" != "no" ] && echo -n "Starting ${DESC}" "${NAME}" ...
    do_start
    case "$?" in
      0) [ "${VERBOSE}" != "no" ] && echo " Done!" ;;
      *) [ "${VERBOSE}" != "no" ] && echo " Error!" ;;
    esac
    ;;
  status)
    [ "${VERBOSE}" != "no" ] && echo -n "The ${DESC}" "${NAME}" ...
    check_status
    case "$?" in
      0) [ "${VERBOSE}" != "no" ] && echo " Running!" ;;
      *) [ "${VERBOSE}" != "no" ] && echo " Stopped!" ;;
    esac
    ;;
  stop)
    [ "${VERBOSE}" != no ] && echo -n "Stopping ${DESC}" "${NAME}" ...
    do_stop
    case "$?" in
      0) [ "${VERBOSE}" != no ] && echo " Done!" ;;
      *)
        # Failed to stop:
        check_status
        case "$?" in
          0) echo " Daemon is still Running!" ;;
          *) echo " Daemon is not Running (use start command)!" ;;
        esac
        ;;
    esac
    ;;
  restart|force-reload)
    #
    # If the "reload" option is implemented then remove the
    # 'force-reload' alias
    #
    echo -n "Restarting ${DESC}" "${NAME}" ...
    do_stop
    case "$?" in
      0)
        do_start
        case "$?" in
          0) echo " Done!" ;;
          *) echo " Failed to start!" ;;
        esac
        ;;
      *)
        # Failed to stop:
        check_status
        case "$?" in
          0) echo " Daemon is still Running!" ;;
          *) echo " Daemon is not Running (use start command)!" ;;
        esac
        ;;
    esac
    ;;
  *)
    echo "Usage: ${SCRIPTNAME} {start|stop|status|restart|force-reload}" >&2
    exit 0
    ;;
esac