|
| 1 | +#!/usr/bin/env sh |
| 2 | + |
| 3 | +######################################################################## |
| 4 | +# https://dyndnsfree.de hook script for acme.sh |
| 5 | +# |
| 6 | +# Environment variables: |
| 7 | +# |
| 8 | +# - $DF_user (your dyndnsfree.de username) |
| 9 | +# - $DF_password (your dyndnsfree.de password) |
| 10 | +# |
| 11 | +# Author: Thilo Gass <[email protected]> |
| 12 | +# Git repo: https://github.com/ThiloGa/acme.sh |
| 13 | + |
| 14 | +#-- dns_df_add() - Add TXT record -------------------------------------- |
| 15 | +# Usage: dns_df_add _acme-challenge.subdomain.domain.com "XyZ123..." |
| 16 | + |
| 17 | +dyndnsfree_api="https://dynup.de/acme.php" |
| 18 | + |
| 19 | +dns_df_add() { |
| 20 | + fulldomain=$1 |
| 21 | + txt_value=$2 |
| 22 | + _info "Using DNS-01 dyndnsfree.de hook" |
| 23 | + |
| 24 | + DF_user="${DF_user:-$(_readaccountconf_mutable DF_user)}" |
| 25 | + DF_password="${DF_password:-$(_readaccountconf_mutable DF_password)}" |
| 26 | + if [ -z "$DF_user" ] || [ -z "$DF_password" ]; then |
| 27 | + DF_user="" |
| 28 | + DF_password="" |
| 29 | + _err "No auth details provided. Please set user credentials using the \$DF_user and \$DF_password environment variables." |
| 30 | + return 1 |
| 31 | + fi |
| 32 | + #save the api user and password to the account conf file. |
| 33 | + _debug "Save user and password" |
| 34 | + _saveaccountconf_mutable DF_user "$DF_user" |
| 35 | + _saveaccountconf_mutable DF_password "$DF_password" |
| 36 | + |
| 37 | + domain="$(printf "%s" "$fulldomain" | cut -d"." -f2-)" |
| 38 | + |
| 39 | + get="$dyndnsfree_api?username=$DF_user&password=$DF_password&hostname=$domain&add_hostname=$fulldomain&txt=$txt_value" |
| 40 | + |
| 41 | + if ! erg="$(_get "$get")"; then |
| 42 | + _err "error Adding $fulldomain TXT: $txt_value" |
| 43 | + return 1 |
| 44 | + fi |
| 45 | + |
| 46 | + if _contains "$erg" "success"; then |
| 47 | + _info "Success, TXT Added, OK" |
| 48 | + else |
| 49 | + _err "error Adding $fulldomain TXT: $txt_value erg: $erg" |
| 50 | + return 1 |
| 51 | + fi |
| 52 | + |
| 53 | + _debug "ok Auto $fulldomain TXT: $txt_value erg: $erg" |
| 54 | + return 0 |
| 55 | +} |
| 56 | + |
| 57 | +dns_df_rm() { |
| 58 | + |
| 59 | + fulldomain=$1 |
| 60 | + txtvalue=$2 |
| 61 | + _info "TXT enrty in $fulldomain is deleted automatically" |
| 62 | + _debug fulldomain "$fulldomain" |
| 63 | + _debug txtvalue "$txtvalue" |
| 64 | + |
| 65 | +} |
0 commit comments