Compare commits

..

2 commits

Author SHA1 Message Date
f
793c9f7644
fix: recover ownership
All checks were successful
ci/woodpecker/push/woodpecker/1 Pipeline was successful
ci/woodpecker/push/woodpecker/2 Pipeline was successful
ci/woodpecker/push/woodpecker/3 Pipeline was successful
ci/woodpecker/push/woodpecker/4 Pipeline was successful
2024-06-22 19:46:54 -03:00
f
ac68f90e25
fix: re-register domainkeys when previously failed 2024-06-22 19:46:30 -03:00

View file

@ -36,17 +36,28 @@ case $1 in
dkey="$selc._domainkey.$SUTTY" dkey="$selc._domainkey.$SUTTY"
# Do nothing if it already exists # 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 ok "Generating new keys for selector ${selc}"
prev="`find $dir -name "*.private" -o -name "*.txt"`" opendkim-genkey --directory=$dir --selector=$selc --subdomains --domain=$SUTTY
chown -R opendkim:opendkim /etc/opendkim
ok "Generating new keys for selector ${selc}" # Discard previous keys
opendkim-genkey --directory=$dir --selector=$selc --subdomains --domain=$SUTTY echo "$dkey $SUTTY:$selc:$pkey" > $key
echo "$SUTTY $dkey" > $sig
# Discard previous keys if test -n "$prev"; then
echo "$dkey $SUTTY:$selc:$pkey" > $key ok "Pruning old keypairs"
echo "$SUTTY $dkey" > $sig 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 " "`" txt="`cat $tkey | tr -d "\n" | cut -d '"' -f 2,4 | tr -d '"' | tr -d " "`"
@ -54,6 +65,10 @@ 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
@ -78,15 +93,5 @@ 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