summaryrefslogtreecommitdiffstats
path: root/import-layers/meta-openembedded/meta-oe/recipes-support/openct/openct/openct.init
blob: c6896095e3ae4afe225121d011085bc7b3aaa7cc (plain)
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
#!/bin/sh
#
# openct       This shell script takes care of starting and stopping OpenCT.
#
# chkconfig:   2345 24 89
# description: OpenCT is a middleware framework for smart card terminals.
#
# processname: ifdhandler
# config:      /etc/openct.conf

### BEGIN INIT INFO
# Provides: openct
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: $syslog $network
# Should-Stop: $syslog $network
# Short-Description: Middleware framework for smart card terminals
# Description: This starts/stops the OpenCT middleware framework support
#              for smart card terminals.
### END INIT INFO

. /etc/init.d/functions

exec="/usr/sbin/openct-control"
prog=openct
proc=ifdhandler

OPENCT_OPTIONS=
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    retval=0
    if ! status $proc >/dev/null 2>&1 ; then
        action $"Initializing OpenCT smart card terminals: " \
            $exec $OPENCT_OPTIONS init
        retval=$?
        [ $retval -eq 0 ] && touch $lockfile
    fi
    return $retval
}

stop() {
    if status $proc >/dev/null 2>&1 ; then
        action $"Stopping OpenCT smart card terminals: " \
            $exec $OPENCT_OPTIONS shutdown
    fi
    retval=$?
    if [ $retval -eq 0 ] ; then
        rm -f /var/run/openct/status
        rm -f $lockfile
    fi
    return $retval
}

restart() {
    stop
    start
}

oct_status() {
    status $proc
    retval=$?
    if [ -e /var/run/openct/status ] ; then
        $exec $OPENCT_OPTIONS status
        [ -e /var/run/openct/status ] && \
            echo $"Waiting for reader attach/detach events..."
    fi
    return $retval
}

case "$1" in
    start|stop|restart)
        $1
        ;;
    reload|force-reload)
        restart
        ;;
    status)
        oct_status
        ;;
    try-restart|condrestart)
  	[ ! -f $lockfile ] || restart
	;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
        exit 2
esac
OpenPOWER on IntegriCloud