Page MenuHomeDevCentral

D3551.id9123.diff
No OneTemporary

D3551.id9123.diff

diff --git a/roles/mailserver/dkim/files/bin/add-dkim-domain.sh b/roles/mailserver/dkim/files/bin/add-dkim-domain.sh
new file mode 100755
--- /dev/null
+++ b/roles/mailserver/dkim/files/bin/add-dkim-domain.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Add a new domain for OpenDKIM
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: BSD-2-Clause
+# Source file: roles/mailserver/dkim/files/bin/add-dkim-domain.sh
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+DIR_ETC_DKIM="{{ dirs.etc }}/opendkim"
+KEY_SIZE=2048
+
+# -------------------------------------------------------------
+# Ensure user is opendkim
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ "$(id -un)" != "opendkim" ]; then
+ echo "This command must be run as the opendkim user." >&2
+ exit 1
+fi
+
+# -------------------------------------------------------------
+# Parse arguments
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ $# -eq 0 ] || [ $# -gt 2 ]; then
+ echo "Usage: $(basename "$0") <domain> [selector]" >&2
+ exit 1
+fi
+
+DOMAIN=$1
+
+if [ $# -eq 2 ]; then
+ SELECTOR=$2
+else
+ SELECTOR=unium
+fi
+
+# -------------------------------------------------------------
+# Generate domain key
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+mkdir "$DIR_ETC_DKIM/keys/$DOMAIN"
+cd "$DIR_ETC_DKIM/keys/$DOMAIN"
+opendkim-genkey -s "$SELECTOR" -b $KEY_SIZE -d "$DOMAIN"
+
+# -------------------------------------------------------------
+# Refresh DKIM tables
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+cd "$DIR_ETC_DKIM"
+make clean all
diff --git a/roles/mailserver/dkim/software.sls b/roles/mailserver/dkim/software.sls
--- a/roles/mailserver/dkim/software.sls
+++ b/roles/mailserver/dkim/software.sls
@@ -38,3 +38,10 @@
- source: salt://roles/mailserver/dkim/files/bin/{{ source }}
- mode: 755
{% endfor %}
+
+/usr/local/bin/add-dkim-domain:
+ file.managed:
+ - source: salt://roles/mailserver/dkim/files/bin/add-dkim-domain.sh
+ - mode: 755
+ - context:
+ dirs: dirs

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 21, 20:14 (1 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2255401
Default Alt Text
D3551.id9123.diff (2 KB)

Event Timeline