]> TLD Linux GIT Repositories - packages/pcsc-lite.git/blob - pcsc-lite-pcscd.init
- merged 2.0.1 from PLD
[packages/pcsc-lite.git] / pcsc-lite-pcscd.init
1 #!/bin/sh
2 #
3 # pcscd         PC/SC Smartcard daemon
4 #
5 # chkconfig:    2345 12 88
6 #
7 # description: The PC/SC smart card daemon is a resource manager for the \
8 #              PC/SC lite and Musclecard frameworks.  It coordinates \
9 #              communications with smart card readers, smart cards, and \
10 #              cryptographic tokens that are connected to the system.
11 #
12 # processname: pcscd
13 # config:      /etc/reader.conf.d
14 #
15 # Note!  pcscd should be started after pcmcia, and shut down before it
16 # for smooth experience with PCMCIA readers.
17 #
18 # $Id$
19
20 # Source function library
21 . /etc/rc.d/init.d/functions
22
23 umask 077
24
25 # Set defaults
26 LOGLEVEL=""
27 PCSCD_OPTIONS=""
28
29 # Get service config - may override defaults
30 [ -f /etc/sysconfig/pcscd ] && . /etc/sysconfig/pcscd
31
32 pidfile=/var/run/pcscd/pcscd.pid
33
34 start() {
35         if [ -f /var/lock/subsys/pcscd ]; then
36                 msg_already_running "PC/SC smart card daemon"
37                 return
38         fi
39
40         local logopt
41         case "$LOGLEVEL" in
42         debug|info|error|critical)
43                 logopt=--$LOGLEVEL
44         ;;
45         esac
46
47         msg_starting "PC/SC smart card daemon"
48         daemon /usr/sbin/pcscd $logopt $PCSCD_OPTIONS
49         RETVAL=$?
50         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pcscd
51 }
52
53 stop() {
54         if [ ! -f /var/lock/subsys/pcscd ]; then
55                 msg_not_running "PC/SC smart card daemon"
56                 return
57         fi
58
59         msg_stopping "PC/SC smart card daemon"
60         killproc --pidfile $pidfile pcscd
61         rm -f /var/lock/subsys/pcscd
62 }
63
64 condrestart() {
65         if [ ! -f /var/lock/subsys/pcscd ]; then
66                 msg_not_running "PC/SC smart card daemon"
67                 RETVAL=$1
68                 return
69         fi
70
71         stop
72         start
73 }
74
75 RETVAL=0
76 # See how we were called.
77 case "$1" in
78   start)
79         start
80         ;;
81   stop)
82         stop
83         ;;
84   restart)
85         stop
86         start
87         ;;
88   try-restart)
89         condrestart 0
90         ;;
91   force-reload)
92         # pcscd doesn't support reloading on HUP
93         condrestart 7
94         ;;
95   status)
96         status --pidfile $pidfile pcscd
97         RETVAL=$?
98         ;;
99   *)
100         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
101         exit 3
102 esac
103
104 exit $RETVAL