Namensschema
This commit is contained in:
parent
a853e4fcab
commit
4ff8f549af
|
@ -21,11 +21,11 @@ function GetZoneFileSerial() {
|
|||
local EleminateLineBreaks=":a;N;\$!ba;s/\n//g;"
|
||||
local SearchPrintSerial="s/\S\+\s\+IN\s\+SOA\s\+\S\+\s\+\S\+\s\+(\?\s\+\([0-9]*\).*/\1/"
|
||||
|
||||
local serial=$(sed -e "$FirstSOALineAndFollowing""$RemoveComments""$EleminateLineBreaks""$SearchPrintSerial" "$1")
|
||||
echo "$serial"
|
||||
local Serial=$(sed -e "$FirstSOALineAndFollowing""$RemoveComments""$EleminateLineBreaks""$SearchPrintSerial" "$1")
|
||||
echo "$Serial"
|
||||
}
|
||||
|
||||
function dnsreload {
|
||||
function DNSReload {
|
||||
if [[ -n "$Usernc" ]]; then
|
||||
rndc reload "$DomainZone" IN "icvpn-internal-view"
|
||||
else
|
||||
|
@ -33,26 +33,26 @@ function dnsreload {
|
|||
fi
|
||||
}
|
||||
|
||||
function validate_ipv4() {
|
||||
function ValidateIPv4() {
|
||||
[[ -n "$(echo "$1" | sed -e '/^\(\(25[0-5]\|\(2[0-4]\|1[0-9]\|[1-9]\)\?[0-9]\)\.\)\{0,3\}\(25[0-5]\|\(2[0-4]\|1[0-9]\|[1-9]\)\?[0-9]\)$/!d')" ]]
|
||||
return $?
|
||||
}
|
||||
|
||||
|
||||
mkdir -p $TempDir
|
||||
Serials=()
|
||||
AllSerials=()
|
||||
for ForwardZoneFile in "${ForwardZoneFiles[@]}"
|
||||
do
|
||||
ZoneName=$(sed -ne 's/\(\S\+\)\s\+IN\s\+SOA\s\+\S\+.*/\1/p' "$ForwardZoneFile")
|
||||
named-compilezone -o "$TempDir/$ZoneName" $ZoneName $ForwardZoneFile >/dev/null 2>&1
|
||||
serial="$(GetZoneFileSerial '$TempDir/$ZoneName')"
|
||||
Serials+=( "$serial" )
|
||||
Serial="$(GetZoneFileSerial '$TempDir/$ZoneName')"
|
||||
AllSerials+=( "$Serial" )
|
||||
done
|
||||
|
||||
serial=0
|
||||
for i in ${Serials[@]}; do serial=$((serial+i)); done )
|
||||
Serial=0
|
||||
for i in ${AllSerials[@]}; do Serial=$((Serial+i)); done )
|
||||
|
||||
echo "$DomainZone $TTL IN SOA $ReverseServerName $ContactEMail $serial $refresh $retry $expire $minimum" > "$TempDir/$DomainZone"
|
||||
echo "$DomainZone $TTL IN SOA $ReverseServerName $ContactEMail $Serial $refresh $retry $expire $minimum" > "$TempDir/$DomainZone"
|
||||
echo "$DomainZone $TTL IN NS $ReverseServerName" >> "$TempDir/$DomainZone"
|
||||
for ForwardZoneFile in $(ls $TempDir)
|
||||
do
|
||||
|
@ -61,7 +61,7 @@ do
|
|||
i=0
|
||||
for IP in $IPs
|
||||
do
|
||||
if validate_ipv4 $IP
|
||||
if ValidateIPv4 $IP
|
||||
then
|
||||
echo $(echo $IP | awk 'BEGIN { FS = "." } ; { print $4 "." $3 "." $2 "." $1 }')".in-addr.arpa." $TTL IN PTR ${Hosts[$i]} >> "$TempDir/$DomainZone"
|
||||
fi
|
||||
|
@ -70,14 +70,14 @@ do
|
|||
done
|
||||
|
||||
if [[ -f $ReverseZoneFile ]]; then
|
||||
oldSerial="$(GetZoneFileSerial '$ReverseZoneFile')"
|
||||
OldSerial="$(GetZoneFileSerial '$ReverseZoneFile')"
|
||||
else
|
||||
oldSerial=0
|
||||
OldSerial=0
|
||||
fi
|
||||
|
||||
if [[ $serial -gt $oldSerial ]]
|
||||
if [[ $Serial -gt $OldSerial ]]
|
||||
then
|
||||
named-compilezone -o $ReverseZoneFile $DomainZone "$TempDir/$DomainZone" >/dev/null 2>&1
|
||||
dnsreload
|
||||
DNSReload
|
||||
fi
|
||||
rm -r $TempDir
|
||||
|
|
Loading…
Reference in New Issue