ab6512a
diff -up openwsman-2.2.4/etc/init/openwsmand.sh.cmake.orig openwsman-2.2.4/etc/init/openwsmand.sh.cmake
ab6512a
--- openwsman-2.2.4/etc/init/openwsmand.sh.cmake.orig	2010-10-06 11:10:10.000000000 +0200
ab6512a
+++ openwsman-2.2.4/etc/init/openwsmand.sh.cmake	2010-11-11 16:52:19.494661859 +0100
ab6512a
@@ -4,28 +4,28 @@
ab6512a
 # Provides: openwsmand
ab6512a
 # Required-Start: $remote_fs
ab6512a
 # Required-Stop: $network
ab6512a
-# Default-Start: 2 3 4 5
ab6512a
-# Default-Stop: 0 1 6 
ab6512a
+# Default-Start:
ab6512a
+# Default-Stop:
ab6512a
 # Short-Description: Openwsman Daemon
ab6512a
 # Description: openwsmand
ab6512a
 #       Start/Stop the Openwsman Daemon
ab6512a
 ### END INIT INFO
ab6512a
 #
ab6512a
 #
ab6512a
-# chkconfig: 2345 36 64
ab6512a
+# chkconfig: - 36 64
ab6512a
 # description: Openwsman Daemon
ab6512a
 # processname: openwsmand
ab6512a
 
6091aac
 NAME=openwsmand
6091aac
 DAEMON=/usr/sbin/$NAME
6091aac
 OPTIONS=-S # with SSL
6091aac
-PIDFILE=/var/run/$NAME.pid
6091aac
+PIDFILE=/var/run/wsmand.pid
6091aac
 
6091aac
 lsb=0
6091aac
 
6091aac
 if [ $EUID != 0 ]; then
6091aac
  echo "This script must be run as root."
6091aac
- exit 1;
6091aac
+ exit 4;
6091aac
 fi
6091aac
 
6091aac
 if [ "$DESCRIPTIVE" = "" ]; then
6091aac
@@ -65,6 +65,7 @@ start()
6091aac
 
6091aac
 	echo "NOTE: The script uses /dev/random device for generating some random bits while generating the server key."
ab6512a
 	echo "      If this takes too long, you can replace the value of \"RANDFILE\" in @SYSCONFDIR@/ssleay.cnf with /dev/urandom. Please understand the implications of replacing the RNADFILE."
ab6512a
+	exit 6 # Six means "program is not configured", seems to be suitable value
6091aac
 		
6091aac
       fi
6091aac
     fi
6091aac
@@ -103,6 +104,9 @@ case "$1" in
6091aac
     stop)
6091aac
     	stop
6091aac
 	rm -f $lockfile
6091aac
+	# pid file should be removed by server itself, but it's marked as
6091aac
+	# TODO in wsmand.c source file;)
ab6512a
+	rm -f $PIDFILE
6091aac
     ;;
6091aac
 
6091aac
     restart)
ab6512a
@@ -137,6 +141,16 @@ case "$1" in
6091aac
         echo "             running"
6091aac
       else
ab6512a
         echo "             stopped"
6091aac
+        if [ -e $PIDFILE ]; then
6091aac
+          echo "             stopped, but pid file exists"
6091aac
+          exit 1
6091aac
+        elif [ -e $lockfile ]; then
6091aac
+          echo "             stopped, but lock file exists"
6091aac
+          exit 2
6091aac
+        else
6091aac
+          echo "             stopped"
6091aac
+          exit 3
6091aac
+        fi
6091aac
       fi
6091aac
     fi
6091aac
     ;;
ab6512a
@@ -147,6 +161,8 @@ case "$1" in
6091aac
 
6091aac
     *)
ab6512a
     echo "Usage: $0 {restart|start|stop|reload|force-reload|status|condrestart}"
6091aac
+    [ "$1" = "usage" ] && exit 0
6091aac
+    exit 2
6091aac
 esac
6091aac
 
6091aac
 if [ $lsb -ne 0 ]; then