95 lines
3.6 KiB
Bash
95 lines
3.6 KiB
Bash
#!/bin/sh
|
|
|
|
. ./dns-functions.sh
|
|
|
|
# exit script when command fails
|
|
set -e
|
|
|
|
export DNSSCRIPT_CONTACT_EMAIL=franken.freifunk.net.
|
|
export DNSSCRIPT_SERVER_NAME=fff-gw-herpf01.fff.community.
|
|
UpdateScriptsFolder="/srv/fff-scripts/"
|
|
ZoneFilesFolder="/var/lib/bind"
|
|
CommunityDomain="fff.community"
|
|
|
|
# Einkommentieren und für eigene Hood setzen
|
|
#HoodSubDomain="herpf" # File unter "$ZoneFilesFolder""db.""$HoodSubDomain"".""$CommunityDomain"
|
|
#HoodSubIPv4="250" # nur /24er Netze
|
|
#HoodSubIPv6="62" # nur /64er Netze
|
|
|
|
# 0 -> Debian o.a. systemctl reload bind9
|
|
# 1 -> rndc benutzen um nur die jeweilige Zone neu zu laden (empfohlen; rndc muss eingerichtet werden)
|
|
# 2 -> für OpenWRT /etc/init.d/named reload
|
|
#
|
|
export DNSSCRIPT_BIND_RELOAD_VER=1
|
|
|
|
# Wenn rndc benutzt wird den internen und externen View setzen
|
|
InternalView="icvpn-internal-view"
|
|
ExternalView="external-view"
|
|
|
|
MasterFileRemoteLocation="https://git.freifunk-franken.de/freifunk-franken/dns/raw/branch/master/db.fff.community"
|
|
|
|
# TTL Refresh Retry Expire Minimum
|
|
TTLReReExMi="3600 2000 6400 2419200 86400"
|
|
|
|
# ForwardZones Schema: "<Zone>/<Zonendatei>" ; optional mehrfach " ""<ZoneX>/<ZonendateiX>" Keine Leerzeichen im Ordner/File erlaubt
|
|
ForwardZones="$CommunityDomain""/""$ZoneFilesFolder""db.""$CommunityDomain"
|
|
|
|
|
|
#############################################################
|
|
|
|
MasterFile="$ZoneFilesFolder""db.""$CommunityDomain"
|
|
|
|
|
|
PreFetchMasterSerial="$(GetZoneFileSerial "$MasterFile")"
|
|
curl "$MasterFileRemoteLocation" --output "$MasterFile"
|
|
PostFetchMasterSerial="$(GetZoneFileSerial "$MasterFile")"
|
|
|
|
if [ $((PostFetchMasterSerial)) -gt $((PreFetchMasterSerial)) ]; then
|
|
ReloadZone "$CommunityDomain" "$InternalView"
|
|
fi
|
|
|
|
|
|
# Update für master-zones
|
|
RZone="50.10.in-addr.arpa."
|
|
RFile="$ZoneFilesFolder""db.50.10"
|
|
"$UpdateScriptsFolder"update-rdnszone.sh "$RZone" "$ForwardZones" "$RFile" "$TTLReReExMi" "$InternalView"
|
|
|
|
RZone="83.10.in-addr.arpa."
|
|
RFile="$ZoneFilesFolder""db.83.10"
|
|
"$UpdateScriptsFolder"update-rdnszone.sh "$RZone" "$ForwardZones" "$RFile" "$TTLReReExMi" "$InternalView"
|
|
|
|
RZone="d.b.9.2.2.0.6.5.3.4.d.f.ip6.arpa."
|
|
RFile="$ZoneFilesFolder""db.fd43-5602-29bd"
|
|
"$UpdateScriptsFolder"update-rdnszone.sh "$RZone" "$ForwardZones" "$RFile" "$TTLReReExMi" "$InternalView"
|
|
|
|
if [ -n "$ExternalView" ]; then
|
|
# Split-View
|
|
InternFile="$MasterFile"
|
|
ExternFile="$ZoneFilesFolder""dbextern.""$CommunityDomain"
|
|
Domain="$CommunityDomain"
|
|
"$UpdateScriptsFolder"update-extzone.sh "$InternFile" "$ExternFile" "$Domain" "$ExternalView"
|
|
fi
|
|
|
|
|
|
if [ -n "$HoodSubDomain" ]; then
|
|
# Update für lokale Zone; ForwardZones wird hier um die SubDomain erweitert
|
|
ForwardZones="$ForwardZones $HoodSubDomain"".""$CommunityDomain""/""$ZoneFilesFolder""db.""$HoodSubDomain"".""$CommunityDomain"
|
|
|
|
RZone="$HoodSubIPv4"".50.10.in-addr.arpa."
|
|
RFile="$ZoneFilesFolder""db.""$HoodSubIPv4"".50.10"
|
|
"$UpdateScriptsFolder"update-rdnszone.sh "$RZone" "$ForwardZones" "$RFile" "$TTLReReExMi" "$InternalView"
|
|
|
|
HoodSubIPv6Reverse="$(echo "$HoodSubIPv6" | awk '{$i=substr(("0000" $i), length($i)+1); print}' | awk '{ i=length; x=substr($0,i,1); for(i--;i!=0;i--)x=x "." substr($0,i,1);}END{print x}')"
|
|
RZone="$HoodSubIPv6Reverse"".d.b.9.2.2.0.6.5.3.4.d.f.ip6.arpa."
|
|
RFile="$ZoneFilesFolder""db.fd43-5602-29bd-""$HoodSubIPv6"
|
|
"$UpdateScriptsFolder"update-rdnszone.sh "$RZone" "$ForwardZones" "$RFile" "$TTLReReExMi" "$InternalView"
|
|
|
|
if [ -n "$ExternalView" ]; then
|
|
# Split-View
|
|
InternFile="$ZoneFilesFolder""db.""$HoodSubDomain"".""$CommunityDomain"
|
|
ExternFile="$ZoneFilesFolder""dbextern.""$HoodSubDomain"".""$CommunityDomain"
|
|
Domain="$HoodSubDomain"".""$CommunityDomain"
|
|
"$UpdateScriptsFolder"update-extzone.sh "$InternFile" "$ExternFile" "$Domain" "$ExternalView"
|
|
fi
|
|
fi
|