X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=ext%2Fdebian%2Fmcollective.init;fp=ext%2Fdebian%2Fmcollective.init;h=f599f4a8b5a6010ed0559bcf0de085ac7b82b59e;hb=b87d2f4e68281062df1913440ca5753ae63314a9;hp=0000000000000000000000000000000000000000;hpb=ab0ea530b8ac956091f17b104ab2311336cfc250;p=packages%2Fprecise%2Fmcollective.git diff --git a/ext/debian/mcollective.init b/ext/debian/mcollective.init new file mode 100755 index 0000000..f599f4a --- /dev/null +++ b/ext/debian/mcollective.init @@ -0,0 +1,85 @@ +#!/bin/sh +# +# mcollective Application Server for STOMP based agents +# +# +# description: mcollective lets you build powerful Stomp compatible middleware clients in ruby without having to worry too +# much about all the setup and management of a Stomp connection, it also provides stats, logging and so forth +# as a bonus. +# +### BEGIN INIT INFO +# Provides: mcollective +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start daemon at boot time +# Description: Enable service provided by mcollective. +### END INIT INFO + +# check permissions + +uid=`id -u` +[ $uid -gt 0 ] && { echo "You need to be root to run file" ; exit 4 ; } + + +# PID directory +pidfile="/var/run/mcollectived.pid" + +name="mcollective" +mcollectived=/usr/sbin/mcollectived +daemonopts="--pid=${pidfile} --config=/etc/mcollective/server.cfg" + + +# Source function library. +. /lib/lsb/init-functions + +# Check that binary exists +if ! [ -f $mcollectived ] +then + echo "mcollectived binary not found" + exit 5 +fi + +# create pid file if it does not exist +[ ! -f ${pidfile} ] && { touch ${pidfile} ; } + +# See how we were called. +case "$1" in + start) + echo "Starting daemon: " $name + # start the program + start-stop-daemon -S -p ${pidfile} --oknodo -q -a ${mcollectived} -- ${daemonopts} + [ $? = 0 ] && { exit 0 ; } || { exit 1 ; } + log_success_msg "mcollective started" + touch $lock + ;; + stop) + echo "Stopping daemon: " $name + start-stop-daemon -K -R 5 -s "TERM" --oknodo -q -p ${pidfile} + [ $? = 0 ] && { exit 0 ; } || { exit 1 ; } + log_success_msg "mcollective stopped" + ;; + restart) + echo "Restarting daemon: " $name + $0 stop + sleep 2 + $0 start + [ $? = 0 ] && { echo "mcollective restarted" ; exit 0 ; } + ;; + condrestart) + if [ -f $lock ]; then + $0 stop + # avoid race + sleep 2 + $0 start + fi + ;; + status) + status_of_proc -p ${pidfile} ${mcollectived} ${name} && exit 0 || exit $? + ;; + *) + echo "Usage: mcollectived {start|stop|restart|condrestart|status}" + exit 2 + ;; +esac