net-im/zendrite: update OpenRC script, remove keepdir and fowner

- move the supervisor call from the conf file to the init file, it
  should not be togglable by users
- use $output_log and $error_log instead of passing args to supervise-
  daemon to log zendrite's stdout/error
- move the config file check to a dedicated checkconfig() function and
  run it at start_pre() and stop_pre() like shown in [1]
- instead of using keepdir and fowners on file in /var do it in the
  init script instead with checkconfig

Removed the fowner calls especially since them being on REPEND instead
of BDEPEND could cause issues with cross-compiling.

[1]: https://github.com/OpenRC/openrc/blob/master/service-script-guide.md#dont-restartreload-with-a-broken-config

Part-off: https://codeberg.org/gentoo/guru/pulls/101
Merges: https://codeberg.org/gentoo/guru/pulls/101
Reviewerd-by: Niklaus 'vimja' Hofer <gentoo-bugzilla@vimja.email>
Signed-off-by: zyxhere💭 <zyx@envs.net>
This commit is contained in:
zyxhere💭 committed 2026-10-05 14:03:10 +05:00
1 parent fbe0f14cee
commit a946011e75
3 files changed
+92 -7

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
# Increase the maximum number of open file descriptors. Set to a higher
# value for larger servers or if joining larger rooms.
rc_ulimit="-n 4096"
# Specify the network service that corresponds to the "bind" setting
# in your configuration file. For example, if you bind to 127.0.0.1,
# this should be set to "loopback" which provides the loopback interface.
rc_need="loopback"
# Uncomment if you are using PostgreSQL:
# rc_need="${rc_need} postgresql"
# Use to bind to different port (useful when running multiple instances).
# ZENDRITE_OPTS="-http-bind-address localhost:8008"
# the config file for zendrite to use
# ZENDRITE_CONFIG="/etc/zendrite/zendrite.yaml"
+73
View File
@@ -0,0 +1,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
}
@@ -97,11 +97,6 @@ src_install() {
insinto /etc/zendrite
doins "${S}"/zendrite-sample.yaml
newinitd "${FILESDIR}"/init.1 zendrite
newconfd "${FILESDIR}"/conf.1 zendrite
keepdir /var/log/zendrite
keepdir /var/lib/zendrite
fowners zendrite:zendrite /var/log/zendrite
newinitd "${FILESDIR}"/init-r2 zendrite
newconfd "${FILESDIR}"/conf-r2 zendrite
}