3 #Usage specify a private keyfile to use with dynv6 'export KEY="path/to/keyfile"'
4 #if no keyfile is specified, you will be asked if you want to create one in /home/$USER/.ssh/dynv6 and /home/$USER/.ssh/dynv6.pub
5 ######## Public functions #####################
6 # Please Read this guide first: https://github.com/Neilpang/acme.sh/wiki/DNS-API-Dev-Guide
7 #Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
11 _info
"Using dynv6 api"
12 _debug fulldomain
"$fulldomain"
13 _debug txtvalue
"$txtvalue"
15 _info
"using keyfile $dynv6_keyfile"
16 _get_domain
"$fulldomain"
17 _your_hosts
="$(ssh -i "$dynv6_keyfile" api@dynv6.com hosts)"
18 if ! _contains
"$_your_hosts" "$_host"; then
19 _debug
"The host is $_host and the record $_record"
20 _debug
"Dynv6 returned $_your_hosts"
21 _err
"The host $_host does not exist on your dynv6 account"
24 _debug
"found host on your account"
25 returnval
="$(ssh -i "$dynv6_keyfile" api@dynv6.com hosts \""$_host"\" records set \""$_record"\" txt data \""$txtvalue"\")"
26 _debug
"Dynv6 returend this after record was added: $returnval"
27 if _contains
"$returnval" "created"; then
29 elif _contains
"$returnval" "updated"; then
32 _err
"Something went wrong! it does not seem like the record was added succesfully"
37 #Usage: fulldomain txtvalue
38 #Remove the txt record after validation.
42 _info
"Using dynv6 api"
43 _debug fulldomain
"$fulldomain"
44 _debug txtvalue
"$txtvalue"
46 _info
"using keyfile $dynv6_keyfile"
47 _get_domain
"$fulldomain"
48 _your_hosts
="$(ssh -i "$dynv6_keyfile" api@dynv6.com hosts)"
49 if ! _contains
"$_your_hosts" "$_host"; then
50 _debug
"The host is $_host and the record $_record"
51 _debug
"Dynv6 returned $_your_hosts"
52 _err
"The host $_host does not exist on your dynv6 account"
55 _debug
"found host on your account"
56 _info
"$(ssh -i "$dynv6_keyfile" api@dynv6.com hosts "\"$_host\"" records del "\"$_record\"" txt)"
60 #################### Private functions below ##################################
61 #Usage: No Input required
63 #dynv6_keyfile the path to the new keyfile that has been generated
65 dynv6_keyfile
="$(eval echo ~"$USER")/.ssh/dynv6"
66 _info
"Path to key file used: $dynv6_keyfile"
67 if [ ! -f "$dynv6_keyfile" ] && [ ! -f "$dynv6_keyfile.pub" ]; then
68 _debug
"generating key in $dynv6_keyfile and $dynv6_keyfile.pub"
69 ssh-keygen
-f "$dynv6_keyfile" -t ssh-ed25519
-N ''
71 _err
"There is already a file in $dynv6_keyfile or $dynv6_keyfile.pub"
75 #Usage: _acme-challenge.www.example.dynv6.net
77 #_host= example.dynv6.net
78 #_record=_acme-challenge.www
79 #aborts if not a valid domain
82 _debug
"getting domain for $_full_domain"
83 if ! _contains
"$_full_domain" 'dynv6.net' && ! _contains
"$_full_domain" 'dns.army' && ! _contains
"$_full_domain" 'dns.navy'; then
84 _err
"The hosts does not seem to be a dynv6 host"
87 _record
="${_full_domain%.*}"
88 _record
="${_record%.*}"
89 _record
="${_record%.*}"
90 _debug
"The record we are ging to use is $_record"
92 while [ "$(echo "$_host" | grep -o '\.' | wc -l)" != "2" ]; do
95 _debug
"And the host is $_host"
100 # Usage: No input required
102 #dynv6_keyfile path to the key that will be used
104 _debug
"get keyfile method called"
105 dynv6_keyfile
="${dynv6_keyfile:-$(_readaccountconf_mutable dynv6_keyfile)}"
106 _debug Your key is
"$dynv6_keyfile"
107 if [ -z "$dynv6_keyfile" ]; then
108 if [ -z "$KEY" ]; then
109 _err
"You did not specify a key to use with dynv6"
110 _info
"Creating new dynv6 api key to add to dynv6.com"
112 _info
"Please add this key to dynv6.com $(cat "$dynv6_keyfile.pub
")"
113 _info
"Hit Enter to contiue"
115 #save the credentials to the account conf file.
119 _saveaccountconf_mutable dynv6_keyfile
"$dynv6_keyfile"