File pcsc-lite-init of Package pcsc-lite

#!/bin/sh
#
# pcscd        Starts the pcscd Daemon
#
# chkconfig:   2345 25 88
# description: The PC/SC smart card daemon is a resource manager for the \
#              PC/SC lite and Musclecard frameworks.  It coordinates \
#              communications with smart card readers, smart cards, and \
#              cryptographic tokens that are connected to the system.
#
# processname: pcscd
# config:      /etc/reader.conf
#
### BEGIN INIT INFO
# Provides: pcscd
# Required-Start: $local_fs $remote_fs $syslog
# Required-Stop: $local_fs $remote_fs $syslog
# Should-Start: udev openct
# Should-Stop: udev openct
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Daemon to access a smart card using PC/SC
# Description: The PC/SC smart card daemon is a resource manager for the
#              PC/SC lite and Musclecard frameworks.  It coordinates
#              communications with smart card readers, smart cards, and
#              cryptographic tokens that are connected to the system.
# X-UnitedLinux-Default-Enabled: yes
### END INIT INFO
#
# Note!  pcscd should be started after pcmcia, and shut down before it
# for smooth experience with PCMCIA readers.

. /etc/rc.status
rc_reset

umask 077

exec=/usr/sbin/pcscd
prog=$(basename $exec)
lockfile=/var/lock/$prog
PCSCD_OPTIONS=

# Source config
if [ -f /etc/sysconfig/pcscd ] ; then
    . /etc/sysconfig/pcscd
fi

cleanup() {
    # if comm socket exists but pid file is absent pcscd fails to start
    # bnc#686674
    if [ -S /var/run/pcscd/pcscd.comm -a ! -e /var/run/pcscd/pcscd.pid ]; then
      # check if a pcscd instance is running and remove the socket in case it's not
      checkproc $exec || rm /var/run/pcscd/pcscd.comm
    fi
}

start() {
    echo -n "Starting PC/SC smart card daemon ($prog): "
    cleanup
    startproc $exec $PCSCD_OPTIONS
    retval=$?
    rc_status
    [ $retval -eq 0 ] && touch $lockfile
    rc_status -v
}
stop() {
    echo -n "Stopping PC/SC smart card daemon ($prog): "
    killproc $exec
    retval=$?
    rc_status
    [ $retval -eq 0 ] && rm -f $lockfile
    rc_status -v
}
restart() {
    stop
    start
}


case "$1" in
    start|stop|restart)
        $1
        ;;
    reload|force-reload)
        restart
        ;;
    status)
        echo -n "Checking for PC/SC smart card daemon ($prog): "
        checkproc $exec
	rc_status -v
        ;;
    condrestart|try-restart)
        if test -f $lockfile ; then
	    restart
	else
	    rc_reset
	fi
	rc_status
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
        exit 2
esac
rc_exit
openSUSE Build Service is sponsored by