testing/acmed: fix and improve init script

- Fix running without supervise-daemon (`pidfile` needed)
- Tell acmed to not create pidfile.
- Rename `config_file` to de-facto standard `cfgfile`.
- Add support for logging to syslog and make it default.
- Allow to easily configure logging level.
This commit is contained in:
Jakub Jirutka 2023-05-09 17:17:46 +02:00
parent faf353b471
commit d4434cd78b
3 changed files with 45 additions and 12 deletions

View File

@ -2,7 +2,7 @@
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=acmed
pkgver=0.21.0
pkgrel=0
pkgrel=1
pkgdesc="ACME (RFC 8555) client daemon"
url="https://github.com/breard-r/acmed"
# s390x, riscv64: blocked by cargo
@ -19,7 +19,6 @@ source="https://github.com/breard-r/acmed/archive/refs/tags/v$pkgver/acmed-$pkgv
acmed.initd
"
prepare() {
default_prepare
mv "$srcdir"/Cargo.lock .
@ -70,6 +69,6 @@ tacd_doc() {
sha512sums="
ef058b12be531c95a4dc7dbed668788116e131f028f7b1d7543597dd72651ea8228a7cfc6663da424ca7b6686063537c95c90158017be4856d428d6cedbc2aa3 acmed-0.21.0.tar.gz
5497908c1e027dad698191744c8c27ac8558f8c8ed70f56e47056c694b2f0cdcfd8c3bb83098c46b6719f0643fde93ffab84ef85f4739581a124d52cd1bced3b Cargo.lock
23440890f61045df3fe3acbf1d54548eb0102d3871e536698efb7e6d2a238984a556a4294ad1588b53d79ebb5029c6268f8779634d8bebd0a611898b1c8187ff acmed.confd
91192fd4a5da625ee6462e61aab991acac8644ec4317ecf289a17b424b93a0c615e74eec1b8b41baa42dc97c2e31846b4df3dfc19b22a504b4f01cb335c71843 acmed.initd
2fb5cb330ba4f91c49e34e5808034cbeeb23a9637f4b03cff80ea26338b0a4a232042d7888ee7305afac945402520433828db4064c4274d8ead431aa16a668c1 acmed.confd
126ce93a32c4eace6d41635947c7ecfa3fea3fd731f5ef2b528e911259305e2fdfa115bc78475d6fba57e0717facc27ac4cc341a4c24511c75ef96772e354c1b acmed.initd
"

View File

@ -1,8 +1,22 @@
# Configuration for /etc/init.d/acmed
config_file="/etc/acmed/acmed.toml"
directory="/var/lib/acmed"
command_user="acmed:acmed"
# Path to the main configuration file.
#cfgfile="/etc/acmed/acmed.toml"
# comment to use traditional service management
# Path to the working directory.
#directory="/var/lib/acmed"
# The log level. Possible values: "error", "warn", "info", "debug", "trace".
#loglevel="warn"
# Whether to log to syslog.
#syslog=yes
# Where to redirect logs if syslog is disabled. Set to empty string to disable.
#logfile="/var/log/acmed.log"
# The user (and group) to run acmed as.
#command_user="acmed:acmed"
# Comment out to use traditional service management.
supervisor=supervise-daemon

View File

@ -1,12 +1,25 @@
#!/sbin/openrc-run
description="ACME (RFC 8555) client daemon"
: ${cfgfile:=/etc/acmed/acmed.toml}
: ${logfile=/var/log/acmed.log}
: ${syslog:=yes}
command="/usr/bin/acmed"
command_args="
--foreground
--no-pid-file
--config $cfgfile
--log-level ${loglevel:-warn}
$command_args
"
command_background=true
command_args="--foreground --config ${config_file:=/etc/acmed/acmed.toml} --log-stderr"
pidfile="/run/$RC_SVCNAME.pid"
: ${command_user:=acmed:acmed}
: ${directory:=/var/lib/acmed}
error_log="/var/log/acmed.log"
required_files="$cfgfile"
depend() {
need net
@ -14,6 +27,13 @@ depend() {
}
start_pre() {
checkpath -d -m 755 -o $command_user "$directory"
checkpath -f -m 644 -o $command_user /var/log/acmed.log
checkpath -d -m 755 -o "$command_user" "$directory" || return 1
if yesno "$syslog"; then
command_args="$command_args --log-syslog"
elif [ "$logfile" ]; then
command_args="$command_args --log-stderr"
error_log="$logfile"
checkpath -f -q -m 644 -o "$command_user" "$logfile" || return 1
fi
}