utilise le TTL de la zone dans le template bind

This commit is contained in:
domi 2013-07-04 08:26:19 +00:00
parent 1a7ffdfcce
commit df28b20d83
2 changed files with 22 additions and 2 deletions

View File

@ -1,4 +1,4 @@
$TTL 1D
$TTL @@ZONETTL@@
;
; BIND data file for domain @@DOMAINE@@
;

View File

@ -35,6 +35,21 @@ dns_get_serial() {
fi
}
dns_get_zonettl() {
local domain=$1
local zonettl=$(
$MYSQL_DO "SELECT zonettl FROM domaines d WHERE d.domaine='$domain';"
)
# default value
if [ "$zonettl" == "" ] ; then
zonettl="86400"
fi
if [ "$zonettl" -eq "0" ] ; then
zonettl="86400"
fi
echo $zonettl
}
dns_chmod() {
local domain=$1
chgrp bind $(dns_zone_file $domain)
@ -100,6 +115,9 @@ dns_regenerate() {
# Get the serial number if there is one
local serial=$(dns_get_serial "$domain")
# Get the zone ttl
local zonettl=$(dns_get_zonettl "$domain")
# Generate the headers with the template
local file=$(cat "$ZONE_TEMPLATE")
@ -129,7 +147,9 @@ dns_regenerate() {
s/@@DEFAULT_SECONDARY_MX@@/$DEFAULT_SECONDARY_MX/g;
s/@@DOMAINE@@/$domain/g;
s/@@SERIAL@@/$serial/g;
s/@@PUBLIC_IP@@/$PUBLIC_IP/g")
s/@@PUBLIC_IP@@/$PUBLIC_IP/g;
s/@@ZONETTL@@/$zonettl/g;
" )
# Add the manual lines
if [ -r "$zone_file" ] ; then