Commit d4025dad authored by Constantinos Venetsanopoulos's avatar Constantinos Venetsanopoulos Committed by Constantinos Venetsanopoulos
Browse files

Init script and default file for snf-ganeti-eventd

Add the init script and default file for snf-ganeti-eventd
in snf-ganeti-tools. Also make sure they get installed in
the right directories when the package is installed
parent aaefccf1
#!/bin/sh
ENABLED=true
SNF_USER="root"
#! /bin/sh
### BEGIN INIT INFO
# Provides: snf-ganeti-eventd
# Required-Start: $remote_fs $syslog ganeti
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
# X-Start-After: ganeti
# Short-Description: Synnefo ganeti-eventd daemon
# Description: ganeti-eventd is a daemon
### END INIT INFO
set -e
# /etc/init.d/snf-ganeti-eventd: start and stop the ganeti-eventd daemon
# script skeleton stolen from rsyncd
DAEMON=/usr/sbin/snf-ganeti-eventd
SNF_EVENTD_PID_FILE=/var/run/snf-ganeti-eventd.pid
SNF_EVENTD_DEFAULTS=/etc/default/snf-ganeti-eventd
SNF_EVENTD_OPTS=''
SNF_EVENTD_ENABLE=true
SNF_USER="root"
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
if [ -s $SNF_EVENTD_DEFAULTS_FILE ]; then
. $SNF_EVENTD_DEFAULTS_FILE
fi
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
eventd_start() {
if start-stop-daemon --start --chuid $SNF_USER --pidfile $SNF_EVENTD_PID_FILE \
--exec $DAEMON -- $SNF_EVENTD_OPTS
then
rc=0
sleep 1
if ! kill -0 $(cat $SNF_EVENTD_PID_FILE) >/dev/null 2>&1; then
log_failure_msg "snf-ganeti-eventd daemon failed to start"
rc=1
fi
else
rc=1
fi
if [ $rc -eq 0 ]; then
log_end_msg 0
else
log_end_msg 1
rm -f $SNF_EVENTD_PID_FILE
fi
} # eventd_start
MASTER=`/usr/sbin/gnt-cluster getmaster`
HOST=`/bin/hostname -f`
if [ "x$MASTER" != x$HOST ]] ;
then
log_failure_msg "snf-ganeti-eventd should run on the ganeti master only"
exit 1
fi
case "$1" in
start)
if "$SNF_EVENTD_ENABLE"; then
log_daemon_msg "Starting snf-ganeti-eventd daemon" "snf-ganeti-eventd"
if [ -s $SNF_EVENTD_PID_FILE ] && kill -0 $(cat $SNF_EVENTD_PID_FILE) >/dev/null 2>&1; then
log_progress_msg "apparently already running"
log_end_msg 0
exit 0
fi
eventd_start
else
if [ -s "$SNF_EVENTD_CONFIG_FILE" ]; then
[ "$VERBOSE" != no ] && log_warning_msg "snf-ganeti-eventd daemon not enabled in $SNF_EVENTD_DEFAULTS_FILE, not starting..."
fi
fi
;;
stop)
log_daemon_msg "Stopping snf-ganeti-eventd daemon" "snf-ganeti-eventd"
start-stop-daemon --stop --quiet --oknodo --pidfile $SNF_EVENTD_PID_FILE
log_end_msg $?
rm -f $SNF_EVENTD_PID_FILE
;;
restart)
set +e
if $SNF_EVENTD_ENABLE; then
log_daemon_msg "Restarting snf-ganeti-eventd daemon" "snf-ganeti-eventd"
if [ -s $SNF_EVENTD_PID_FILE ] && kill -0 $(cat $SNF_EVENTD_PID_FILE) >/dev/null 2>&1; then
start-stop-daemon --stop --quiet --oknodo --pidfile $SNF_EVENTD_PID_FILE || true
sleep 1
else
log_warning_msg "snf-ganeti-eventd daemon not running, attempting to start."
rm -f $SNF_EVENTD_PID_FILE
fi
eventd_start
else
if [ -s "$SNF_EVENTD_CONFIG_FILE" ]; then
[ "$VERBOSE" != no ] && log_warning_msg "snf-ganeti-eventd daemon not enabled in $SNF_EVENTD_DEFAULTS_FILE, not starting..."
fi
fi
;;
status)
status_of_proc -p $SNF_EVENTD_PID_FILE "$DAEMON" ganeti-eventd
exit $? # notreached due to set -e
;;
*)
echo "Usage: /etc/init.d/snf-ganeti-eventd {start|stop|restart|status}"
exit 1
esac
exit 0
kvm-vif-bridge /etc/ganeti
conf/default/snf-ganeti-eventd /etc/default
conf/init.d/snf-ganeti-eventd /etc/init.d
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment