File openct-init.patch of Package openct

--- etc/init-script.in
+++ etc/init-script.in
@@ -1,12 +1,51 @@
 #! /bin/sh
 #
+# /etc/init.d/openct
+#
+### BEGIN INIT INFO
+# Provides:          openct
+# Required-Start:    $remote_fs
+# Required-Stop:     $remote_fs
+# Should-Start:      $syslog
+# Should-Stop:       $syslog
+# Default-Start:     2 3 5
+# Default-Stop:
+# Short-Description: Smart card terminal framework
+# Description:       Runs drivers for smart card readers
+### END INIT INFO
 
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=@sbindir@/openct-control
 NAME=OpenCT
 DESC="smart card terminal framework"
 
-test -x $DAEMON || exit 0
+# Shell functions sourced from /etc/rc.status:
+#      rc_check         check and set local and overall rc status
+#      rc_status        check and set local and overall rc status
+#      rc_status -v     ditto but be verbose in local rc status
+#      rc_status -v -r  ditto and clear the local rc status
+#      rc_failed        set local and overall rc status to failed
+#      rc_reset         clear local rc status (overall remains)
+#      rc_exit          exit appropriate to overall rc status
+. /etc/rc.status
+
+rc_reset
+
+# Return values acc. to LSB for all commands but status:
+# 0 - success
+# 1 - misc error
+# 2 - invalid or excess args
+# 3 - unimplemented feature (e.g. reload)
+# 4 - insufficient privilege
+# 5 - program not installed
+# 6 - program not configured
+#
+# Note that starting an already running service, stopping
+# or restarting a not-running service as well as the restart
+# with force-reload (in case signalling is not supported) are
+# considered a success.
+
+test -x $DAEMON || exit 5
 
 # create the directory for our status and socket files,
 # if it does not exist.
@@ -18,52 +57,54 @@
 	# this example would assign the directory to a group "scard"
 	# and set permissions so only users in that group can access
 	# smart card readers via openct.
-	#chown root:scard "@OPENCT_SOCKET_PATH@"
-	#chmod 0750 "@OPENCT_SOCKET_PATH@"
+	chown @USER@:@GROUP@ "@OPENCT_SOCKET_PATH@"
+	chmod 0755 "@OPENCT_SOCKET_PATH@"
 fi
 
-set -e
-
 case "$1" in
   start)
 	echo -n "Starting $DESC: $NAME"
 	$DAEMON init
-	echo "."
+	rc_status -v
 	;;
   stop)
 	echo -n "Stopping $DESC: $NAME "
-	$DAEMON shutdown
-	echo "."
+	if test -f @OPENCT_SOCKET_PATH@/status ; then
+	    $DAEMON shutdown
+	fi
+	rc_status -v
 	;;
-  #reload)
-	#
-	#	If the daemon can reload its config files on the fly
-	#	for example by sending it SIGHUP, do it here.
-	#
-	#	If the daemon responds to changes in its config file
-	#	directly anyway, make this a do-nothing entry.
-	#
-	# echo -n "Reloading $DESC configuration..."
-	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
-	#	@localstatedir@/run/$NAME.pid --exec $DAEMON
-	# echo "done."
-  #;;
+  reload)
+  	;;
   restart|force-reload)
 	#
 	#	If the "reload" option is implemented, move the "force-reload"
 	#	option to the "reload" entry above. If not, "force-reload" is
 	#	just the same as "restart".
 	#
-	echo -n "Restarting $DESC: $NAME"
-	$DAEMON shutdown
+	echo -n "Restarting $DESC: $NAME "
+	if test -f @OPENCT_SOCKET_PATH@/status ; then
+	    $DAEMON shutdown
+	fi
 	sleep 0.1
 	$DAEMON init
-	echo "."
+	rc_status -v
+	;;
+  try-restart)
+	$0 status >/dev/null &&  $0 restart
+	rc_status
+	;;
+  status)
+  	echo -n "Checking for $DESC: $NAME"
+	if openct-tool list >/dev/null 2>&1; then
+		rc_failed 0
+	else
+		rc_failed 3
+	fi
+	rc_status -v
 	;;
   *)
-	N=/etc/init.d/$NAME
-	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
-	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" >&2
 	exit 1
 	;;
 esac
openSUSE Build Service is sponsored by