[__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 fi
# Key and Domain tables # Key and Domain tables
echo "KeyTable ${CFG_DIR}/KeyTable" echo "KeyTable ${CFG_DIR:?}/KeyTable"
echo "SigningTable ${CFG_DIR}/SigningTable" echo "SigningTable ${CFG_DIR:?}/SigningTable"
# Required socket to listen on # Required socket to listen on
printf "Socket %s\n" "${SOCKET:?}" printf "Socket %s\n" "${SOCKET:?}"

View File

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