| #!/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} |
| |
| |
| [ -r /etc/default/${NAME} ] && . /etc/default/${NAME} |
| |
| |
| |
| |
| do_start() |
| { |
| |
| 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} |
| } |
| |
| |
| |
| |
| check_status() |
| { |
| /usr/bin/daemon --pidfile=${PIDFILE} --name=${NAME} --running |
| } |
| |
| |
| |
| |
| 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!" ;; |
| *) |
| |
| check_status |
| case "$?" in |
| 0) echo " Daemon is still Running!" ;; |
| *) echo " Daemon is not Running (use start command)!" ;; |
| esac |
| ;; |
| esac |
| ;; |
| restart|force-reload) |
| |
| |
| |
| |
| echo -n "Restarting ${DESC}" "${NAME}" ... |
| do_stop |
| case "$?" in |
| 0) |
| do_start |
| case "$?" in |
| 0) echo " Done!" ;; |
| *) echo " Failed to start!" ;; |
| esac |
| ;; |
| *) |
| |
| 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 |
| |