[__opendkim_genkey] add debian support
This commit is contained in:
parent
d97fb9a434
commit
40d7b4354e
3 changed files with 37 additions and 30 deletions
|
@ -1,12 +1,24 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
DIRECTORY="/var/db/dkim/"
|
|
||||||
|
os=$( "${__explorer:?}/os" )
|
||||||
|
case "$os" in
|
||||||
|
'debian')
|
||||||
|
DIRECTORY="/etc/dkimkeys/"
|
||||||
|
;;
|
||||||
|
'alpine'|'freebsd')
|
||||||
|
DIRECTORY="/var/db/dkim/"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
DIRECTORY="/var/db/dkim/"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [ -f "${__object:?}/parameter/directory" ];
|
if [ -f "${__object:?}/parameter/directory" ];
|
||||||
then
|
then
|
||||||
# Be forgiving about a lack of trailing slash
|
# Be forgiving about a lack of trailing slash
|
||||||
DIRECTORY="$(sed -E 's!([^/])$!\1/!' < "${__object:?}/parameter/directory")"
|
DIRECTORY="$(sed -E 's!([^/])$!\1/!' < "${__object:?}/parameter/directory")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
KEY_ID="$(echo "${__object_id:?)}" | tr '/' '_')"
|
KEY_ID="$(echo "${__object_id:?)}" | tr '/' '_')"
|
||||||
DEFAULT_PATH="${DIRECTORY:?}${KEY_ID:?}.private"
|
DEFAULT_PATH="${DIRECTORY:?}${KEY_ID:?}.private"
|
||||||
if [ -s "${DEFAULT_PATH}" ]; then
|
if [ -s "${DEFAULT_PATH}" ]; then
|
||||||
|
|
|
@ -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
|
Take into account that if you use this type without the `--domain` and
|
||||||
`--selector` parameters, the `$__object_id` must be in form `$domain/$selector`.
|
`--selector` parameters, the `$__object_id` must be in form `$domain/$selector`.
|
||||||
|
|
||||||
Currently, this type is only implemented for Alpine Linux and FreeBSD.
|
Currently, this type is only implemented for Debian, Alpine Linux and FreeBSD.
|
||||||
Please contribute an implementation if you can.
|
Please contribute an implementation if you can.
|
||||||
|
|
||||||
NOTE: the name of the key file under `--directory` will default to
|
NOTE: the name of the key file under `--directory` will default to
|
||||||
|
|
|
@ -21,12 +21,20 @@
|
||||||
|
|
||||||
os=$(cat "${__global:?}/explorer/os")
|
os=$(cat "${__global:?}/explorer/os")
|
||||||
|
|
||||||
CFG_DIR="/etc/opendkim"
|
|
||||||
user="opendkim"
|
|
||||||
group="opendkim"
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
'alpine')
|
'alpine')
|
||||||
:
|
CFG_DIR="/etc/opendkim"
|
||||||
|
user="opendkim"
|
||||||
|
group="opendkim"
|
||||||
|
|
||||||
|
__package opendkim-utils
|
||||||
|
;;
|
||||||
|
'debian')
|
||||||
|
CFG_DIR="/etc/dkimkeys"
|
||||||
|
user="opendkim"
|
||||||
|
group="opendkim"
|
||||||
|
|
||||||
|
__package opendkim-tools
|
||||||
;;
|
;;
|
||||||
'freebsd')
|
'freebsd')
|
||||||
CFG_DIR="/usr/local/etc/mail"
|
CFG_DIR="/usr/local/etc/mail"
|
||||||
|
@ -35,8 +43,8 @@ case "$os" in
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
cat <<- EOF >&2
|
cat <<- EOF >&2
|
||||||
__opendkim_genkey currently only supports Alpine Linux and FreeBSD.
|
__opendkim_genkey does not support $os (yet).
|
||||||
Please contribute an implementation for $os if you can.
|
Please contribute an implementation if you can.
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
@ -78,13 +86,6 @@ printf '%s' "${group:?}" > "${__object:?}/group"
|
||||||
printf '%s' "${DOMAIN:?}" > "${__object:?}/domain"
|
printf '%s' "${DOMAIN:?}" > "${__object:?}/domain"
|
||||||
printf '%s' "${SELECTOR:?}" > "${__object:?}/selector"
|
printf '%s' "${SELECTOR:?}" > "${__object:?}/selector"
|
||||||
|
|
||||||
DIRECTORY="/var/db/dkim/"
|
|
||||||
if [ -f "${__object:?}/parameter/directory" ];
|
|
||||||
then
|
|
||||||
# Be forgiving about a lack of trailing slash
|
|
||||||
DIRECTORY="$(sed -E 's!([^/])$!\1/!' < "${__object:?}/parameter/directory")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
SIGKEY="${DOMAIN:?}"
|
SIGKEY="${DOMAIN:?}"
|
||||||
if [ -f "${__object:?}/parameter/sigkey" ];
|
if [ -f "${__object:?}/parameter/sigkey" ];
|
||||||
then
|
then
|
||||||
|
@ -96,24 +97,18 @@ then
|
||||||
SIGDOMAIN="$(cat "${__object:?}/parameter/sigdomain")"
|
SIGDOMAIN="$(cat "${__object:?}/parameter/sigdomain")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure the key-container directory exists with the proper permissions
|
KEY_STATE="$(cut -f 1 "${__object:?}/explorer/key-state")"
|
||||||
__directory "${DIRECTORY}" \
|
KEY_LOCATION="$(cut -f 2- "${__object:?}/explorer/key-state")"
|
||||||
--mode 0750 \
|
|
||||||
--owner "${user}" --group "${group}"
|
|
||||||
|
|
||||||
# OS-specific code
|
|
||||||
case "$os" in
|
|
||||||
'alpine')
|
|
||||||
# This is needed for opendkim-genkey
|
|
||||||
__package opendkim-utils
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
keys_dir=$(dirname "${KEY_LOCATION:?}")
|
||||||
key_table="${CFG_DIR}/KeyTable"
|
key_table="${CFG_DIR}/KeyTable"
|
||||||
signing_table="${CFG_DIR}/SigningTable"
|
signing_table="${CFG_DIR}/SigningTable"
|
||||||
|
|
||||||
KEY_STATE="$(cut -f 1 "${__object:?}/explorer/key-state")"
|
# Ensure the key-container directory exists with the proper permissions
|
||||||
KEY_LOCATION="$(cut -f 2- "${__object:?}/explorer/key-state")"
|
__directory "${keys_dir}" \
|
||||||
|
--mode 0750 \
|
||||||
|
--owner "${user}" \
|
||||||
|
--group "${group}"
|
||||||
|
|
||||||
__line "__opendkim_genkey/${__object_id:?}" \
|
__line "__opendkim_genkey/${__object_id:?}" \
|
||||||
--file "${key_table}" \
|
--file "${key_table}" \
|
||||||
|
|
Loading…
Add table
Reference in a new issue