6091aac
diff -up openwsman-2.2.3/etc/init/openwsmand.sh.in.orig openwsman-2.2.3/etc/init/openwsmand.sh.in
6091aac
--- openwsman-2.2.3/etc/init/openwsmand.sh.in.orig	2010-09-06 15:49:57.000000000 +0200
6091aac
+++ openwsman-2.2.3/etc/init/openwsmand.sh.in	2010-09-13 15:09:17.823620695 +0200
6091aac
@@ -19,13 +19,13 @@
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."
6091aac
 	echo -e "      If this takes too long, you can replace the value of \"RANDFILE\" in @SYSCONFDIR@/ssleay.cnf with /dev/urandom.\n      Please understand the implications of doing do."
6091aac
+        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;)
6091aac
+        rm -f $PIDFILE
6091aac
     ;;
6091aac
 
6091aac
     restart)
6091aac
@@ -136,7 +140,16 @@ case "$1" in
6091aac
       if [ $? -eq 0 ]; then
6091aac
         echo "             running"
6091aac
       else
6091aac
-        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
     ;;
6091aac
@@ -147,6 +160,8 @@ case "$1" in
6091aac
 
6091aac
     *)
6091aac
     echo "Usage: $0 {restart|start|stop|reload|force-reload|status}"
6091aac
+    [ "$1" = "usage" ] && exit 0
6091aac
+    exit 2
6091aac
 esac
6091aac
 
6091aac
 if [ $lsb -ne 0 ]; then