blob: a1182df597a01d612fc5c2acbd00cd8d0bd3e262 (
plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/sbin/openrc-run
ZENDRITE=${SVCNAME#*.}
: ${ZENDRITE_CONFDIR:=${RC_PREFIX%/}/etc/zendrite}
if [ -n "${ZENDRITE}" ] && [ ${SVCNAME} != "zendrite" ]; then
: ${ZENDRITE_CONFIG:=${ZENDRITE_CONFDIR}/${ZENDRITE}.yaml}
: ${ZENDRITE_PIDFILE:=${RC_PREFIX%/}/run/zendrite.${ZENDRITE}.pid}
else
: ${ZENDRITE_CONFIG:=${ZENDRITE_CONFDIR}/zendrite.yaml}
: ${ZENDRITE_PIDFILE:=${RC_PREFIX%/}/run/zendrite.pid}
fi
if [ -n "${ZENDRITE_USER}" ]; then
: # Do nothing, ZENDRITE_USER is set externally.
else
ZENDRITE_USER='zendrite'
fi
if [ -n "${ZENDRITE_WORKING_DIRECTORY}" ]; then
: # Do nothing, ZENDRITE_WORKING_DIRECTORY is set externally.
else
ZENDRITE_WORKING_DIRECTORY='${RC_PREFIX%/}/var/lib/zendrite'
fi
# Where should supervise-daemon write zendrite's stdout to?
if [ -n "${ZENDRITE_STDOUT_FILE}" ]; then
: # Do nothing, ZENDRITE_STDOUT_FILE is set externally.
else
ZENDRITE_STDOUT_FILE="${RC_PREFIX%/}/var/log/zendrite/zendrite.stdout"
fi
# Where should supervise-daemon write zendrite's stderr to?
if [ -n "${ZENDRITE_STDERR_FILE}" ]; then
: # Do nothing, ZENDRITE_STDERR_FILE is set externally.
else
ZENDRITE_STDERR_FILE="${RC_PREFIX%/}/var/log/zendrite/zendrite.stderr"
fi
supervisor=supervise-daemon
command="${RC_PREFIX%/}/usr/bin/zendrite"
command_args="${ZENDRITE_OPTS} --config ${ZENDRITE_CONFIG}"
command_user="${ZENDRITE_USER}:${ZENDRITE_USER}"
output_log="${ZENDRITE_STDOUT_FILE}"
error_log="${ZENDRITE_STDERR_FILE}"
directory="${ZENDRITE_WORKING_DIRECTORY}"
# https://github.com/OpenRC/openrc/blob/master/service-script-guide.md#dont-restartreload-with-a-broken-config
checkconfig() {
test -f "${ZENDRITE_CONFIG}" || {
echo "\"${ZENDRITE_CONFIG}\" does not exist or is not a regular file." >&2
return 1
}
}
start_pre() {
[ "$RC_CMD" != "restart" ] && {
checkconfig || return $?
}
# Create the log and home directories and make sure they are owned by the
# service user so it can write into them.
checkpath -d -o ${ZENDRITE_USER}:${ZENDRITE_USER} ${ZENDRITE_STDOUT_FILE%/*}
checkpath -d -o ${ZENDRITE_USER}:${ZENDRITE_USER} ${ZENDRITE_WORKING_DIRECTORY}
}
stop_pre() {
[ "$RC_CMD" = "restart" ] && {
checkconfig || return $?
}
return 0
}
|