forked from saltstack-formulas/consul-formula
-
Notifications
You must be signed in to change notification settings - Fork 0
/
consul.openrc
55 lines (45 loc) · 998 Bytes
/
consul.openrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/sbin/openrc-run
if [ -z "${CONSUL_DIR}" ] ; then
CONSUL_DIR="/etc/consul.d"
fi
if [ -z "${CONSUL_PID}" ] ; then
CONSUL_PID="/run/consul.pid"
fi
extra_started_commands="reload graceful"
required_files=$CONSUL_CONF
depend() {
need net
use logger dns
after firewall
after famd
after sshd
}
checkconfig() {
if [ ! -d "${CONSUL_DIR}" ] ; then
ewarn "${CONSUL_DIR} does not exist."
return 1
fi
/usr/local/bin/consul validate "${CONSUL_DIR}"
}
start() {
checkconfig || return 1
ebegin "Starting consul"
start-stop-daemon --start --quiet --background --make-pidfile --pidfile "${CONSUL_PID}" \
--exec /usr/local/bin/consul -- agent -config-dir="${CONSUL_DIR}"
eend $?
}
stop() {
local rv=0
ebegin "Stopping consul"
start-stop-daemon --stop --quiet --pidfile "${CONSUL_PID}"
rm -f "${CONSUL_PID}"
eend $?
}
reload() {
if ! service_started "${SVCNAME}" ; then
eerror "${SVCNAME} isn't running"
return 1
fi
checkconfig || return 1
eend $?
}