diff --git a/debian/pcscd.init b/debian/pcscd.init new file mode 100644 index 0000000000000000000000000000000000000000..0cb91ce2cb0b98c9fdc5dc98ad2bf8036ca120c6 --- /dev/null +++ b/debian/pcscd.init @@ -0,0 +1,119 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: pcscd +# Required-Start: $local_fs $remote_fs $syslog +# Required-Stop: $local_fs $remote_fs $syslog +# Should-Start: udev +# Should-Stop: udev +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Daemon to access a smart card using PC/SC +# Description: The PC/SC daemon is used to dynamically +# allocate/deallocate reader drivers at runtime and manage +# connections to the readers. +### END INIT INFO + +# Authors: +# Carlos Prados Bocos <cprados@debian.org> +# Ludovic Rousseau <rousseau@debian.org> + +# Do NOT "set -e" + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="PCSC Lite resource manager" +NAME=pcscd +DAEMON=/usr/sbin/$NAME +IPCDIR=/run/pcscd +PIDFILE=$IPCDIR/$NAME.pid + +# Exit if the package is not installed +[ -x "$DAEMON" ] || exit 0 + +# Prefer PCSCD_ARGS per systemd, falling back to DAEMON_ARGS for old configs. +[ -r /etc/default/$NAME ] && . /etc/default/$NAME +. /lib/init/vars.sh +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ + ${PCSCD_ARGS-$DAEMON_ARGS} \ + || return 2 + # Add code here, if necessary, that waits for the process to be ready + # to handle requests from services started subsequently which depend + # on this one. As a last resort, sleep for some time. +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=3 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/debian/pcscd.maintscript b/debian/pcscd.maintscript index 478d7aefc8d0fecb9359d0f33dc330b1a0b6f43b..35884317e9abcda1e9babce0a69533946ff2d764 100644 --- a/debian/pcscd.maintscript +++ b/debian/pcscd.maintscript @@ -1,2 +1 @@ rm_conffile /etc/reader.conf.d/0comments 1.9.3-2~ pcscd -rm_conffile /etc/init.d/pcscd 2.3.0-3~ pcscd