2015-03-16 18:00:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# 2015 Nico Schottelius (nico-cdist at schottelius.org)
|
2015-07-23 20:05:55 +00:00
|
|
|
# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
|
2015-03-16 18:00:47 +00:00
|
|
|
#
|
|
|
|
# This file is part of cdist.
|
|
|
|
#
|
|
|
|
# cdist is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# cdist 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 General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ -f "/etc/default/consul" ]; then
|
|
|
|
. /etc/default/consul
|
|
|
|
fi
|
|
|
|
|
|
|
|
. /lib/lsb/init-functions
|
|
|
|
|
|
|
|
NAME=consul
|
|
|
|
CONSUL=/usr/local/bin/consul
|
|
|
|
CONFIG=/etc/$NAME/conf.d
|
|
|
|
PID_FILE=/var/run/$NAME/pidfile
|
|
|
|
|
2015-07-23 20:05:55 +00:00
|
|
|
mkdir -p /var/run/$NAME
|
|
|
|
chown consul:consul /var/run/$NAME
|
|
|
|
chmod 2770 /var/run/$NAME
|
|
|
|
|
2015-03-16 18:00:47 +00:00
|
|
|
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
log_daemon_msg "Starting consul agent" "consul" || true
|
|
|
|
if start-stop-daemon --start --quiet --oknodo \
|
|
|
|
--pidfile "$PID_FILE" --background \
|
|
|
|
--exec $CONSUL -- agent -pid-file="$PID_FILE" -config-dir "$CONFIG"; then
|
|
|
|
log_end_msg 0 || true
|
|
|
|
else
|
|
|
|
log_end_msg 1 || true
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
stop)
|
|
|
|
log_daemon_msg "Stopping consul agent" "consul" || true
|
|
|
|
if start-stop-daemon --stop --quiet --oknodo --pidfile $PID_FILE; then
|
|
|
|
log_end_msg 0 || true
|
|
|
|
else
|
|
|
|
log_end_msg 1 || true
|
|
|
|
fi
|
|
|
|
;;
|
2015-07-23 20:05:55 +00:00
|
|
|
|
2015-03-16 18:00:47 +00:00
|
|
|
reload)
|
|
|
|
log_daemon_msg "Reloading consul agent" "consul" || true
|
|
|
|
if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID_FILE --exec $CONSUL; then
|
|
|
|
log_end_msg 0 || true
|
|
|
|
else
|
|
|
|
log_end_msg 1 || true
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
restart)
|
|
|
|
$0 stop && $0 start
|
|
|
|
;;
|
|
|
|
|
|
|
|
status)
|
|
|
|
status_of_proc -p $PID_FILE $CONSUL consul && exit 0 || exit $?
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
log_action_msg "Usage: /etc/init.d/consul {start|stop|reload|restart|status}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|