#!/usr/bin/bash # # Original script is dns_selhost.sh by Marvin Edeler, https://github.com/Marvo2011/acme.sh/ # Bug-report here: https://github.com/acmesh-official/acme.sh/issues/4291 # # Modified by CHECKIP.NET to use with Get-Your-Free-DYNDNS and named as dns_checkipnet.sh # Bug-report per email to: dyndns-checkipnet@email4me.info # Save as /root/acme.sh/dnsapi/dns_checkipnet.sh # # Mit Nutzung von dns_checkipnet.sh stimmst Du zu, dass die Zugriffsdaten in Logdateien und Deine Daten in einer Datenbank gespeichert werden! # # By using dns_checkipnet.sh you agree that the access data will be stored in log files and your data in a database! # # Last Edit: 08.06.2023 dns_checkipnet_add() { fulldomain=$1 txt=$2 _info "Calling acme-dns on checkipnet $fulldomain" _debug fulldomain "$fulldomain" _debug txtvalue "$txt" CHECKIPNETDNS_UPDATE_URL="https://dyndns.checkip.net/acme/" # Get values, but don't save until we successfully validated CHECKIPNETDNS_ID="${CHECKIPNETDNS_ID:-$(_readaccountconf_mutable CHECKIPNETDNS_ID)}" # These values are domain dependent, so read them from there CHECKIPNETDNS_MAP="${CHECKIPNETDNS_MAP:-$(_readdomainconf CHECKIPNETDNS_MAP)}" # checkipnet api can't dynamically add TXT record, # so we have to store the last used RID of the domain to support a second RID for wildcard domains # (format: 'fulldomainA:lastRid fulldomainB:lastRid ...') CHECKIPNETDNS_MAP_LAST_USED_INTERNAL=$(_readdomainconf CHECKIPNETDNS_MAP_LAST_USED_INTERNAL) if [ -z "${CHECKIPNETDNS_ID:-}" ] ; then _err "CHECKIPNETDNS_ID" return 1 fi # get the domain entry from CHECKIPNETDNS_MAP # full domains must be wich-dyndns.dyndns.checkip.net, # must exact CHECKIPNETDNS_MAP=wich-dyndns.dyndns.checkip.net:rid1:rid2 mapEntry=$(echo "$CHECKIPNETDNS_MAP" | sed -n -E "s/(^|^.*[[:space:]])(_acme-challenge.t6t6t6t6.checkip.net:.*+)(.*)/\2/p") _debug2 mapEntry "$mapEntry" if test -z "$mapEntry"; then _err "SELFHOSTDNS_MAP must contain the fulldomain incl. prefix and at least one RID" return 1 fi # get the RIDs from the map entry rid1=$(echo "$mapEntry" | cut -d: -f2) rid2=$(echo "$mapEntry" | cut -d: -f3) # read last used rid domain lastUsedRidForDomainEntry=$CHECKIPNETDNS_MAP_LAST_USED_INTERNAL _debug2 lastUsedRidForDomainEntry "$lastUsedRidForDomainEntry" lastUsedRidForDomain=$(echo "$lastUsedRidForDomainEntry" | cut -d: -f2) rid="$rid1" if [ "$lastUsedRidForDomain" = "$rid" ] && ! test -z "$rid2"; then rid="$rid2" fi _info "Trying to add $txt on checkipnet for rid: $rid" data="?id=$CHECKIPNETDNS_ID&rid=$rid&content=$txt" response="$(_get "$CHECKIPNETDNS_UPDATE_URL$data")" if [ "$response" != "0" ]; then _err "Invalid response of acme-dns for checkipnet" return 1 fi # write last used rid domain newLastUsedRidForDomainEntry="$fulldomain:$rid" if ! test -z "$lastUsedRidForDomainEntry"; then # replace last used rid entry for domain CHECKIPNETDNS_MAP_LAST_USED_INTERNAL=$(echo "$CHECKIPNETDNS_MAP_LAST_USED_INTERNAL" | sed -n -E "s/$lastUsedRidForDomainEntry/$newLastUsedRidForDomainEntry/p") else # add last used rid entry for domain if test -z "$CHECKIPNETDNS_MAP_LAST_USED_INTERNAL"; then CHECKIPNETDNS_MAP_LAST_USED_INTERNAL="$newLastUsedRidForDomainEntry" else CHECKIPNETDNS_MAP_LAST_USED_INTERNAL="$CHECKIPNETDNS_MAP_LAST_USED_INTERNAL $newLastUsedRidForDomainEntry" fi fi # Now that we know the values are good, save them _saveaccountconf_mutable CHECKIPNETDNS_ID "$CHECKIPNETDNS_ID" # These values are domain dependent, so store them there _savedomainconf CHECKIPNETDNS_MAP "$CHECKIPNETDNS_MAP" _savedomainconf CHECKIPNETDNS_MAP_LAST_USED_INTERNAL "$CHECKIPNETDNS_MAP_LAST_USED_INTERNAL" } dns_checkipnet_rm() { fulldomain=$1 txt=$2 _debug fulldomain "$fulldomain" _debug txtvalue "$txt" _info "Creating and removing of records is not supported by CHECKIPNET API, will not delete anything." }