diff --git a/bin/systemV/init.d/alignak b/bin/systemV/init.d/alignak
index a8015a31e..e84d40387 100755
--- a/bin/systemV/init.d/alignak
+++ b/bin/systemV/init.d/alignak
@@ -1,511 +1,38 @@
#!/bin/sh
-
+# Generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
### BEGIN INIT INFO
-# Provides: alignak
-# Required-Start: $network $remote_fs
-# Required-Stop: $network $remote_fs
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: alignak monitoring daemon
-# Description: alignak is a monitoring tool composed of many separated modules:
-# - arbiter : the main one : control everything else.
-# - scheduler : receives checks/actions from arbiter. Schedules & forwards them to pollers.
-# - poller : receives the checks from a scheduler. Launch them and returns results
-# - broker : manage results by looking at scheduler. Like export to flat file or db.
-# - reactionner : manage the failed checks by looking at scheduler.
-# - receiver : manage all passive data
+# Provides: alignak
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start: alignak-broker alignak-poller alignak-reactionner alignak-receiver alignak-scheduler alignak-arbiter
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Alignak daemons instance
### END INIT INFO
+DESC="alignak"
+DAEMON=none
+PIDFILE=none
-### Chkconfig Header
-# Alignak Starts Alignak daemons
-#
-# chkconfig: 345 99 01
-# description: Start Alignak daemons
-
-# Reference:
-# http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
-
-
-NAME="alignak"
-
-AVAIL_MODULES="scheduler poller reactionner broker receiver arbiter"
-
-## ALIGNAK_MODULE_FILE is set by alignak-* if it's one of these that's calling us.
-if [ -z "$ALIGNAK_MODULE_FILE" ]; then
- SCRIPTNAME=$0
- _usage_mods_="[ <$AVAIL_MODULES> ]"
-else
- SCRIPTNAME=$ALIGNAK_MODULE_FILE
-fi
-
-curpath=$(cd $(dirname "$0") && pwd)
-#echo curpath is $curpath filename is $(basename "$0")
-
-
-export LANG=en_US.UTF8
-export LC_ALL=en_US.UTF8
-export PYTHONIOENCODING=utf8
-export PYTHONUNBUFFERED="0"
-export TZ=:/etc/localtime
+MODULES="alignak-broker alignak-poller alignak-reactionner alignak-receiver alignak-scheduler alignak-arbiter"
-# default
-DEBUG=false
-CMD=""
-SUBMODULES=""
-
-# Try relative first (if we have /usr/local for example
-[ -z "$ALIGNAK_DEFAULT_FILE" ] && ALIGNAK_DEFAULT_FILE="${curpath}/../default/$NAME"
-[ ! -f "$ALIGNAK_DEFAULT_FILE" ] && ALIGNAK_DEFAULT_FILE="/etc/default/$NAME"
-
-
-
-usage() {
- cat << END
-Usage: $SCRIPTNAME [ -d ] {start|stop|status|restart|reload|force-reload|check} $_usage_mods_
-
- -d start requested module(s) in debug mode, only useful with start|restart
-
-END
-}
-
-if [ "$1" = "-d" ]; then
- DEBUG="1"
- shift
-fi
-
-if [ $# -eq 0 ]; then
- usage >&2
- exit 2
-fi
-
-CMD=$1
-shift
-SUBMODULES=$*
-
-# Reads configuration variable file if it is present
-[ -r "$ALIGNAK_DEFAULT_FILE" ] && . "$ALIGNAK_DEFAULT_FILE"
-
-if [ -z "$SUBMODULES" ]; then
- SUBMODULES=$AVAIL_MODULES
-else
- # check given modules
- for mod1 in $SUBMODULES; do
- found=0
- for mod2 in $AVAIL_MODULES; do
- [ $mod1 = $mod2 ] && found=1;
- done
- [ $found = 0 ] && { usage >&2 ; exit 2 ; }
+do_start_cmd_override() {
+ for svc in $MODULES ; do
+ service $svc start
done
-fi
-
-# Now look if some required variables are pre defined:
-if [ -z "$ALIGNAKCFG" ]; then
- ALIGNAKCFG="$ETC/alignak.cfg"
-fi
-echo "Alignak main configuration file is: $ALIGNAKCFG"
-
-# If log or pi directories dir are missing, create them and chown them
-[ ! -d $VAR ] && mkdir -p $VAR && chown -R $ALIGNAK_USER:$ALIGNAK_GROUP /usr/local/var/log/alignak/monitoring-log
-[ ! -d $RUN ] && mkdir -p $RUN && chown -R $ALIGNAK_USER:$ALIGNAK_GROUP /usr/local/var/run/alignak
-
-# In case not existing, define here
-log_failure_msg() {
- echo $*
- return 1
-}
-
-log_warning_msg() {
- echo $*
- return 1
-}
-
-log_end_msg() {
- code=$1
- shift
- echo $*
- return $code
-}
-
-# Load the VERBOSE setting and other rcS variables
-[ -f /etc/default/rcS ] && . /etc/default/rcS
-
-# Source function library.
-[ -f /etc/rc.d/init.d/functions ] && . /etc/rc.d/init.d/functions
-
-[ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions
-
-echo_success() {
- log_end_msg 0 $*
-}
-
-echo_failure() {
- log_end_msg 1 $*
-}
-
-################################################
-
-#
-# returns the pid for a submodule
-#
-
-getpidfile() {
- mod="$1"
- modPIDVAR=$(echo $mod | tr 'a-z' 'A-Z')"PID"
- pidfile=$(echo $(eval echo \${$modPIDVAR}))
- if test "$pidfile"
- then
- echo "$pidfile"
- else
- echo "$RUN/${mod}d.pid"
- fi
-}
-
-getmodpid() {
- mod=$1
- pidfile=$(getpidfile "$mod")
- if [ -s $pidfile ]; then
- cat $pidfile
- fi
-}
-
-
-getdebugfile() {
- mod="$1"
- modDEBUG=$(echo $mod | tr 'a-z' 'A-Z')"DEBUGFILE"
- debugfile=$(echo $(eval echo \${$modDEBUG}))
- if test "$debugfile"
- then
- echo "$debugfile"
- else
- echo "${VAR}/${mod}-debug.log"
- fi
-}
-
-#
-# Display status
-#
-do_status() {
- mod=$1
- pidfile=$(getpidfile "$mod")
- [ -e "$pidfile" ] || {
- echo "$mod NOT RUNNING (pidfile ($pidfile) not exist)"
- return 3
- }
- [ -r "$pidfile" ] || {
- echo "$mod NOT RUNNING (pidfile ($pidfile) unreadable)"
- return 3
- }
- pid=$(cat "$pidfile")
- if [ -z "$pid" ]; then
- echo "$mod NOT RUNNING (pid file empty)"
- return 4
- fi
- ps -p "$pid" >/dev/null 2>&1
- rc=$?
- if [ $rc != 0 ]; then
- log_failure_msg "$mod NOT RUNNING (process $pid doesn't exist?)"
- return 1
- fi
- echo "$mod RUNNING (pid $pid)"
- return 0
-}
-
-#
-# starts our modules
-#
-do_start() {
- mod=$1
- modfilepath="$BIN/alignak-${mod}"
- [ -e "$modfilepath" ] || {
- log_failure_msg "FAILED: did not find $mod file ($modfilepath) ; are you sure alignak-$mod is installed?"
- return 5
- }
- [ "$DEBUG" = 1 ] && DEBUGCMD="--debug "$(getdebugfile "$mod")
- # Arbiter alignak.cfg, and the other OTHERd.ini
- modINI=$(echo "$"${mod}CFG | tr '[:lower:]' '[:upper:]')
- modinifile=$(eval echo ${modINI})
- if [ "$mod" != "arbiter" ]; then
- output=$($modfilepath -d -e "${modinifile}" $DEBUGCMD 2>&1)
- rc=$?
- else
- if [ -z "$ALIGNAKSPECIFICCFG" ]; then
- output=$($modfilepath -d -e "${modinifile}" -a "$ALIGNAKCFG" $DEBUGCMD 2>&1)
- else
- output=$($modfilepath -d -e "${modinifile}" -a "$ALIGNAKCFG" $DEBUGCMD 2>&1)
- fi
- rc=$?
- fi
- # debug:
- #resfile="/tmp/bad_start_for_$mod"
- #echo "$output" > "$resfile" || true
- if [ $rc != 0 ]; then
- resfile="/tmp/bad_start_for_$mod"
- echo "$output" > "$resfile" || true
- output=$(echo "$output" | tail -1)
- echo "FAILED: $output (full output is in $resfile)"
- return 1
- fi
- echo "OK"
- return 0
+ return 0;
}
-#
-# stops modules
-#
-do_stop() {
- mod=$1
- pid=$(getmodpid "$mod")
- statusoutput=$(do_status "$mod")
- [ $? -ne 0 ] && {
- echo "$statusoutput"
- return 0
- }
- if [ ! -z "$pid" ]; then
- kill "$pid"
- #sleep 1
- ## TODO: instead of 'sleep 1': wait up to when pid file is removed (with timeout)?
- for i in 1 2 3
- do
- # TODO: use a better way to get the children pids..
- allpids="$(ps -aef | grep "$pid" | grep "alignak-$mod" | awk '{print $2}')"
- if [ -z "$allpids" ]; then
- echo "OK"
- return 0
- fi
- sleep 1
- done
- echo "there are still remaining processes to $mod running.. ; trying to kill them (SIGTERM).."
- allpids="$(ps -aef | grep "$pid" | grep "alignak-$mod" | awk '{print $2}')"
- for cpid in $(ps -aef | grep "$pid" | grep "alignak-$mod" | awk '{print $2}'); do
- kill $cpid > /dev/null 2>&1
- done
- for i in 1 2 3
- do
- # TODO: eventually use a better way to get the children pids..
- allpids="$(ps -aef | grep "$pid" | grep "alignak-$mod" | awk '{print $2}')"
- if [ -z "$allpids" ]; then
- echo "OK"
- return 0
- fi
- sleep 1
- done
- echo "there are still remaining processes to $mod running.. ; trying to kill -9 them.."
- allpids="$(ps -aef | grep "$pid" | grep "alignak-$mod" | awk '{print $2}')"
- for cpid in $(ps -aef | grep "$pid" | grep "alignak-$mod" | awk '{print $2}'); do
- kill -9 $cpid > /dev/null 2>&1
- done
- sleep 1
- allpids="$(ps -aef | grep "$pid" | grep "alignak-$mod" | awk '{print $2}')"
- if [ ! -z "$allpids" ]; then
- echo "FAILED: one or more process for $mod are still running after kill -9!"
- echo "Remaining processes are (pids="$allpids"):"
- ps -lf $(for p in $allpids ; do echo -n "-p$p " ; done)
- echo "You should check this."
- return 1
- fi
- echo "OK"
- else
- echo "NOT RUNNING"
- fi
- return 0
-}
-
-#
-# does the config check
-#
-do_check() {
- echo "Checking configuration..."
- [ "$DEBUG" = 1 ] && DEBUGCMD="--debug $VAR/${mod}-debug.log"
-
- modINI=$(echo "$"${mod}CFG | tr '[:lower:]' '[:upper:]')
- modinifile=$(eval echo ${modINI})
-
- if [ -z "$ALIGNAKSPECIFICCFG" ]; then
- $BIN/alignak-arbiter -V -c "${modinifile}" -a "$ALIGNAKCFG" $DEBUGCMD 2>&1
- else
- $BIN/alignak-arbiter -V -c "${modinifile}" -a "$ALIGNAKCFG" -a "$ALIGNAKSPECIFICCFG" $DEBUGCMD 2>&1
- fi
- rc=$?
- if [ $rc -eq 0 ]; then
- echo_success
- else
- echo "$startoutput"
- echo_failure
- fi
- return $?
-}
-
-
-############################
-
-do_start_() {
- echo "Starting $1: "
- status=$(do_status "$1")
- rc=$?
- if [ $rc -eq 0 ]; then
- log_warning_msg "Already running"
- return
- fi
- startoutput=$(do_start "$1")
- rc=$?
- if [ $rc -eq 0 ]; then
- echo_success
- else
- echo "$startoutput"
- echo_failure
- fi
- return $rc
-}
-
-do_stop_() {
- echo "Stopping $1"
- statusoutput=$(do_status "$1")
- rc=$?
- if [ $rc -ne 0 ]; then
- failuremsg="Couldn't get status of $1: $statusoutput"
- else
- stopoutput=$(do_stop "$1" 2>&1)
- rc=$?
- [ $rc -ne 0 ] && failuremsg="Couldn't stop $1: $stopoutput"
- fi
- if [ $rc -ne 0 ]; then
- log_failure_msg "$failuremsg"
- echo_failure
- else
- echo_success
- fi
- return $rc
-}
-
-do_restart_() {
- mod="$1"
- if [ "$mod" = "arbiter" ]; then
- do_check_ "$mod"
- checkrc=$?
- if [ $checkrc -ne 0 ]; then
- return 1
- fi
- fi
- echo "Restarting $mod"
- stopoutput=$(do_stop "$mod")
- startoutput=$(do_start "$mod")
- rc=$?
- if [ $rc -eq 0 ]; then
- echo_success
- else
- log_failure_msg "$startoutput"
- echo_failure
- fi
- return $rc
-}
-
-do_force_reload_() {
- do_restart_ $1
-}
-
-do_reload_() {
- mod="$1"
- if [ "$mod" = "arbiter" ]; then
- do_status_ $mod
- checkrc=$?
- if [ $checkrc -ne 0 ]; then
- echo "Cannot request reload if process is not running."
- return 1
- fi
- do_check_ "$mod"
- checkrc=$?
- if [ $checkrc -ne 0 ]; then
- return 1
- fi
- pid=$(getmodpid "$mod")
- if [ "$pid" != "" ]; then
- # send SIGHUP signal to reload configuration
- kill -1 $pid
- rc=$?
- fi
- else
- # if not the arbiter module, reload == restart
- do_restart_ $mod
- fi
- echo "Reloading $mod"
- if [ $rc -eq 0 ]; then
- echo_success
- else
- echo_failure
- fi
- return $rc
-}
-
-do_status_() {
- mod=$1
- echo "Checking status of $mod"
- do_status "$1"
- rc=$?
- if [ $rc -eq 0 ]; then
- echo_success
- else
- echo_failure
- fi
-
-}
-
-do_check_() {
- echo "Doing config check"
- output=$(do_check "$1" 2>&1)
- rc=$?
- check_res_file=$(mktemp /tmp/alignak_checkconfig_resultXXXXXXXX)
- echo "$output" > "$check_res_file"
- mv $check_res_file /tmp/alignak_checkconfig_result
- check_res_file="/tmp/alignak_checkconfig_result"
-
- if [ $rc -eq 0 ]; then
- echo_success
- else
- output=$(echo "$output" | tail -1)
- log_warning_msg "full result is in ${check_res_file}"
- log_failure_msg "ConfigCheck failed: $output"
- echo_failure
- fi
- return $rc
-}
-do_checkconfig_() { do_check_ "$1" ; }
-
-
-############################
-
-do_cmd_on() {
- action=$1
- mods=$2
-
- local return_value
- return_value=0
-
- for mod in $mods
- do
- # If at least one action fails, the return value is 1.
- do_${action}_ "$mod" || return_value=1
+do_stop_override() {
+ REVERSE_MODULES=$(echo $MODULES | tr ' ' '\n' | tac |tr '\n' ' ')
+ for svc in $REVERSE_MODULES ; do
+ service $svc stop
done
-
- return $return_value
+ return 0;
}
-
-############################
-## Main:
-
-case "$CMD" in
- start|stop|restart|status|force-reload)
- do_cmd_on "$CMD" "$SUBMODULES"
- ;;
- force-reload)
- do_cmd_on "force_reload" "$SUBMODULES"
- ;;
- check|checkconfig|reload)
- do_cmd_on "$CMD" "arbiter"
- ;;
- *)
- usage >&2
- exit 2
- ;;
-esac
-
+# TODO
+do_status_override () :
diff --git a/bin/systemV/init.d/alignak-arbiter b/bin/systemV/init.d/alignak-arbiter
index ef85e8c2f..4497e62a0 100755
--- a/bin/systemV/init.d/alignak-arbiter
+++ b/bin/systemV/init.d/alignak-arbiter
@@ -1,83 +1,59 @@
#!/bin/sh
-#
-# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
-#
-# This file is part of Alignak.
-#
-# Alignak is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Alignak is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Alignak. If not, see .
-#
-#
-# This file incorporates work covered by the following copyright and
-# permission notice:
-#
-# Copyright (C) 2009-2014:
-# Gabes Jean, naparuba@gmail.com
-# Gerhard Lausser, Gerhard.Lausser@consol.de
-# Gregory Starck, g.starck@gmail.com
-# Hartmut Goebel, h.goebel@goebel-consult.de
-#
-# This file is part of Shinken.
-#
-# Shinken is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Shinken is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Shinken. If not, see .
-
+# Initially generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
### BEGIN INIT INFO
-# Provides: alignak-arbiter
-# Required-Start: $all
-# Required-Stop: $all
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Alignak arbiter daemon
-# Description: Alignak is a monitoring tool and the Arbiter
-# is one of its daemon. This one reads the configuration,
-# cuts it into parts and dispatches it. Then it waits
-# for orders from the users to dispatch them too.
+# Provides: alignak-arbiter
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Alignak arbiter daemon instance
### END INIT INFO
-### Chkconfig Header
-# Alignak Starts Alignak Arbiter
-#
-# chkconfig: 345 99 01
-# description: Start Alignak arbiter daemon
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+set -a
+ALIGNAK_CONFIGURATION_FILE=/usr/local/share/alignak/etc/alignak.ini
+ALIGNAK_USER=alignak
+ALIGNAK_GROUP=alignak
+[ -r /etc/default/alignak ] && . /etc/default/alignak
+
+# Alignak debs get installed inside "site-packages", but Debian's Python doesn't include it inside sys.path
+# So let's find out which Python Alignak is going to use
+PYTHONVER=$( /usr/bin/env python -V 2>&1 | cut -d' ' -f 2 | cut -d. -f 1,2 )
+PYTHONPATH=/usr/local/lib/python$PYTHONVER/site-packages
+set +a
+
+NAME=arbiter-master
+DESC=alignak-arbiter
+DAEMON=/usr/local/bin/alignak-arbiter
+PIDFILE=/var/run/alignak/arbiter-master.pid
+LOGFILE=/var/log/alignak/arbiter-master.log
+DAEMON_ARGS="-d -n ${NAME} -e "${ALIGNAK_CONFIGURATION_FILE}" -i ${PIDFILE} -l ${LOGFILE}"
-# Author: Gabes Jean
-# Olivier LI-KIANG-CHEONG
+do_start_cmd_override() {
+ /bin/mkdir -p /var/log/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/log/alignak || return 2
+ /bin/chmod 775 /var/log/alignak || return 2
+ /bin/mkdir -p /var/run/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/run/alignak || return 2
+ /bin/chmod 775 /var/run/alignak || return 2
+ do_start_cmd || return $?
+}
-SHORTNAME=arbiter
-NAME="alignak-$SHORTNAME"
-SCRIPT=$(readlink -f "$0")
-curdir=$(dirname "$SCRIPT")
+do_status_override() {
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && return 0 || return $?
+}
-export ALIGNAK_MODULE_FILE="$NAME" ## for 'alignak' init script to see that it's called by us
+do_stop_cmd_override() {
+ start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER" || return 2
+}
-case "$1" in
- start|stop|reload|restart|force-reload|status|check|checkconfig)
- "$curdir/alignak" $@ "$SHORTNAME"
- exit $?
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME [-d] {start|stop|reload|restart|force-reload|status|check}"
- exit 1
- ;;
-esac
+do_reload() {
+ log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+ start-stop-daemon --stop --signal HUP --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER"
+ log_end_msg $?
+}
diff --git a/bin/systemV/init.d/alignak-broker b/bin/systemV/init.d/alignak-broker
index 5aff95e99..2fd5b739c 100755
--- a/bin/systemV/init.d/alignak-broker
+++ b/bin/systemV/init.d/alignak-broker
@@ -1,83 +1,59 @@
#!/bin/sh
-#
-# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
-#
-# This file is part of Alignak.
-#
-# Alignak is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Alignak is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Alignak. If not, see .
-#
-#
-# This file incorporates work covered by the following copyright and
-# permission notice:
-#
-# Copyright (C) 2009-2014:
-# Gabes Jean, naparuba@gmail.com
-# Gerhard Lausser, Gerhard.Lausser@consol.de
-# Gregory Starck, g.starck@gmail.com
-# Hartmut Goebel, h.goebel@goebel-consult.de
-#
-# This file is part of Shinken.
-#
-# Shinken is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Shinken is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Shinken. If not, see .
-
+# Initially generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
### BEGIN INIT INFO
-# Provides: alignak-broker
-# Required-Start: $all
-# Required-Stop: $all
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Alignak broker daemon
-# Description: Alignak is a monitoring tool and the Broker
-# is one of its daemon. This one gets the configuration from the arbiter
-# His purpose is to get the broks from the schedulers specified in the
-# configuration
+# Provides: alignak-broker
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Alignak broker daemon instance
### END INIT INFO
-### Chkconfig Header
-# Alignak Starts Alignak Broker
-#
-# chkconfig: 345 99 01
-# description: Start Alignak broker daemon
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+set -a
+ALIGNAK_CONFIGURATION_FILE=/usr/local/share/alignak/etc/alignak.ini
+ALIGNAK_USER=alignak
+ALIGNAK_GROUP=alignak
+[ -r /etc/default/alignak ] && . /etc/default/alignak
+
+# Alignak debs get installed inside "site-packages", but Debian's Python doesn't include it inside sys.path
+# So let's find out which Python Alignak is going to use
+PYTHONVER=$( /usr/bin/env python -V 2>&1 | cut -d' ' -f 2 | cut -d. -f 1,2 )
+PYTHONPATH=/usr/local/lib/python$PYTHONVER/site-packages
+set +a
+
+NAME=broker-master
+DESC=alignak-broker
+DAEMON=/usr/local/bin/alignak-broker
+PIDFILE=/var/run/alignak/broker-master.pid
+LOGFILE=/var/log/alignak/broker-master.log
+DAEMON_ARGS="-d -n ${NAME} -e "${ALIGNAK_CONFIGURATION_FILE}" -i ${PIDFILE} -l ${LOGFILE}"
-# Author: Gabes Jean
-# Olivier LI-KIANG-CHEONG
+do_start_cmd_override() {
+ /bin/mkdir -p /var/log/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/log/alignak || return 2
+ /bin/chmod 775 /var/log/alignak || return 2
+ /bin/mkdir -p /var/run/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/run/alignak || return 2
+ /bin/chmod 775 /var/run/alignak || return 2
+ do_start_cmd || return $?
+}
-SHORTNAME=broker
-NAME="alignak-$SHORTNAME"
-SCRIPT=$(readlink -f "$0")
-curdir=$(dirname "$SCRIPT")
+do_status_override() {
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && return 0 || return $?
+}
-export ALIGNAK_MODULE_FILE="$NAME" ## for 'alignak' init script to see that it's called by us
+do_stop_cmd_override() {
+ start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER" || return 2
+}
-case "$1" in
- start|stop|reload|restart|force-reload|status|check|checkconfig)
- "$curdir/alignak" $@ "$SHORTNAME"
- exit $?
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME [-d] {start|stop|reload|restart|force-reload|status|check}"
- exit 1
- ;;
-esac
+do_reload() {
+ log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+ start-stop-daemon --stop --signal HUP --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER"
+ log_end_msg $?
+}
diff --git a/bin/systemV/init.d/alignak-poller b/bin/systemV/init.d/alignak-poller
index 1d614cb39..5040a90c6 100755
--- a/bin/systemV/init.d/alignak-poller
+++ b/bin/systemV/init.d/alignak-poller
@@ -1,84 +1,59 @@
#!/bin/sh
-#
-# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
-#
-# This file is part of Alignak.
-#
-# Alignak is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Alignak is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Alignak. If not, see .
-#
-#
-# This file incorporates work covered by the following copyright and
-# permission notice:
-#
-# Copyright (C) 2009-2014:
-# Gabes Jean, naparuba@gmail.com
-# Gerhard Lausser, Gerhard.Lausser@consol.de
-# Gregory Starck, g.starck@gmail.com
-# Hartmut Goebel, h.goebel@goebel-consult.de
-#
-# This file is part of Shinken.
-#
-# Shinken is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Shinken is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Shinken. If not, see .
-
+# Initially generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
### BEGIN INIT INFO
-# Provides: alignak-poller
-# Required-Start: $all
-# Required-Stop: $all
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Alignak poller daemon
-# Description: Alignak is a monitoring tool and the Poller
-# is one of its daemon. This one gets the configuration from the arbiter
-# His purpose is to actually do the checks ordered by the schedulers,
-# and then sends the results to the schedulers specified in the
-# configuration
+# Provides: alignak-poller
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Alignak poller daemon instance
### END INIT INFO
-### Chkconfig Header
-# Alignak Starts Alignak Poller
-#
-# chkconfig: 345 99 01
-# description: Start Alignak poller daemon
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+set -a
+ALIGNAK_CONFIGURATION_FILE=/usr/local/share/alignak/etc/alignak.ini
+ALIGNAK_USER=alignak
+ALIGNAK_GROUP=alignak
+[ -r /etc/default/alignak ] && . /etc/default/alignak
+
+# Alignak debs get installed inside "site-packages", but Debian's Python doesn't include it inside sys.path
+# So let's find out which Python Alignak is going to use
+PYTHONVER=$( /usr/bin/env python -V 2>&1 | cut -d' ' -f 2 | cut -d. -f 1,2 )
+PYTHONPATH=/usr/local/lib/python$PYTHONVER/site-packages
+set +a
+
+NAME=poller-master
+DESC=alignak-poller
+DAEMON=/usr/local/bin/alignak-poller
+PIDFILE=/var/run/alignak/poller-master.pid
+LOGFILE=/var/log/alignak/poller-master.log
+DAEMON_ARGS="-d -n ${NAME} -e "${ALIGNAK_CONFIGURATION_FILE}" -i ${PIDFILE} -l ${LOGFILE}"
-# Author: Gabes Jean
-# Olivier LI-KIANG-CHEONG
+do_start_cmd_override() {
+ /bin/mkdir -p /var/log/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/log/alignak || return 2
+ /bin/chmod 775 /var/log/alignak || return 2
+ /bin/mkdir -p /var/run/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/run/alignak || return 2
+ /bin/chmod 775 /var/run/alignak || return 2
+ do_start_cmd || return $?
+}
-SHORTNAME=poller
-NAME="alignak-$SHORTNAME"
-SCRIPT=$(readlink -f "$0")
-curdir=$(dirname "$SCRIPT")
+do_status_override() {
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && return 0 || return $?
+}
-export ALIGNAK_MODULE_FILE="$NAME" ## for 'alignak' init script to see that it's called by us
+do_stop_cmd_override() {
+ start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER" || return 2
+}
-case "$1" in
- start|stop|reload|restart|force-reload|status|check|checkconfig)
- "$curdir/alignak" $@ "$SHORTNAME"
- exit $?
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME [-d] {start|stop|reload|restart|force-reload|status|check}"
- exit 1
- ;;
-esac
+do_reload() {
+ log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+ start-stop-daemon --stop --signal HUP --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER"
+ log_end_msg $?
+}
diff --git a/bin/systemV/init.d/alignak-reactionner b/bin/systemV/init.d/alignak-reactionner
index 39fc3d9ec..6d5236c30 100755
--- a/bin/systemV/init.d/alignak-reactionner
+++ b/bin/systemV/init.d/alignak-reactionner
@@ -1,83 +1,59 @@
#!/bin/sh
-#
-# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
-#
-# This file is part of Alignak.
-#
-# Alignak is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Alignak is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Alignak. If not, see .
-#
-#
-# This file incorporates work covered by the following copyright and
-# permission notice:
-#
-# Copyright (C) 2009-2014:
-# Gabes Jean, naparuba@gmail.com
-# Gerhard Lausser, Gerhard.Lausser@consol.de
-# Gregory Starck, g.starck@gmail.com
-# Hartmut Goebel, h.goebel@goebel-consult.de
-#
-# This file is part of Shinken.
-#
-# Shinken is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Shinken is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Shinken. If not, see .
-
+# Initially generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
### BEGIN INIT INFO
-# Provides: alignak-reactionner
-# Required-Start: $all
-# Required-Stop: $all
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Alignak reactionner daemon
-# Description: Alignak is a monitoring tool and the Reactionner
-# is one of its daemon. This one gets the configuration from the arbiter
-# His purpose is to get the actually do the actions like sending an email
-# ordered by the schedulers specified in the configuration
+# Provides: alignak-reactionner
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Alignak reactionner daemon instance
### END INIT INFO
-### Chkconfig Header
-# Alignak Starts Alignak Reactionner
-#
-# chkconfig: 345 99 01
-# description: Start Alignak reactionner daemon
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+set -a
+ALIGNAK_CONFIGURATION_FILE=/usr/local/share/alignak/etc/alignak.ini
+ALIGNAK_USER=alignak
+ALIGNAK_GROUP=alignak
+[ -r /etc/default/alignak ] && . /etc/default/alignak
+
+# Alignak debs get installed inside "site-packages", but Debian's Python doesn't include it inside sys.path
+# So let's find out which Python Alignak is going to use
+PYTHONVER=$( /usr/bin/env python -V 2>&1 | cut -d' ' -f 2 | cut -d. -f 1,2 )
+PYTHONPATH=/usr/local/lib/python$PYTHONVER/site-packages
+set +a
+
+NAME=reaction-master
+DESC=alignak-reactionner
+DAEMON=/usr/local/bin/alignak-reactionner
+PIDFILE=/var/run/alignak/reaction-master.pid
+LOGFILE=/var/log/alignak/reaction-master.log
+DAEMON_ARGS="-d -n ${NAME} -e "${ALIGNAK_CONFIGURATION_FILE}" -i ${PIDFILE} -l ${LOGFILE}"
-# Author: Gabes Jean
-# Olivier LI-KIANG-CHEONG
+do_start_cmd_override() {
+ /bin/mkdir -p /var/log/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/log/alignak || return 2
+ /bin/chmod 775 /var/log/alignak || return 2
+ /bin/mkdir -p /var/run/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/run/alignak || return 2
+ /bin/chmod 775 /var/run/alignak || return 2
+ do_start_cmd || return $?
+}
-SHORTNAME=reactionner
-NAME="alignak-$SHORTNAME"
-SCRIPT=$(readlink -f "$0")
-curdir=$(dirname "$SCRIPT")
+do_status_override() {
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && return 0 || return $?
+}
-export ALIGNAK_MODULE_FILE="$NAME" ## for 'alignak' init script to see that it's called by us
+do_stop_cmd_override() {
+ start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER" || return 2
+}
-case "$1" in
- start|stop|reload|restart|force-reload|status|check|checkconfig)
- "$curdir/alignak" $@ "$SHORTNAME"
- exit $?
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME [-d] {start|stop|reload|restart|force-reload|status|check}"
- exit 1
- ;;
-esac
+do_reload() {
+ log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+ start-stop-daemon --stop --signal HUP --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER"
+ log_end_msg $?
+}
diff --git a/bin/systemV/init.d/alignak-receiver b/bin/systemV/init.d/alignak-receiver
index 1a5eaae5a..100313d1e 100755
--- a/bin/systemV/init.d/alignak-receiver
+++ b/bin/systemV/init.d/alignak-receiver
@@ -1,83 +1,59 @@
#!/bin/sh
-#
-# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
-#
-# This file is part of Alignak.
-#
-# Alignak is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Alignak is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Alignak. If not, see .
-#
-#
-# This file incorporates work covered by the following copyright and
-# permission notice:
-#
-# Copyright (C) 2009-2014:
-# Gabes Jean, naparuba@gmail.com
-# Gerhard Lausser, Gerhard.Lausser@consol.de
-# Gregory Starck, g.starck@gmail.com
-# Hartmut Goebel, h.goebel@goebel-consult.de
-#
-# This file is part of Shinken.
-#
-# Shinken is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Shinken is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Shinken. If not, see .
-
+# Initially generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
### BEGIN INIT INFO
-# Provides: alignak-receiver
-# Required-Start: $all
-# Required-Stop: $all
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Alignak receiver daemon
-# Description: Alignak is a monitoring tool and the Receiver
-# is one of its daemon. This one gets the configuration from the arbiter
-# His purpose is to get the broks from the schedulers specified in the
-# configuration
+# Provides: alignak-receiver
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Alignak receiver daemon instance
### END INIT INFO
-### Chkconfig Header
-# Alignak Starts Alignak Receiver
-#
-# chkconfig: 345 99 01
-# description: Start Alignak receiver daemon
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+set -a
+ALIGNAK_CONFIGURATION_FILE=/usr/local/share/alignak/etc/alignak.ini
+ALIGNAK_USER=alignak
+ALIGNAK_GROUP=alignak
+[ -r /etc/default/alignak ] && . /etc/default/alignak
+
+# Alignak debs get installed inside "site-packages", but Debian's Python doesn't include it inside sys.path
+# So let's find out which Python Alignak is going to use
+PYTHONVER=$( /usr/bin/env python -V 2>&1 | cut -d' ' -f 2 | cut -d. -f 1,2 )
+PYTHONPATH=/usr/local/lib/python$PYTHONVER/site-packages
+set +a
+
+NAME=receiver-master
+DESC=alignak-receiver
+DAEMON=/usr/local/bin/alignak-receiver
+PIDFILE=/var/run/alignak/receiver-master.pid
+LOGFILE=/var/log/alignak/receiver-master.log
+DAEMON_ARGS="-d -n ${NAME} -e "${ALIGNAK_CONFIGURATION_FILE}" -i ${PIDFILE} -l ${LOGFILE}"
-# Author: Gabes Jean
-# Olivier LI-KIANG-CHEONG
+do_start_cmd_override() {
+ /bin/mkdir -p /var/log/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/log/alignak || return 2
+ /bin/chmod 775 /var/log/alignak || return 2
+ /bin/mkdir -p /var/run/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/run/alignak || return 2
+ /bin/chmod 775 /var/run/alignak || return 2
+ do_start_cmd || return $?
+}
-SHORTNAME=receiver
-NAME="alignak-$SHORTNAME"
-SCRIPT=$(readlink -f "$0")
-curdir=$(dirname "$SCRIPT")
+do_status_override() {
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && return 0 || return $?
+}
-export ALIGNAK_MODULE_FILE="$NAME" ## for 'alignak' init script to see that it's called by us
+do_stop_cmd_override() {
+ start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER" || return 2
+}
-case "$1" in
- start|stop|reload|restart|force-reload|status|check|checkconfig)
- "$curdir/alignak" $@ "$SHORTNAME"
- exit $?
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME [-d] {start|stop|reload|restart|force-reload|status|check}"
- exit 1
- ;;
-esac
+do_reload() {
+ log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+ start-stop-daemon --stop --signal HUP --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER"
+ log_end_msg $?
+}
diff --git a/bin/systemV/init.d/alignak-scheduler b/bin/systemV/init.d/alignak-scheduler
index 798e23fa0..da87a7bab 100755
--- a/bin/systemV/init.d/alignak-scheduler
+++ b/bin/systemV/init.d/alignak-scheduler
@@ -1,83 +1,59 @@
#!/bin/sh
-#
-# Copyright (C) 2015-2016: Alignak team, see AUTHORS.txt file for contributors
-#
-# This file is part of Alignak.
-#
-# Alignak is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Alignak is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Alignak. If not, see .
-#
-#
-# This file incorporates work covered by the following copyright and
-# permission notice:
-#
-# Copyright (C) 2009-2014:
-# Gabes Jean, naparuba@gmail.com
-# Gerhard Lausser, Gerhard.Lausser@consol.de
-# Gregory Starck, g.starck@gmail.com
-# Hartmut Goebel, h.goebel@goebel-consult.de
-#
-# This file is part of Shinken.
-#
-# Shinken is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Shinken is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Shinken. If not, see .
-
+# Initially generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
### BEGIN INIT INFO
-# Provides: alignak-scheduler
-# Required-Start: $all
-# Required-Stop: $all
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Alignak scheduler daemon
-# Description: Alignak is a monitoring tool and the Scheduler
-# is one of its daemon. This one get configuration from the arbiter
-# His purpose is only to schedule do the checks and actions specified
-# in the configuration received from the arbiter
+# Provides: alignak-scheduler
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Alignak scheduler daemon instance
### END INIT INFO
-### Chkconfig Header
-# Alignak Starts Alignak Scheduler
-#
-# chkconfig: 345 99 01
-# description: Start Alignak scheduler daemon
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+set -a
+ALIGNAK_CONFIGURATION_FILE=/usr/local/share/alignak/etc/alignak.ini
+ALIGNAK_USER=alignak
+ALIGNAK_GROUP=alignak
+[ -r /etc/default/alignak ] && . /etc/default/alignak
+
+# Alignak debs get installed inside "site-packages", but Debian's Python doesn't include it inside sys.path
+# So let's find out which Python Alignak is going to use
+PYTHONVER=$( /usr/bin/env python -V 2>&1 | cut -d' ' -f 2 | cut -d. -f 1,2 )
+PYTHONPATH=/usr/local/lib/python$PYTHONVER/site-packages
+set +a
+
+NAME=schedule-master
+DESC=alignak-scheduler
+DAEMON=/usr/local/bin/alignak-scheduler
+PIDFILE=/var/run/alignak/schedule-master.pid
+LOGFILE=/var/log/alignak/schedule-master.log
+DAEMON_ARGS="-d -n ${NAME} -e "${ALIGNAK_CONFIGURATION_FILE}" -i ${PIDFILE} -l ${LOGFILE}"
-# Author: Gabes Jean
-# Olivier LI-KIANG-CHEONG
+do_start_cmd_override() {
+ /bin/mkdir -p /var/log/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/log/alignak || return 2
+ /bin/chmod 775 /var/log/alignak || return 2
+ /bin/mkdir -p /var/run/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/run/alignak || return 2
+ /bin/chmod 775 /var/run/alignak || return 2
+ do_start_cmd || return $?
+}
-SHORTNAME=scheduler
-NAME="alignak-$SHORTNAME"
-SCRIPT=$(readlink -f "$0")
-curdir=$(dirname "$SCRIPT")
+do_status_override() {
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && return 0 || return $?
+}
-export ALIGNAK_MODULE_FILE="$NAME" ## for 'alignak' init script to see that it's called by us
+do_stop_cmd_override() {
+ start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER" || return 2
+}
-case "$1" in
- start|stop|reload|restart|force-reload|status|check|checkconfig)
- "$curdir/alignak" $@ "$SHORTNAME"
- exit $?
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME [-d] {start|stop|reload|restart|force-reload|status|check}"
- exit 1
- ;;
-esac
+do_reload() {
+ log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+ start-stop-daemon --stop --signal HUP --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER"
+ log_end_msg $?
+}
diff --git a/bin/systemV/init.d/alignak-webui b/bin/systemV/init.d/alignak-webui
new file mode 100755
index 000000000..d02c92e81
--- /dev/null
+++ b/bin/systemV/init.d/alignak-webui
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+### BEGIN INIT INFO
+# Provides: alignak-webui
+# Required-Start: $remote_fs
+# Required-Stop: $remote_fs
+# Should-Start: $network
+# Should-Stop: $network
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: uWSGI instance to serve Alignak WebUI
+### END INIT INFO
+set -a
+ALIGNAK_WEBUI_CONFIGURATION_FILE=/usr/local/share/alignak-webui/etc/settings.cfg
+ALIGNAK_WEBUI_BACKEND=http://127.0.0.1:5000
+ALIGNAK_WEBUI_WS=http://127.0.0.1:7770
+ALIGNAK_WEBUI_PID=/var/run//alignak-webui/alignak-webui.pid
+ALIGNAK_WEBUI_LOG=/var/log/alignak-webui/alignak-webui.log
+ALIGNAK_WEBUI_UWSGI_LOG=/var/log/alignak-webui/uwsgi.log
+ALIGNAK_WEBUI_LOGGER_FILE=/usr/local/share/alignak-webui/etc/logging.json
+ALIGNAK_WEBUI_HOST=127.0.0.1
+ALIGNAK_WEBUI_PORT=5001
+ALIGNAK_WEBUI_PROCESSES=4
+ALIGNAK_USER=alignak
+ALIGNAK_GROUP=alignak
+[ -r /etc/default/alignak-webui ] && . /etc/default/alignak-webui
+
+PYTHONVER=$( /usr/bin/env python -V 2>&1 | cut -d' ' -f 2 | cut -d. -f 1,2 )
+PYTHONPATH=/usr/local/lib/python$PYTHONVER/site-packages
+set +a
+
+DESC=alignak-webui
+NAME=alignak-webui
+DAEMON=/usr/bin/uwsgi
+DAEMON_ARGS="--master --enable-threads --plugin python --wsgi-file /usr/local/share/alignak-webui/etc/alignak-webui.wsgi --daemonize ${ALIGNAK_WEBUI_UWSGI_LOG} --pidfile ${ALIGNAK_WEBUI_PID} --logto /${ALIGNAK_WEBUI_LOG} --uid ${ALIGNAK_USER} --gid ${ALIGNAK_GROUP} --http-socket ${ALIGNAK_WEBUI_HOST}:${ALIGNAK_WEBUI_PORT} --processes ${ALIGNAK_WEBUI_PROCESSES} --ini /usr/local/share/alignak-webui/etc/uwsgi-service.ini"
+PIDFILE=/var/run/alignak-webui/alignak-webui.pid
+
+do_start_cmd_override ()
+{
+ /bin/mkdir -p /var/run/alignak-webui || return 2
+ /bin/chown alignak:alignak /var/run/alignak-webui || return 2
+ /bin/mkdir -p /var/log/alignak-webui || return 2
+ /bin/chown alignak:alignak /var/log/alignak-webui || return 2
+ do_start_cmd || return $?
+}
+
+do_stop_cmd_override() {
+ start-stop-daemon --stop --signal INT --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER" || return 2
+}
diff --git a/bin/systemV/init.d/gen.sh b/bin/systemV/init.d/gen.sh
new file mode 100755
index 000000000..e785e377b
--- /dev/null
+++ b/bin/systemV/init.d/gen.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Script to generate all the daemon scripts from the template
+
+for svc in broker poller reactionner receiver scheduler arbiter; do
+ dname=$svc-master
+ # For some reason you can't go over 15 characters in a daemon name
+ if [ $svc = reactionner ] ; then
+ dname=reaction-master
+ fi
+ if [ $svc = scheduler ] ; then
+ dname=schedule-master
+ fi
+ sed s/%SERVICE%/$svc/ service-template | sed s/%DAEMONNAME%/$dname/ > alignak-$svc
+done
diff --git a/bin/systemV/init.d/service-template b/bin/systemV/init.d/service-template
new file mode 100644
index 000000000..04f169fbb
--- /dev/null
+++ b/bin/systemV/init.d/service-template
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Initially generated by sysd2v v0.3 -- http://www.trek.eu.org/devel/sysd2v
+### BEGIN INIT INFO
+# Provides: alignak-%SERVICE%
+# Required-Start: $network $remote_fs $syslog
+# Required-Stop: $network $remote_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: Alignak %SERVICE% daemon instance
+### END INIT INFO
+
+# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
+if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
+ set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
+fi
+set -a
+ALIGNAK_CONFIGURATION_FILE=/usr/local/share/alignak/etc/alignak.ini
+ALIGNAK_USER=alignak
+ALIGNAK_GROUP=alignak
+[ -r /etc/default/alignak ] && . /etc/default/alignak
+
+# Alignak debs get installed inside "site-packages", but Debian's Python doesn't include it inside sys.path
+# So let's find out which Python Alignak is going to use
+PYTHONVER=$( /usr/bin/env python -V 2>&1 | cut -d' ' -f 2 | cut -d. -f 1,2 )
+PYTHONPATH=/usr/local/lib/python$PYTHONVER/site-packages
+set +a
+
+NAME=%DAEMONNAME%
+DESC=alignak-%SERVICE%
+DAEMON=/usr/local/bin/alignak-%SERVICE%
+PIDFILE=/var/run/alignak/%DAEMONNAME%.pid
+LOGFILE=/var/log/alignak/%DAEMONNAME%.log
+DAEMON_ARGS="-d -n ${NAME} -e "${ALIGNAK_CONFIGURATION_FILE}" -i ${PIDFILE} -l ${LOGFILE}"
+
+do_start_cmd_override() {
+ /bin/mkdir -p /var/log/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/log/alignak || return 2
+ /bin/chmod 775 /var/log/alignak || return 2
+ /bin/mkdir -p /var/run/alignak || return 2
+ /bin/chown -R ${ALIGNAK_USER}:${ALIGNAK_GROUP} /var/run/alignak || return 2
+ /bin/chmod 775 /var/run/alignak || return 2
+ do_start_cmd || return $?
+}
+
+do_status_override() {
+ status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && return 0 || return $?
+}
+
+do_stop_cmd_override() {
+ start-stop-daemon --stop --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER" || return 2
+}
+
+do_reload() {
+ log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+ start-stop-daemon --stop --signal HUP --quiet --pidfile "$PIDFILE" --user "$ALIGNAK_USER"
+ log_end_msg $?
+}