[Date Prev] [Date Index] [Date Next] [Thread Prev] [Thread Index] [Thread Next]

[PATCH] Spruce up the conserver init.d script

Eric Biederman ebiederm@aristanetworks.com
Mon, 5 Oct 2009 10:16:21 GMT


Another patch we have been carrying that hasn't made it up to conserver.

- Add basic error handling
- Rename the current restart reload
- Implement a true restart

Eric
Add error handling.
make restart actually force a restart of conserver.
make reload simply reload conservers configuration.

---
diff -ur conserver-8.1.17/contrib/redhat-rpm/conserver.init conserver-8.1.17-initscript/contrib/redhat-rpm/conserver.init
--- conserver-8.1.17/contrib/redhat-rpm/conserver.init	2009-09-27 02:15:16.000000000 -0400
+++ conserver-8.1.17-initscript/contrib/redhat-rpm/conserver.init	2009-10-05 05:13:40.926619734 -0400
@@ -25,31 +25,48 @@
 [ -x $DAEMON  ] || exit 1
 
 
+start()
+{
+	echo -n "Starting conserver: "
+	daemon --user "${RUNAS-}" $DAEMON ${OPTIONS--d}
+	RETVAL=$?
+	[ "$RETVAL" = 0 ] && touch /var/lock/subsys/conserver
+	echo
+}
+
+stop()
+{
+	echo -n "Shutting down conserver: "
+	killproc conserver
+	RETVAL=$?
+	[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/conserver
+	echo
+}
+  
 # See how we were called.
 case "$1" in
   start)
-    echo -n "Starting conserver: "
-    daemon --user "${RUNAS-}" $DAEMON ${OPTIONS--d}
-    echo
-    touch /var/lock/subsys/conserver
+    start
     ;;
   stop)
-    echo -n "Shutting down conserver: "
-    killproc conserver
-    echo
-    rm -f /var/lock/subsys/conserver
+    stop
     ;;
   status)
     status conserver
     ;;
   restart)
-    echo -n "Restarting conserver: "
+    stop
+    start
+    ;;
+  reload)
+    echo -n "Reloading conserver: "
     killproc conserver -HUP
+    RETVAL=$?
     echo
     ;;
   *)
-    echo "Usage: conserver {start|stop|restart|status}"
-    exit 1
+    echo "Usage: conserver {start|stop|restart|reload|status}"
+    RETVAL=1
 esac
 
-exit 0
+exit $RETVAL