salt/debian/salt-minion.init

100 lines
2.6 KiB
Plaintext
Raw Normal View History

2011-10-04 03:46:11 +00:00
#!/bin/sh
### BEGIN INIT INFO
2012-11-13 21:03:53 +00:00
# Provides: salt-minion
2014-02-20 15:56:14 +00:00
# Required-Start: $remote_fs $network +cloud-init
2012-11-13 21:03:53 +00:00
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
2011-10-04 03:46:11 +00:00
# Short-Description: salt minion control daemon
2012-11-13 21:03:53 +00:00
# Description: This is a daemon that controls the salt minions
2011-10-04 03:46:11 +00:00
### END INIT INFO
2012-11-13 21:03:53 +00:00
# Author: Michael Prokop <mika@debian.org>
2011-10-04 03:46:11 +00:00
2012-11-13 21:03:53 +00:00
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="salt minion control daemon"
NAME=salt-minion
DAEMON=/usr/bin/salt-minion
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
2011-10-04 03:46:11 +00:00
2012-11-13 21:03:53 +00:00
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
2011-10-04 03:46:11 +00:00
2012-11-13 21:03:53 +00:00
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
2011-10-04 03:46:11 +00:00
2012-11-13 21:03:53 +00:00
. /lib/init/vars.sh
. /lib/lsb/init-functions
2011-11-27 21:58:15 +00:00
2012-11-13 21:03:53 +00:00
do_start() {
pid=$(pidofproc -p $PIDFILE $DAEMON)
if [ -n "$pid" ] ; then
log_begin_msg "$DESC already running."
log_end_msg 0
exit 0
2011-10-04 03:46:11 +00:00
fi
2012-11-13 21:03:53 +00:00
log_daemon_msg "Starting salt-minion daemon: "
start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS
log_end_msg $?
2011-10-04 03:46:11 +00:00
}
2012-11-13 21:03:53 +00:00
do_stop() {
log_begin_msg "Stopping $DESC ..."
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
RC=$?
[ $RC -eq 0 ] && rm -f $PIDFILE
log_end_msg $RC
2011-10-04 03:46:11 +00:00
}
case "$1" in
2012-11-13 21:03:53 +00:00
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
2011-10-04 03:46:11 +00:00
;;
2012-11-13 21:03:53 +00:00
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
2011-10-04 03:46:11 +00:00
;;
2012-11-13 21:03:53 +00:00
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
2011-10-04 03:46:11 +00:00
;;
2012-11-13 21:03:53 +00:00
#reload)
# not implemented
#;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
2011-10-04 03:46:11 +00:00
;;
*)
2012-11-13 21:03:53 +00:00
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
2011-10-04 03:46:11 +00:00
;;
esac
2012-11-13 21:03:53 +00:00
exit 0