~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to vivid/etc/init.d/pcscd

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
### BEGIN INIT INFO
 
3
# Provides: pcscd
 
4
# Required-Start:    $local_fs $remote_fs $syslog
 
5
# Required-Stop:     $local_fs $remote_fs $syslog
 
6
# Should-Start:      udev
 
7
# Should-Stop:       udev
 
8
# Default-Start:     2 3 4 5
 
9
# Default-Stop:      0 1 6
 
10
# Short-Description: Daemon to access a smart card using PC/SC
 
11
# Description:       The PC/SC daemon is used to dynamically
 
12
#                    allocate/deallocate reader drivers at runtime and manage
 
13
#                    connections to the readers.
 
14
### END INIT INFO
 
15
 
 
16
# Authors: 
 
17
#   Carlos Prados Bocos <cprados@debian.org>
 
18
#   Ludovic Rousseau <rousseau@debian.org>
 
19
 
 
20
# Do NOT "set -e"
 
21
 
 
22
# PATH should only include /usr/* if it runs after the mountnfs.sh script
 
23
PATH=/sbin:/usr/sbin:/bin:/usr/bin
 
24
DESC="PCSC Lite resource manager"
 
25
NAME=pcscd
 
26
DAEMON=/usr/sbin/$NAME
 
27
IPCDIR=/var/run/pcscd
 
28
PIDFILE=$IPCDIR/$NAME.pid
 
29
SCRIPTNAME=/etc/init.d/$NAME
 
30
 
 
31
# if you need to pass arguments to pcscd you should edit the file
 
32
# /etc/default/pcscd and add a line 
 
33
# DAEMON_ARGS="--your-option"
 
34
 
 
35
# Exit if the package is not installed
 
36
[ -x "$DAEMON" ] || exit 0
 
37
 
 
38
# Read configuration variable file if it is present
 
39
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
40
 
 
41
# Load the VERBOSE setting and other rcS variables
 
42
. /lib/init/vars.sh
 
43
 
 
44
# Define LSB log_* functions.
 
45
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
 
46
. /lib/lsb/init-functions
 
47
 
 
48
# get LANG variable (code from /etc/init.d/keymap.sh)
 
49
ENV_FILE="none"
 
50
[ -r /etc/environment ] && ENV_FILE="/etc/environment"
 
51
[ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
 
52
 
 
53
value=$(egrep "^[^#]*LANG=" $ENV_FILE | tail -n1 | cut -d= -f2)
 
54
eval LANG=$value
 
55
 
 
56
#
 
57
# Function that starts the daemon/service
 
58
#
 
59
do_start()
 
60
{
 
61
        # create $IPCDIR with correct access rights
 
62
        if [ ! -d $IPCDIR ]
 
63
        then
 
64
                rm -rf $IPCDIR
 
65
                mkdir $IPCDIR
 
66
        fi
 
67
        chmod 0755 $IPCDIR
 
68
 
 
69
        # Return
 
70
        #   0 if daemon has been started
 
71
        #   1 if daemon was already running
 
72
        #   2 if daemon could not be started
 
73
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
 
74
                || return 1
 
75
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
 
76
                $DAEMON_ARGS \
 
77
                || return 2
 
78
        # Add code here, if necessary, that waits for the process to be ready
 
79
        # to handle requests from services started subsequently which depend
 
80
        # on this one.  As a last resort, sleep for some time.
 
81
}
 
82
 
 
83
#
 
84
# Function that stops the daemon/service
 
85
#
 
86
do_stop()
 
87
{
 
88
        # Return
 
89
        #   0 if daemon has been stopped
 
90
        #   1 if daemon was already stopped
 
91
        #   2 if daemon could not be stopped
 
92
        #   other if a failure occurred
 
93
        start-stop-daemon --stop --quiet --retry=3 --pidfile $PIDFILE --name $NAME
 
94
        RETVAL="$?"
 
95
        [ "$RETVAL" = 2 ] && return 2
 
96
}
 
97
 
 
98
case "$1" in
 
99
  start)
 
100
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
 
101
        do_start
 
102
        case "$?" in
 
103
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 
104
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 
105
        esac
 
106
        ;;
 
107
  stop)
 
108
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
 
109
        do_stop
 
110
        case "$?" in
 
111
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
 
112
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 
113
        esac
 
114
        ;;
 
115
  status)
 
116
          status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
 
117
          ;;
 
118
  restart|force-reload)
 
119
        #
 
120
        # If the "reload" option is implemented then remove the
 
121
        # 'force-reload' alias
 
122
        #
 
123
        log_daemon_msg "Restarting $DESC" "$NAME"
 
124
        do_stop
 
125
        case "$?" in
 
126
          0|1)
 
127
                do_start
 
128
                case "$?" in
 
129
                        0) log_end_msg 0 ;;
 
130
                        1) log_end_msg 1 ;; # Old process is still running
 
131
                        *) log_end_msg 1 ;; # Failed to start
 
132
                esac
 
133
                ;;
 
134
          *)
 
135
                # Failed to stop
 
136
                log_end_msg 1
 
137
                ;;
 
138
        esac
 
139
        ;;
 
140
  *)
 
141
        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
 
142
        exit 3
 
143
        ;;
 
144
esac
 
145
 
 
146
: