aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support/salt/files/salt-master
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openstack/recipes-support/salt/files/salt-master')
-rwxr-xr-xmeta-openstack/recipes-support/salt/files/salt-master111
1 files changed, 111 insertions, 0 deletions
diff --git a/meta-openstack/recipes-support/salt/files/salt-master b/meta-openstack/recipes-support/salt/files/salt-master
new file mode 100755
index 00000000..b534b363
--- /dev/null
+++ b/meta-openstack/recipes-support/salt/files/salt-master
@@ -0,0 +1,111 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: salt-master
+# Required-Start: $remote_fs $network
+# Required-Stop: $remote_fs $network
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: salt master control daemon
+# Description: This is a daemon that controls the salt minions
+### END INIT INFO
+
+# Author: Michael Prokop <mika@debian.org>
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="salt master control daemon"
+NAME=salt-master
+DAEMON=/usr/bin/salt-master
+DAEMON_ARGS="-d"
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Source function library.
+. /etc/init.d/functions
+
+do_start() {
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ pid=$(pidof -x $DAEMON)
+ if [ -n "$pid" ] ; then
+ return 1
+ fi
+
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+}
+
+do_stop() {
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && echo "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && echo OK ;;
+ 2) [ "$VERBOSE" != no ] && echo FAILED ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && echo "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && echo OK ;;
+ 2) [ "$VERBOSE" != no ] && echo FAILED ;;
+ esac
+ ;;
+ status)
+ pid=`pidof -x $DAEMON`
+ if [ -n "$pid" ]; then
+ echo "$NAME (pid $pid) is running ..."
+ else
+ echo "$NAME is stopped"
+ fi
+ ;;
+ #reload)
+ # not implemented
+ #;;
+ restart|force-reload)
+ echo "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) echo OK ;;
+ 1) echo FAILED ;; # Old process is still running
+ *) echo FAILED ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ echo FAILED
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+exit 0