Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
getssl / usr / share / getssl / dns_scripts / dns_add_nsupdate
Size: Mime:
#!/usr/bin/env bash

# example of script to add token to local dns using nsupdate

fulldomain="$1"
token="$2"

# VARIABLES:
#
# DNS_NSUPDATE_KEYFILE - path to a TSIG key file, if required
# DNS_NSUPDATE_GETKEY  - command to execute if access to the key file requires
#                        some special action: mounting a disk, decrypting a file..
#                        Called with the operation 'add' and action 'open" / 'close'


if [ -n "${DNS_NSUPDATE_KEYFILE}" ]; then
  if [ -n "${DNS_NSUPDATE_KEY_HOOK}" ] && ! ${DNS_NSUPDATE_KEY_HOOK} 'add' 'open' "${fulldomain}" ; then
    exit $(( $? + 128 ))
  fi

  options="-k ${DNS_NSUPDATE_KEYFILE}"
fi

cmd=
if [ -n "${DNS_SERVER}" ]; then
  cmd+="server ${DNS_SERVER}\n"
fi

cmd+="update add  ${DNS_ZONE:-"_acme-challenge.${fulldomain}."} 300 in TXT \"${token}\"\n"
cmd+="\n" # blank line is a "send" command to nsupdate

printf "$cmd" | nsupdate ${options} -v

sts=$?

if [ -n "${DNS_NSUPDATE_KEYFILE}" ]; then
  if [ -n "${DNS_NSUPDATE_KEY_HOOK}" ] && ! ${DNS_NSUPDATE_KEY_HOOK} 'add' 'close'  "${fulldomain}"; then
    exit $(( sts + ( $? * 10 ) ))
  fi
fi

exit ${sts}