Debian 10 - tinydns helper scripts ================================== Public domain ******************************************************************************** ### /opt/tinydns-scripts/domains/example.com ################################################################################# ## domain: example.com ################################################################################# Zexample.com:ns1.pmoghadam.ir:hostmaster.pmoghadam.ir:2012062100:16384:2048:1814400:1800 .example.com::ns1.pmoghadam.ir:1800 .example.com::ns2.pmoghadam.ir:1800 @example.com::mail.iranux.org::1800 +example.com:1.2.3.4:1800 +www.example.com:1.2.3.4:1800 ******************************************************************************** ### /opt/tinydns-scripts/comments.txt ################################################################################ # Documentation: http://cr.yp.to/djbdns/tinydns-data.html ################################################################################ # # SOA Record # Zfqdn:mname:rname:ser:ref:ret:exp:min:ttl:timestamp:lo # mname: primary name server # rname: contact address # ser: serial number (default: the modification time of the data file) # ref: refreshtime (default: 16384 seconds / 04:33:04) # ret: retry time (default: 2048 seconds / 00:34:08) # exp: expire time (default: 1048576 seconds / 12 day 03:16:16) # min: minimum time (default: 2560 seconds / 00:42:40) # # NS Record # .fqdn:ip:x:ttl:timestamp:lo # x: NS record # # A Record # +fqdn:ip:ttl:timestamp:lo # # MX Record # @fqdn:ip:x:dist:ttl:timestamp:lo # x: mx record # dist: distance (default: 0) # # ******************************************************************************** ### /opt/tinydns-scripts/create-data-file.sh #!/bin/bash PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" CWD=$(dirname $(readlink -f $0)) DATAFILE="/usr/local/djbdns/tinydns/root/data" DOMAINSDIR="$CWD/domains" COMMENTS="$CWD/comments.txt" TMP=$(mktemp) # Check if comments file exist [ ! -f "$COMMENTS" ] && echo "Comments file not exist: $COMMENTS" && exit # Check if domain directory exists [ ! -d "$DOMAINSDIR" ] && echo "Directory not found: $DOMAINSDIR" && exit # Check if domain directory not empty N=$(find "$DOMAINSDIR" -type f | wc -l) [ "$N" == "0" ] && echo "Directory is empty: $DOMAINSDIR" && exit (cat $COMMENTS; echo; echo) > $TMP find "$DOMAINSDIR" -type f -exec cat {} \; -exec echo \; >> $TMP if ! cmp -s $TMP $DATAFILE; then echo "~~~~~~~~~~~~~~~~~~~~" >> $CWD/data-change.log date +%T-%T >> $CWD/data-change.log diff -ruN $DATAFILE $TMP >> $CWD/data-change.log echo "~~~~~~~~~~~~~~~~~~~~" >> $CWD/data-change.log # Create a backup before change cp $DATAFILE $DATAFILE.bak-$(date +%F-%s) cp $TMP $DATAFILE cd $(dirname $DATAFILE) make mv data.bak-* backups else echo "No new records" fi [ -e $TMP ] && rm $TMP ******************************************************************************** _BY: Pejman Moghadam_ _TAG: tinydns, dns_ _DATE: 2021-06-2 07:12:46_