Compare commits
2 commits
25cc58890b
...
793c9f7644
Author | SHA1 | Date | |
---|---|---|---|
|
793c9f7644 | ||
|
ac68f90e25 |
1 changed files with 23 additions and 18 deletions
41
opendkimd.sh
41
opendkimd.sh
|
@ -36,17 +36,28 @@ case $1 in
|
|||
dkey="$selc._domainkey.$SUTTY"
|
||||
|
||||
# Do nothing if it already exists
|
||||
test -f "$pkey" && exit 0
|
||||
if test ! -f "$pkey"; then
|
||||
# Remove old keys later
|
||||
prev="`find $dir -name "*.private" -o -name "*.txt"`"
|
||||
|
||||
# Remove old keys later
|
||||
prev="`find $dir -name "*.private" -o -name "*.txt"`"
|
||||
ok "Generating new keys for selector ${selc}"
|
||||
opendkim-genkey --directory=$dir --selector=$selc --subdomains --domain=$SUTTY
|
||||
chown -R opendkim:opendkim /etc/opendkim
|
||||
|
||||
ok "Generating new keys for selector ${selc}"
|
||||
opendkim-genkey --directory=$dir --selector=$selc --subdomains --domain=$SUTTY
|
||||
# Discard previous keys
|
||||
echo "$dkey $SUTTY:$selc:$pkey" > $key
|
||||
echo "$SUTTY $dkey" > $sig
|
||||
|
||||
# Discard previous keys
|
||||
echo "$dkey $SUTTY:$selc:$pkey" > $key
|
||||
echo "$SUTTY $dkey" > $sig
|
||||
if test -n "$prev"; then
|
||||
ok "Pruning old keypairs"
|
||||
rm -f $prev
|
||||
fi
|
||||
|
||||
if test -f $pid ; then
|
||||
ok "Reloading"
|
||||
cat $pid | xargs -r kill -USR1
|
||||
fi
|
||||
fi
|
||||
|
||||
txt="`cat $tkey | tr -d "\n" | cut -d '"' -f 2,4 | tr -d '"' | tr -d " "`"
|
||||
|
||||
|
@ -54,6 +65,10 @@ case $1 in
|
|||
# continue anyway.
|
||||
ok "Registering public key records"
|
||||
for node in `drill -Q ns $SUTTY`; do
|
||||
if drill -Q @${node} txt ${dkey} | grep -q "${txt}" ; then
|
||||
ok "Records already registered for selector ${selc}"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Craft record
|
||||
cat >/tmp/dns <<DNS
|
||||
|
@ -78,15 +93,5 @@ DNS
|
|||
not_ok "Couldn't query ${dkey} at ${node}!"
|
||||
fi
|
||||
done
|
||||
|
||||
if test -n "$prev"; then
|
||||
ok "Pruning old keypairs"
|
||||
rm -f $prev
|
||||
fi
|
||||
|
||||
if test -f $pid ; then
|
||||
ok "Reloading"
|
||||
cat $pid | xargs -r kill -USR1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue