Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 127 lines (113 sloc) 2.35 KB
#!/bin/sh
#
# mcprovision Server Provisioner for The Marionette Collective
#
# chkconfig: 345 24 76
#
# description: Automated the provisioning of servers
#
### BEGIN INIT INFO
# Provides: mcprovision
# 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 daemon.
### END INIT INFO
mcprovision="/usr/sbin/mcprovision"
pidfile="/var/run/mcprovision.pid"
# Lockfile
if [ -d /var/lock/subsys ]; then
# RedHat/CentOS/etc who use subsys
lock="/var/lock/subsys/mcprovision"
else
# The rest of them
lock="/var/lock/mcprovision"
fi
# Source function library.
. /etc/init.d/functions
# Load options, set things like PSK's and SSL keys in here
if [ -f /etc/sysconfig/mcprovision ]; then
. /etc/sysconfig/mcprovision
fi
# Check that binary exists
if ! [ -f $mcprovision ]
then
echo "$mcprovision binary not found"
exit 0
fi
# See how we were called.
case "$1" in
start)
echo -n "Starting mcprovision: "
if [ -f ${lock} ]; then
# we were not shut down correctly
if [ -s ${pidfile} ]; then
kill `cat ${pidfile}` >/dev/null 2>&1
fi
rm -f ${pidfile}
rm -f ${lock}
sleep 2
fi
rm -f ${pidfile}
${mcprovision} /etc/mcollective/mcprovision.yaml
if [ $? = 0 ]; then
success $"mcprovision"
touch $lock
echo
exit 0
else
failure
echo
exit 1
fi
;;
stop)
echo -n "Shutting down mcprovision: "
if [ -s ${pidfile} ]; then
kill `cat ${pidfile}` >/dev/null 2>&1
fi
rm -f ${pidfile}
success $"mcprovision"
rm -f $lock
echo
;;
restart)
$0 stop
sleep 2
$0 start
;;
condrestart)
if [ -f $lock ]; then
$0 stop
# avoid race
sleep 2
$0 start
fi
;;
status)
if [ -f ${lock} ]; then
if [ -s ${pidfile} ]; then
if [ -e /proc/`cat ${pidfile}` ]; then
echo "mcprovision (`cat ${pidfile}`) is running"
exit 0
else
echo "mcprovision (`cat ${pidfile}`) is NOT running"
exit 1
fi
fi
else
echo "mcprovision: service not started"
exit 1
fi
;;
force-reload)
echo "not implemented"
;;
*)
echo "Usage: mcprovision {start|stop|restart|condrestart|status}"
exit 1
;;
esac
exit 0