[__opendkim] FreeBSD: Fix service name inconsistency

This was going to be taken care of in __start_on_boot, but the solution to that
ended up not being generic enough; so this is what we get >,<.

While at it, add various variable value checks where it made sense.
This commit is contained in:
evilham 2022-03-15 21:30:31 +01:00
parent af04f7464b
commit 9473f34910
2 changed files with 11 additions and 7 deletions

View file

@ -34,8 +34,8 @@ then
fi
# Key and Domain tables
echo "KeyTable ${CFG_DIR}/KeyTable"
echo "SigningTable ${CFG_DIR}/SigningTable"
echo "KeyTable ${CFG_DIR:?}/KeyTable"
echo "SigningTable ${CFG_DIR:?}/SigningTable"
# Required socket to listen on
printf "Socket %s\n" "${SOCKET:?}"

View file

@ -22,13 +22,17 @@ os=$(cat "${__global:?}/explorer/os")
CFG_DIR="/etc/opendkim"
service="opendkim"
start_service="opendkim"
case "$os" in
'alpine')
:
;;
'freebsd')
CFG_DIR="/usr/local/etc/mail"
# This is for 'service X start'
service="milter-opendkim"
# This is for __start_on_boot (it's inconsistent)
start_service="milteropendkim"
;;
*)
printf "__opendkim does not yet support %s.\n" "$os" >&2
@ -75,7 +79,7 @@ fi
# Generate and deploy configuration file.
source_file="${__object:?}/files/opendkim.conf"
target_file="${CFG_DIR}/opendkim.conf"
target_file="${CFG_DIR:?}/opendkim.conf"
mkdir -p "${__object:?}/files"
@ -90,11 +94,11 @@ fi
require="__package/opendkim" __file "$target_file" \
--source "$source_file" --mode 0644
require="__package/opendkim" __start_on_boot "${service}"
require="__package/opendkim" __start_on_boot "${start_service:?}"
# Ensure Key and Signing tables exist and have proper permissions
key_table="${CFG_DIR}/KeyTable"
signing_table="${CFG_DIR}/SigningTable"
key_table="${CFG_DIR:?}/KeyTable"
signing_table="${CFG_DIR:?}/SigningTable"
require="__package/opendkim" \
__file "${key_table}" \
@ -105,7 +109,7 @@ require="__package/opendkim" \
--mode 444
require="__file${target_file} __file${key_table}
__file${signing_table} __start_on_boot/${service}" \
__file${signing_table} __start_on_boot/${start_service}" \
__check_messages opendkim \
--pattern "^__file${target_file}" \
--execute "service ${service} restart"