6b7b5caf54
Instead of using comments declare info in a special variable. Then the variable can be used to print the DNS API provider usage. The usage can be parsed on UI and show all needed inputs for options. The info is stored in plain string that it's both human-readable and easy to parse: dns_example_info='API name An extended description. Multiline. Domains: list of alternative domains to find Site: the dns provider website e.g. example.com Docs: Link to ACME.sh wiki for the provider Options: VARIABLE1 Title for the option1. VARIABLE2 Title for the option2. Default "default value". VARIABLE3 Title for the option3. Description to show on UI. Optional. Issues: Link to a support ticket on https://github.com/acmesh-official/acme.sh Author: First Lastname <authoremail@example.com>, Another Author <https://github.com/example>; ' Here: VARIABLE1 will be required. VARIABLE2 will be required too but will be populated with a "default value". VARIABLE3 is optional and can be empty. A DNS provider may have alternative options like CloudFlare may use API KEY or API Token. You can use a second section OptionsAlt: section. Some providers may have alternative names or domains e.g. Aliyun and AlibabaCloud. Add them to Domains: section. Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
71 lines
1.8 KiB
Bash
71 lines
1.8 KiB
Bash
#!/usr/bin/env sh
|
|
# shellcheck disable=SC2034
|
|
dns_nsd_info='NLnetLabs NSD Server
|
|
Site: github.com/NLnetLabs/nsd
|
|
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi#nsd
|
|
Options:
|
|
Nsd_ZoneFile Zone File path. E.g. "/etc/nsd/zones/example.com.zone"
|
|
Nsd_Command Command. E.g. "sudo nsd-control reload"
|
|
Issues: github.com/acmesh-official/acme.sh/issues/2245
|
|
'
|
|
|
|
# args: fulldomain txtvalue
|
|
dns_nsd_add() {
|
|
fulldomain=$1
|
|
txtvalue=$2
|
|
ttlvalue=300
|
|
|
|
Nsd_ZoneFile="${Nsd_ZoneFile:-$(_readdomainconf Nsd_ZoneFile)}"
|
|
Nsd_Command="${Nsd_Command:-$(_readdomainconf Nsd_Command)}"
|
|
|
|
# Arg checks
|
|
if [ -z "$Nsd_ZoneFile" ] || [ -z "$Nsd_Command" ]; then
|
|
Nsd_ZoneFile=""
|
|
Nsd_Command=""
|
|
_err "Specify ENV vars Nsd_ZoneFile and Nsd_Command"
|
|
return 1
|
|
fi
|
|
|
|
if [ ! -f "$Nsd_ZoneFile" ]; then
|
|
Nsd_ZoneFile=""
|
|
Nsd_Command=""
|
|
_err "No such file: $Nsd_ZoneFile"
|
|
return 1
|
|
fi
|
|
|
|
_savedomainconf Nsd_ZoneFile "$Nsd_ZoneFile"
|
|
_savedomainconf Nsd_Command "$Nsd_Command"
|
|
|
|
echo "$fulldomain. $ttlvalue IN TXT \"$txtvalue\"" >>"$Nsd_ZoneFile"
|
|
_info "Added TXT record for $fulldomain"
|
|
_debug "Running $Nsd_Command"
|
|
if eval "$Nsd_Command"; then
|
|
_info "Successfully updated the zone"
|
|
return 0
|
|
else
|
|
_err "Problem updating the zone"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# args: fulldomain txtvalue
|
|
dns_nsd_rm() {
|
|
fulldomain=$1
|
|
txtvalue=$2
|
|
ttlvalue=300
|
|
|
|
Nsd_ZoneFile="${Nsd_ZoneFile:-$(_readdomainconf Nsd_ZoneFile)}"
|
|
Nsd_Command="${Nsd_Command:-$(_readdomainconf Nsd_Command)}"
|
|
|
|
_sed_i "/$fulldomain. $ttlvalue IN TXT \"$txtvalue\"/d" "$Nsd_ZoneFile"
|
|
_info "Removed TXT record for $fulldomain"
|
|
_debug "Running $Nsd_Command"
|
|
if eval "$Nsd_Command"; then
|
|
_info "Successfully reloaded NSD "
|
|
return 0
|
|
else
|
|
_err "Problem reloading NSD"
|
|
return 1
|
|
fi
|
|
}
|