-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrc.pcscd
94 lines (82 loc) · 1.37 KB
/
rc.pcscd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
#
# /etc/rc.d/rc.pcscd
#
# Start/stop/restart the PC/SC daemon
#
# PC/SC daemon should be started after pcmcia and shut down
# before it for smooth experience with PCMCIA readers
#
# Bash colors
C_GREEN=$'\e[32;01m'
C_YELLOW=$'\e[33;01m'
C_RED=$'\e[31;01m'
C_BLUE=$'\e[0;34m'
C_NORMAL=$'\e[0m'
# Print status functions
echo_done() {
echo "${C_GREEN}Done${C_NORMAL}"
}
echo_fail() {
echo "${C_RED}Failure${C_NORMAL}"
}
echo_status() {
if [ $? != 0 ]; then
echo_fail
else
echo_done
fi
}
SNAME='PC/SC daemon'
NAME=pcscd
CMD=/usr/sbin/pcscd
CMD_OPTS=
PIDFILE=/var/run/$NAME.pid
start() {
if [ -x $CMD ]; then
if [ ! -e $PIDFILE ]; then
rm -f /var/run/$NAME.pub
rm -f /var/run/$NAME.comm
echo -n "Starting $SNAME ($CMD): "
if [ -x /usr/sbin/update-reader.conf ]; then
/usr/sbin/update-reader.conf
fi
$CMD $CMD_OPTS
echo_status
else
echo "Starting $SNAME: Already running with PID `cat $PIDFILE`"
fi
fi
}
stop() {
if [ -e $PIDFILE ]; then
echo -n "Stopping ${SNAME}... "
killall $NAME 1>/dev/null 2>&1
echo_status
else
echo "Stopping ${SNAME}: Not running"
fi
}
restart() {
stop
sleep 2
start
}
help() {
echo "$SNAME control"
echo "Usage: $0 start|stop|restart"
echo
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
restart
;;
*)
help
esac