#! /bin/sh
#
# chkconfig: 345 55 45
#
# Description:    This shell script takes care of starting and stopping the pcscd Daemon/Manager

. /etc/rc.d/init.d/functions

# Readers Conf
. /etc/reader.conf.d/reader.conf

# Determine the base and follow a runlevel link name.
function start()
{
	gprintf "Starting %s: " "pcscd"
    daemon /usr/sbin/pcscd
	echo
	touch /var/lock/subsys/pcscd
}

function stop()
{
	gprintf "Stopping %s: " "pcscd"
	killproc pcscd
	echo
	rm /var/lock/subsys/pcscd
}

function reload()
{
	pid=`pidoffather pcscd`
    if [ "x$pid" != "x" ]; then
		kill -HUP $pid 2>/dev/null
	fi
	touch /var/lock/subsys/pcscd
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart)
		stop
		start
		;;
	reload)
		reload
		;;
	status)
		status pcscd
		;;
	*)
		gprintf "Usage: %s {start|stop|status|restart|reload}\n" "pcscd"
		exit 1
esac

exit 0
