[__opendkim*] address cdist-contrib #32 review

This commit is contained in:
fnux 2024-05-29 15:34:04 +02:00
parent 40d7b4354e
commit d8afc76fdf
No known key found for this signature in database
GPG key ID: 4502C902C00A1E12
6 changed files with 15 additions and 25 deletions

View file

@ -3,9 +3,6 @@
echo "# Managed remotely, manual changes will be lost."
# Used for OS-specific configuration.
os=$(cat "${__global:?}/explorer/os")
# Optional chdir(2)
if [ "$BASEDIR" ];
then
@ -71,3 +68,6 @@ if [ "$PIDFILE" ];
then
printf "PidFile %s\n" "$PIDFILE"
fi
# Custom user configuration, if any (passed via --custom-config):
$CUSTOM_CONFIG

View file

@ -14,7 +14,7 @@ installation and basic configuration of an instance of OpenDKIM.
Note that this type does not generate or ensure that a key is present: use
`cdist-type__opendkim-genkey(7)` for that.
Note that this type is currently only implemented for Debian, Alpine Linux and
Note that this type is currently only implemented for Alpine Linux, Debian and
FreeBSD. Please contribute an implementation if you can.
@ -45,10 +45,6 @@ custom-config
The string following this parameter is appended as-is in the configuration, to
enable more complex configurations.
pidfile
Specifies the path to a file that should be created at process start
containing the process ID.
BOOLEAN PARAMETERS
------------------
syslog

View file

@ -77,9 +77,10 @@ if [ -f "${__object:?}/parameter/userid" ]; then
export USERID
fi
if [ -f "${__object:?}/parameter/pidfile" ]; then
PIDFILE="$(cat "${__object:?}/parameter/pidfile")"
export PIDFILE
# Custom configuration handling.
if [ -f "${__object:?}/parameter/custom-config" ]; then
CUSTOM_CONFIG="$(cat "${__object:?}/parameter/custom-config")"
export CUSTOM_CONFIG
fi
# Debian: set configuration specific to debian packaging if no explicit value
@ -89,15 +90,17 @@ if [ "$os" = "debian" ]; then
# using a local socket with MTAs that access the socket as a non-privileged
# user (for example, Postfix). You may need to add user "postfix" to group
# "opendkim" in that case.
if [ -z "$USERID" ]; then
# We only set UserID if it is not provided via custom configuration.
if [ -z "$USERID" ] && echo "$CUSTOM_CONFIG" | grep -Eq '^UserID\s+\w+$'; then
export USERID="opendkim"
fi
if [ -z "$UMASK" ]; then
if [ -z "$UMASK" ] && echo "$CUSTOM_CONFIG" | grep -Eq '^UMask\s+\w+$'; then
export UMASK="007"
fi
if [ -z "$PIDFILE" ]; then
if ! echo "$CUSTOM_CONFIG" | grep -Eq '^PidFile\s+\w+$'; then
export PIDFILE="/run/opendkim/opendkim.pid"
fi
fi
@ -113,12 +116,6 @@ mkdir -p "${__object:?}/files"
"${__type:?}/files/opendkim.conf.sh" >"$source_file"
# Add user custom config
if [ -f "${__object:?}/parameter/custom-config" ]; then
echo "# Custom user config" >>"$source_file"
cat "${__object:?}/parameter/custom-config" >>"$source_file"
fi
require="__package/opendkim" __file "$target_file" \
--source "$source_file" --mode 0644

View file

@ -4,4 +4,3 @@ subdomains
umask
userid
custom-config
pidfile

View file

@ -1,13 +1,11 @@
#!/bin/sh -e
os=$( "${__explorer:?}/os" )
case "$os" in
'debian')
DIRECTORY="/etc/dkimkeys/"
;;
'alpine'|'freebsd')
DIRECTORY="/var/db/dkim/"
;;
*)
DIRECTORY="/var/db/dkim/"
;;

View file

@ -22,7 +22,7 @@ associating any given `sigkey` values to this key.
Take into account that if you use this type without the `--domain` and
`--selector` parameters, the `$__object_id` must be in form `$domain/$selector`.
Currently, this type is only implemented for Debian, Alpine Linux and FreeBSD.
Currently, this type is only implemented for Alpine Linux, Debian and FreeBSD.
Please contribute an implementation if you can.
NOTE: the name of the key file under `--directory` will default to