358 kx #!/bin/sh
358 kx
358 kx PATH=/sbin:/usr/sbin:/bin:/usr/bin
358 kx DESC="PCSC Lite resource manager"
358 kx NAME=pcscd
358 kx DAEMON=/usr/sbin/${NAME}
358 kx IPCDIR=/var/run/pcscd
358 kx PIDFILE=${IPCDIR}/${NAME}.pid
358 kx SCRIPTNAME=/etc/rc.d/rc.${NAME}
358 kx
358 kx # Read configuration variable file if it is present
358 kx [ -r /etc/default/${NAME} ] && . /etc/default/${NAME}
358 kx
358 kx #
358 kx # Function that starts the daemon/service
358 kx #
358 kx do_start()
358 kx {
358 kx # create $IPCDIR with correct access rights
358 kx if [ ! -d ${IPCDIR} ] ; then
358 kx rm -rf ${IPCDIR}
358 kx mkdir -p ${IPCDIR}
358 kx fi
358 kx chmod 0755 ${IPCDIR}
358 kx
358 kx /usr/bin/daemon --pidfile=${PIDFILE} --name=${NAME} -- ${DAEMON} -f ${PCSCD_ARGS}
358 kx }
358 kx
358 kx #
358 kx # Function that check status the daemon/service
358 kx #
358 kx check_status()
358 kx {
358 kx /usr/bin/daemon --pidfile=${PIDFILE} --name=${NAME} --running
358 kx }
358 kx
358 kx #
358 kx # Function that stops the daemon/service
358 kx #
358 kx do_stop()
358 kx {
358 kx /usr/bin/daemon --pidfile=${PIDFILE} --name=${NAME} --stop 1> /dev/null 2>/dev/null
358 kx ret="$?"
358 kx if [ "${ret}" != 0 ] ; then
358 kx return 1
358 kx fi
358 kx }
358 kx
358 kx case "$1" in
358 kx start)
358 kx [ "${VERBOSE}" != "no" ] && echo -n "Starting ${DESC}" "${NAME}" ...
358 kx do_start
358 kx case "$?" in
358 kx 0) [ "${VERBOSE}" != "no" ] && echo " Done!" ;;
358 kx *) [ "${VERBOSE}" != "no" ] && echo " Error!" ;;
358 kx esac
358 kx ;;
358 kx status)
358 kx [ "${VERBOSE}" != "no" ] && echo -n "The ${DESC}" "${NAME}" ...
358 kx check_status
358 kx case "$?" in
358 kx 0) [ "${VERBOSE}" != "no" ] && echo " Running!" ;;
358 kx *) [ "${VERBOSE}" != "no" ] && echo " Stopped!" ;;
358 kx esac
358 kx ;;
358 kx stop)
358 kx [ "${VERBOSE}" != no ] && echo -n "Stopping ${DESC}" "${NAME}" ...
358 kx do_stop
358 kx case "$?" in
358 kx 0) [ "${VERBOSE}" != no ] && echo " Done!" ;;
358 kx *)
358 kx # Failed to stop:
358 kx check_status
358 kx case "$?" in
358 kx 0) echo " Daemon is still Running!" ;;
358 kx *) echo " Daemon is not Running (use start command)!" ;;
358 kx esac
358 kx ;;
358 kx esac
358 kx ;;
358 kx restart|force-reload)
358 kx #
358 kx # If the "reload" option is implemented then remove the
358 kx # 'force-reload' alias
358 kx #
358 kx echo -n "Restarting ${DESC}" "${NAME}" ...
358 kx do_stop
358 kx case "$?" in
358 kx 0)
358 kx do_start
358 kx case "$?" in
358 kx 0) echo " Done!" ;;
358 kx *) echo " Failed to start!" ;;
358 kx esac
358 kx ;;
358 kx *)
358 kx # Failed to stop:
358 kx check_status
358 kx case "$?" in
358 kx 0) echo " Daemon is still Running!" ;;
358 kx *) echo " Daemon is not Running (use start command)!" ;;
358 kx esac
358 kx ;;
358 kx esac
358 kx ;;
358 kx *)
358 kx echo "Usage: ${SCRIPTNAME} {start|stop|status|restart|force-reload}" >&2
358 kx exit 0
358 kx ;;
358 kx esac