summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debian/buildsys/common/bcfg2-server.init50
-rw-r--r--debian/buildsys/common/bcfg2.init78
2 files changed, 83 insertions, 45 deletions
diff --git a/debian/buildsys/common/bcfg2-server.init b/debian/buildsys/common/bcfg2-server.init
index 9ec06ddfd..ec920a377 100644
--- a/debian/buildsys/common/bcfg2-server.init
+++ b/debian/buildsys/common/bcfg2-server.init
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Bcfg2Server - Bcfg2 configuration daemon
+# bcfg-server - Bcfg2 configuration daemon
#
# chkconfig: 2345 19 81
# description: bcfg2 server for configuration requests
@@ -29,57 +29,65 @@ test -x $DAEMON || exit 5
# Internal variables
BINARY=$(basename $DAEMON)
-case "$1" in
- start)
+start () {
echo -n "Starting Configuration Management Server: "
start_daemon ${DAEMON} ${PARAMS}
STATUS=$?
if [ "$STATUS" = 0 ]
then
log_success_msg "bcfg2-server"
+ test -d /var/lock/subsys && touch /var/log/subsys/bcfg2-server
else
log_failure_msg "bcfg2-server"
fi
- exit $STATUS
- ;;
- stop)
+ return $STATUS
+}
+
+stop () {
echo -n "Stopping Configuration Management Server: "
killproc ${BINARY}
STATUS=$?
if [ "$STATUS" = 0 ]; then
log_success_msg "bcfg2-server"
- exit 0
+ test -d /var/lock/subsys && touch /var/log/subsys/bcfg2-server
else
log_failure_msg "bcfg2-server"
fi
- exit $STATUS
- ;;
- restart|force-reload|reload)
- $0 stop
- sleep 5
- $0 start
- ;;
- status)
+ return $STATUS
+}
+
+status () {
# Inspired by redhat /etc/init.d/functions status() call
PID=$(pidof -x $BINARY)
if [ -n "$PID" ]; then
echo "$BINARY (pid $PID) is running..."
- exit 0
+ return 0
fi
if [ -f $PIDFILE ]; then
if [ -n "$PID" ]; then
log_failure_msg "$BINARY dead but pid file exists..."
- exit 1
+ return 1
fi
fi
log_failure_msg "$BINARY is not running"
- exit 3
+ return 3
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status
;;
- *)
- log_success_msg "Usage: $0 {start|stop|status|reload|restart|force-reload}"
- exit 1
+ *)
+ log_success_msg "Usage: $0 {start|stop|status|reload|restart|force-reload}"
+ exit 1
;;
esac
diff --git a/debian/buildsys/common/bcfg2.init b/debian/buildsys/common/bcfg2.init
index 330cf4fdd..0f6e7b3cd 100644
--- a/debian/buildsys/common/bcfg2.init
+++ b/debian/buildsys/common/bcfg2.init
@@ -41,19 +41,20 @@ test -f "/etc/default/bcfg2" && . /etc/default/bcfg2
test -x $BCFG2 || exit 5
# Agent mode daemon capability
-PIDFILE=/var/run/bcfg2.pid
+PIDFILE=/var/run/bcfg2-agent.pid
# Internal variables
BINARY=$(basename $BCFG2)
+AGENT_EXTRA_OPTS="-A -i ${PIDFILE}"
+
# Include lsb functions
. /lib/lsb/init-functions
-case "$1" in
- start)
+start () {
echo -n "Running configuration management client: "
if [ "$BCFG2_AGENT" -eq 1 ]
then
- start_daemon ${BCFG2} -A -i /var/run/bcfg2-agent.pid ${BCFG2_OPTIONS} ${BCFG2_OPTIONS_AGENT}
+ start_daemon ${BCFG2} ${AGENT_EXTRA_OPTS} ${BCFG2_OPTIONS} ${BCFG2_OPTIONS_AGENT}
STATUS=$?
fi
@@ -65,16 +66,35 @@ case "$1" in
if [ "$STATUS" -eq 0 ]
then
log_success_msg "bcfg2"
+ if [ "$BCFG2_AGENT" -eq 1 ]; then
+ test -d /var/lock/subsys && touch /var/log/subsys/bcfg2-agent
+ fi
else
log_failure_msg "bcfg2"
fi
- exit $STATUS
- ;;
- status)
- # Since we are always OK, always return OK as status
- exit 0
- ;;
- stop)
+ return $STATUS
+}
+
+status () {
+ if [ "$BCFG2_AGENT" -eq 1 ]
+ then
+ PID=$(pidof -x $BINARY)
+ if [ -n "$PID" ] ; then
+ log_success_msg "$BINARY (pid $PID) is running..."
+ return 0
+ fi
+ if [ -f $PIDFILE ]; then
+ if [ -n "$PID" ]; then
+ log_failure_msg "$BINARY dead but pid file exists..."
+ return 1
+ fi
+ fi
+ else
+ return 0
+ fi
+}
+
+stop () {
if [ "$BCFG2_AGENT" -eq 1 ]
then
echo -n "Stopping configuration management client daemon: "
@@ -83,25 +103,35 @@ case "$1" in
if [ "$STATUS" -eq 0 ]
then
log_success_msg "bcfg2"
- exit 0
+ if [ "$BCFG2_AGENT" -eq 1 ]; then
+ test -d /var/lock/subsys && rm -f /var/log/subsys/bcfg2-agent
+ fi
else
log_failure_msg "bcfg2"
fi
- exit $STATUS
-
+ return $STATUS
else
- true
+ return 0
fi
+}
+
+case $"1" in
+ start)
+ start
;;
- restart|reload|force-reload)
- if [ "$BCFG2_AGENT" -eq 1 ]
- then
- $0 stop
- sleep 5
- $0 start
- else
- true
- fi
+ stop)
+ stop
+ ;;
+ status)
+ status
+ ;;
+ restart|reload|force-reload)
+ if [ "$BCFG2_AGENT" -eq 1 ]
+ then
+ stop
+ sleep 5
+ start
+ fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload|status}"