#!/bin/sh
#
# pcscd		PC/SC Smartcard daemon
#
# chkconfig:	2345 12 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
#
# $Id: pcsc-lite-pcscd.init,v 1.7 2006/03/06 09:37:12 qboosh Exp $


# Source function library
. /etc/rc.d/init.d/functions

umask 077

# Set defaults
LOGGING="yes"

# Get service config - may override defaults
[ -f /etc/sysconfig/pcscd ] && . /etc/sysconfig/pcscd

if is_yes "${LOGGING}"; then
	LOGOPT="-d"
else
	LOGOPT=""
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/pcscd ]; then
		msg_starting pcscd
		/usr/sbin/update-reader.conf && daemon pcscd $LOGOPT
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pcscd
	else
		msg_already_running pcscd
	fi
	;;
  stop)
	# Stop daemons.
	if [ -f /var/lock/subsys/pcscd ]; then
		msg_stopping pcscd
		killproc pcscd
		rm -f /var/lock/subsys/pcscd
	else
		msg_not_running pcscd
	fi
	;;
  restart|force-reload)
	# pcscd doesn't support reloading on HUP
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status pcscd
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL

# This must be last line !
# vi:syntax=sh:tw=78:ts=8:sw=4
