#!/bin/sh

##
# Start PC/SC
##

. /etc/rc.common

StartService ()
{
    if ! pid=$(GetPID pcscd); then
	ConsoleMessage "Starting Smart Card Services"
	rm -rf /tmp/pcsc
	/usr/sbin/pcscd
    fi
}


StopService ()
{
    if pid=$(GetPID pcscd); then
        ConsoleMessage "Stopping Smart Card Services"
        kill -TERM "${pid}"
    fi
}

RestartService ()
{
    if pid=$(GetPID pcscd); then
        ConsoleMessage "Restarting Smart Card Services"
        kill -TERM "${pid}"
    fi
    # Leave pcscd the time to die
    sleep 3
    StartService
}

RunService "$1"


