-#! /bin/sh
-### BEGIN INIT INFO
-# Provides: mcollective
-# Required-Start: $network $named $remote_fs $syslog
-# Required-Stop: $network $named $remote_fs $syslog
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: MCollective daemon
-# Description: Marionette Collective daemon - build server
-# orchestration or parallel job execution systems.
-### END INIT INFO
-
-# Author: Jonas Genannt <jonas.genannt@capi2name.de>
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DESC="Marionette Collective daemon"
-NAME=mcollective
-DAEMON=/usr/sbin/mcollectived
-PIDFILE=/var/run/$NAME.pid
-DAEMON_ARGS="--config=/etc/mcollective/server.cfg --pid=$PIDFILE"
-SCRIPTNAME=/etc/init.d/$NAME
-RUN=yes
-
-# Exit if the package is not installed
-[ -x "$DAEMON" ] || exit 0
-
-[ -r /etc/default/$NAME ] && . /etc/default/$NAME
-
-. /lib/init/vars.sh
-
-. /lib/lsb/init-functions
-
-# XXX: cloud-init writes daemonize=0 into the server.conf
-# (https://github.com/stackforge/fuel-web/blob/master/fuel_agent/cloud-init-templates/cloud_config_ubuntu.jinja2#L50)
-# Undo that error here
-# FIXME: remove this hack after fixing the template
-
-conf_fixup()
-{
- local conf=/etc/mcollective/server.cfg
- if grep -q -e 'daemonize\s*=\s*0' $conf; then
- sed -i $conf -re 's/^\s*daemonize\s*=\s*0\s*$/daemonize=1/'
- fi
-}
-
-do_start()
-{
- if [ "$RUN" != "yes" ] ; then
- log_progress_msg "(disabled)"
- log_end_msg 0
-
- exit 0
- fi
- conf_fixup
- start-stop-daemon --start --quiet --pidfile $PIDFILE \
- --startas $DAEMON -- $DAEMON_ARGS \
- || return 2
-}
-
-do_stop()
-{
- if [ -s $PIDFILE ]; then
- kill `cat ${PIDFILE}` >/dev/null 2>&1
- fi
- rm -f $PIDFILE
- return "0"
-}
-
-case "$1" in
- start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
- do_start
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- status)
- status_of_proc -p "${PIDFILE}" "$DAEMON" "$NAME" && exit 0 || exit $?
- ;;
- restart|force-reload)
- log_daemon_msg "Restarting $DESC" "$NAME"
- do_stop
- case "$?" in
- 0|1)
- do_start
- case "$?" in
- 0) log_end_msg 0 ;;
- 1) log_end_msg 1 ;; # Old process is still running
- *) log_end_msg 1 ;; # Failed to start
- esac
- ;;
- *)
- # Failed to stop
- log_end_msg 1
- ;;
- esac
- ;;
- *)
- echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
- exit 3
- ;;
-esac
-
-: