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