@@ -12,23 +12,25 @@ dns_selfhost_add() {
1212 _debug txtvalue " $txt "
1313
1414 SELFHOSTDNS_UPDATE_URL=" https://selfhost.de/cgi-bin/api.pl"
15+
16+ # Get values, but don't save until we successfully validated
1517 SELFHOSTDNS_USERNAME=" ${SELFHOSTDNS_USERNAME:- $(_readaccountconf_mutable SELFHOSTDNS_USERNAME)} "
1618 SELFHOSTDNS_PASSWORD=" ${SELFHOSTDNS_PASSWORD:- $(_readaccountconf_mutable SELFHOSTDNS_PASSWORD)} "
17- SELFHOSTDNS_MAP=" ${SELFHOSTDNS_MAP:- $(_readaccountconf_mutable SELFHOSTDNS_MAP)} "
18- SELFHOSTDNS_RID=" ${SELFHOSTDNS_RID:- $(_readaccountconf_mutable SELFHOSTDNS_RID)} "
19- SELFHOSTDNS_RID2=" ${SELFHOSTDNS_RID2:- $(_readaccountconf_mutable SELFHOSTDNS_RID2)} "
20- SELFHOSTDNS_LAST_SLOT=" $( _readaccountconf_mutable SELFHOSTDNS_LAST_SLOT) "
19+ # These values are domain dependent, so read them from there
20+ _getdeployconf SELFHOSTDNS_MAP
21+ _getdeployconf SELFHOSTDNS_RID
22+ _getdeployconf SELFHOSTDNS_RID2
23+ _getdeployconf SELFHOSTDNS_LAST_SLOT
24+
25+ if [ -z " ${SELFHOSTDNS_USERNAME:- } " ] || [ -z " ${SELFHOSTDNS_PASSWORD:- } " ]; then
26+ _err " SELFHOSTDNS_USERNAME and SELFHOSTDNS_PASSWORD must be set"
27+ return 1
28+ fi
2129
2230 if test -z " $SELFHOSTDNS_LAST_SLOT " ; then
2331 SELFHOSTDNS_LAST_SLOT=1
2432 fi
2533
26- _saveaccountconf_mutable SELFHOSTDNS_USERNAME " $SELFHOSTDNS_USERNAME "
27- _saveaccountconf_mutable SELFHOSTDNS_PASSWORD " $SELFHOSTDNS_PASSWORD "
28- _saveaccountconf_mutable SELFHOSTDNS_MAP " $SELFHOSTDNS_MAP "
29- _saveaccountconf_mutable SELFHOSTDNS_RID " $SELFHOSTDNS_RID "
30- _saveaccountconf_mutable SELFHOSTDNS_RID2 " $SELFHOSTDNS_RID2 "
31-
3234 rid=$( echo " $SELFHOSTDNS_MAP " | grep -Eoi " $domain :(\d+)" | tr -d " $domain :" )
3335
3436 if test -z " $rid " ; then
@@ -41,7 +43,10 @@ dns_selfhost_add() {
4143 fi
4244 fi
4345
44- _saveaccountconf_mutable SELFHOSTDNS_LAST_SLOT " $SELFHOSTDNS_LAST_SLOT "
46+ if test -z " $rid " ; then
47+ _err " SELFHOSTDNS_RID and SELFHOSTDNS_RID2, or SELFHOSTDNS_MAP must be set"
48+ return 1
49+ fi
4550
4651 _info " Trying to add $txt on selfhost for rid: $rid "
4752
@@ -52,6 +57,15 @@ dns_selfhost_add() {
5257 _err " Invalid response of acme-dns for selfhost"
5358 return 1
5459 fi
60+
61+ # Now that we know the values are good, save them
62+ _saveaccountconf_mutable SELFHOSTDNS_USERNAME " $SELFHOSTDNS_USERNAME "
63+ _saveaccountconf_mutable SELFHOSTDNS_PASSWORD " $SELFHOSTDNS_PASSWORD "
64+ # These values are domain dependent, so store them there
65+ _savedeployconf SELFHOSTDNS_MAP " $SELFHOSTDNS_MAP "
66+ _savedeployconf SELFHOSTDNS_RID " $SELFHOSTDNS_RID "
67+ _savedeployconf SELFHOSTDNS_RID2 " $SELFHOSTDNS_RID2 "
68+ _savedeployconf SELFHOSTDNS_LAST_SLOT " $SELFHOSTDNS_LAST_SLOT "
5569}
5670
5771dns_selfhost_rm () {
0 commit comments