summaryrefslogtreecommitdiffstats
path: root/debian/bcfg2.init
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-10-29 21:12:39 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-10-29 21:12:39 +0000
commita5ac33e90dfdd61062d22ad73f93edd57aedf3ae (patch)
treeeabaadb2a1d2685c8b0c9daade619903766002e6 /debian/bcfg2.init
parent656d9d1b091718294681d13cf502071b87cbacb6 (diff)
downloadbcfg2-a5ac33e90dfdd61062d22ad73f93edd57aedf3ae.tar.gz
bcfg2-a5ac33e90dfdd61062d22ad73f93edd57aedf3ae.tar.bz2
bcfg2-a5ac33e90dfdd61062d22ad73f93edd57aedf3ae.zip
Add new Debian packaging from Sami Haahtinen
Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5512 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'debian/bcfg2.init')
-rw-r--r--debian/bcfg2.init141
1 files changed, 141 insertions, 0 deletions
diff --git a/debian/bcfg2.init b/debian/bcfg2.init
new file mode 100644
index 000000000..76adf0ad4
--- /dev/null
+++ b/debian/bcfg2.init
@@ -0,0 +1,141 @@
+#!/bin/sh
+#
+# bcfg2 - bcfg2 configuration client
+#
+# chkconfig: 2345 19 81
+# description: bcfg2 client for configuration requests
+#
+### BEGIN INIT INFO
+# Provides: bcfg2
+# Required-Start: $network $remote_fs $named
+# Required-Stop: $network $remote_fs $named
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Configuration management client
+# Description: Bcfg2 is a configuration management system that builds
+# installs configuration files served by bcfg2-server
+# This is a client that installs the server provided
+# Configuration.
+### END INIT INFO
+
+# This might need some better logic
+BCFG2=/usr/sbin/bcfg2
+
+# Set default options
+# You can set script specific options with BCFG2_OPTIONS_INIT
+# You can set agent-mode specific options with BCFG2_OPTIONS_AGENT
+BCFG2_OPTIONS="-q"
+
+# Disabled per default
+BCFG2_ENABLED=0
+BCFG2_INIT=0
+BCFG2_AGENT=0
+
+# Include default startup configuration if exists
+test -f "/etc/default/bcfg2" && . /etc/default/bcfg2
+
+[ "$BCFG2_ENABLED" -eq 0 ] && exit 0
+[ "$BCFG2_AGENT" -eq 0 -a "$BCFG2_INIT" -eq 0 ] && exit 0
+
+# Exit if bcfg2 doesn't exist and is not executable
+test -x $BCFG2 || exit 5
+
+# Agent mode daemon capability
+PIDFILE=/var/run/bcfg2-agent.pid
+# Internal variables
+BINARY=$(basename $BCFG2)
+
+AGENT_EXTRA_OPTS="-A -i ${PIDFILE}"
+
+# Include lsb functions
+. /lib/lsb/init-functions
+
+start () {
+ echo -n "Running configuration management client: "
+ if [ "$BCFG2_AGENT" -eq 1 ]
+ then
+ start_daemon ${BCFG2} ${AGENT_EXTRA_OPTS} ${BCFG2_OPTIONS} ${BCFG2_OPTIONS_AGENT}
+ STATUS=$?
+ fi
+
+ if [ "$BCFG2_INIT" -eq 1 ]; then
+ ${BCFG2} ${BCFG2_OPTIONS} ${BCFG2_OPTIONS_INIT}
+ STATUS=$?
+ fi
+
+ if [ "$STATUS" -eq 0 ]
+ then
+ log_success_msg "bcfg2"
+ if [ "$BCFG2_AGENT" -eq 1 ]; then
+ test -d /var/lock/subsys && touch /var/lock/subsys/bcfg2-agent
+ fi
+ else
+ log_failure_msg "bcfg2"
+ fi
+ 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: "
+ killproc -p $PIDFILE ${BINARY}
+ STATUS=$?
+ if [ "$STATUS" -eq 0 ]
+ then
+ log_success_msg "bcfg2"
+ if [ "$BCFG2_AGENT" -eq 1 ]; then
+ test -d /var/lock/subsys && rm -f /var/lock/subsys/bcfg2-agent
+ fi
+ else
+ log_failure_msg "bcfg2"
+ fi
+ return $STATUS
+ else
+ return 0
+ fi
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ 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}"
+ exit 1
+esac
+
+exit 0