fix: re-register domainkeys when previously failed

This commit is contained in:
f 2024-06-22 19:46:30 -03:00
parent 25cc58890b
commit ac68f90e25
No known key found for this signature in database

View file

@ -36,8 +36,7 @@ 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 # Remove old keys later
prev="`find $dir -name "*.private" -o -name "*.txt"`" prev="`find $dir -name "*.private" -o -name "*.txt"`"
@ -48,12 +47,27 @@ case $1 in
echo "$dkey $SUTTY:$selc:$pkey" > $key echo "$dkey $SUTTY:$selc:$pkey" > $key
echo "$SUTTY $dkey" > $sig 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 " "`" txt="`cat $tkey | tr -d "\n" | cut -d '"' -f 2,4 | tr -d '"' | tr -d " "`"
# Register the TXT record on every nameserver. Log failures but # Register the TXT record on every nameserver. Log failures but
# 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 +92,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