OK, here's a patch which uses some of the functions from
</lib/lsb/init-functions>.

Changes are:
- Depend on lsb-base
- Always source /lib/lsb/init-functions
- Don't "set -e", per LSB 3.1.0 section 20.8:
  > Conforming scripts shall not specify the "exit on error" option
  > (i.e. set -e) when sourcing this file, or calling any of the
  > commands thus made available.
- Reimplement restart|force-reload in terms of stop & start.
- Call start-stop-daemon with --retry in "stop" to wait until it really
  has been stopped.

There might not be compelling reasons to use this version, which is fine
with me.

-Ted
diff -ru ../pcsc-lite-1.3.2/debian/control ../pcsc-lite-1.3.2-new/debian/control
--- ../pcsc-lite-1.3.2/debian/control	2006-10-07 01:03:57.000000000 +1000
+++ ../pcsc-lite-1.3.2-new/debian/control	2006-10-07 02:18:21.000000000 +1000
@@ -8,7 +8,7 @@
 Package: pcscd
 Architecture: any
 Priority: extra
-Depends: libccid | pcsc-ifd-handler, ${shlibs:Depends}
+Depends: libccid | pcsc-ifd-handler, ${shlibs:Depends}, lsb-base
 Conflicts: libpcsclite0 (<< 1.2.0-rc1-1), libccid (<= 1.0.0-1)
 Description: Middleware to access a smart card using PC/SC (daemon side)
  The purpose of PC/SC Lite is to provide a Windows(R) SCard interface 
diff -ru ../pcsc-lite-1.3.2/debian/pcscd.init ../pcsc-lite-1.3.2-new/debian/pcscd.init
--- ../pcsc-lite-1.3.2/debian/pcscd.init	2006-10-07 01:03:57.000000000 +1000
+++ ../pcsc-lite-1.3.2-new/debian/pcscd.init	2006-10-07 02:20:24.000000000 +1000
@@ -6,6 +6,19 @@
 # Carlos Prados Bocos <[EMAIL PROTECTED]>
 # modifications by Ludovic Rousseau <[EMAIL PROTECTED]>
 
+### BEGIN INIT INFO
+# Provides: pcscd
+# Required-Start: $local_fs $remote_fs $syslog
+# Required-Stop: $local_fs $remote_fs $syslog
+# Should-Start: usbmgr udev hotplug
+# Should-Stop: usbmgr udev hotplug
+# 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
+
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 NAME=pcscd
 DAEMON=/usr/sbin/$NAME
@@ -17,54 +30,42 @@
 # Gracefully exit if the package has been removed (but not purged).
 test -x $DAEMON || exit 0
 
-if [ -f /lib/lsb/init-functions ]; then
-	. /lib/lsb/init-functions
-else
-	log_success_msg() { echo "$@"; }
-	log_warning_msg() { echo "$@"; }
-	log_failure_msg() { echo "$@"; }
-fi
-
-set -e
+. /lib/lsb/init-functions
 
 case "$1" in
   start)
-	echo -n "Starting $DESC: $NAME"
+	log_daemon_msg "Starting $DESC" $NAME
 	# if the daemon is already running we REstart it
 	if [ -f $PIDFILE ]; then
-	  echo " already running."
+	  log_progress_msg "already running, "
 	  $0 restart
 	else
 	  start-stop-daemon --start --quiet --pidfile $PIDFILE \
 	    --exec $DAEMON -- --error
-	  echo "."
+	  log_end_msg $?
 	fi
 	;;
 
   stop)
-	echo -n "Stopping $DESC: $NAME"
+    log_daemon_msg "Stopping $DESC" $NAME
 	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
-	  --name $NAME
-	echo "."
+	  --retry --name $NAME
+	log_end_msg $?
 	;;
 	
   restart|force-reload)
 	$0 stop
-	echo -n "Starting $DESC: $NAME"
-	sleep 2
-	start-stop-daemon --start --quiet --pidfile $PIDFILE \
-		--exec $DAEMON -- --error
-	echo "."
+	$0 start
 	;;
 	
   restart-if-running)
-    echo -n "Restarting $DESC if it is running: $NAME"
+    log_daemon_msg "Restarting $DESC if it is running" $NAME
 	if $0 status &> /dev/null
 	then
 		echo "."
 		$0 restart
 	else
-		echo " (not running)."
+		log_success_msg " (not running)."
 	fi
 	;; 
 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to