Blob Blame History Raw
diff -up openwsman-2.2.3/etc/init/openwsmand.sh.in.orig openwsman-2.2.3/etc/init/openwsmand.sh.in
--- openwsman-2.2.3/etc/init/openwsmand.sh.in.orig	2010-09-06 15:49:57.000000000 +0200
+++ openwsman-2.2.3/etc/init/openwsmand.sh.in	2010-09-13 15:09:17.823620695 +0200
@@ -19,13 +19,13 @@
 NAME=openwsmand
 DAEMON=/usr/sbin/$NAME
 OPTIONS=-S # with SSL
-PIDFILE=/var/run/$NAME.pid
+PIDFILE=/var/run/wsmand.pid
 
 lsb=0
 
 if [ $EUID != 0 ]; then
  echo "This script must be run as root."
- exit 1;
+ exit 4;
 fi
 
 if [ "$DESCRIPTIVE" = "" ]; then
@@ -65,6 +65,7 @@ start()
 
 	echo "NOTE: The script uses /dev/random device for generating some random bits while generating the server key."
 	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."
+        exit 6 # Six means "program is not configured", seems to be suitable value
 		
       fi
     fi
@@ -103,6 +104,9 @@ case "$1" in
     stop)
     	stop
 	rm -f $lockfile
+	# pid file should be removed by server itself, but it's marked as
+	# TODO in wsmand.c source file;)
+        rm -f $PIDFILE
     ;;
 
     restart)
@@ -136,7 +140,16 @@ case "$1" in
       if [ $? -eq 0 ]; then
         echo "             running"
       else
-        echo "             stopped"
+        if [ -e $PIDFILE ]; then
+          echo "             stopped, but pid file exists"
+          exit 1
+        elif [ -e $lockfile ]; then
+          echo "             stopped, but lock file exists"
+          exit 2
+        else
+          echo "             stopped"
+          exit 3
+        fi
       fi
     fi
     ;;
@@ -147,6 +160,8 @@ case "$1" in
 
     *)
     echo "Usage: $0 {restart|start|stop|reload|force-reload|status}"
+    [ "$1" = "usage" ] && exit 0
+    exit 2
 esac
 
 if [ $lsb -ne 0 ]; then