Remote DNS support

This commit is contained in:
Serghey Rodin 2014-03-23 18:49:18 +02:00
commit 311146adbc
13 changed files with 77 additions and 60 deletions

View file

@ -117,34 +117,30 @@ dns_rec="$dns_rec DATE='$DATE'"
echo "$dns_rec" >> $USER_DATA/dns.conf
chmod 660 $USER_DATA/dns.conf
# Get dns config path
if [ -e '/etc/named.conf' ]; then
dns_conf='/etc/named.conf'
# Create system configs
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
if [ -e '/etc/named.conf' ]; then
dns_conf='/etc/named.conf'
dns_group='named'
else
dns_conf='/etc/bind/named.conf'
dns_group='bind'
fi
# Adding zone in named.conf
named="zone \"$domain_idn\" {type master; file"
named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};"
echo "$named" >> $dns_conf
# Updating domain dns zone
update_domain_zone
# Set permissions
chmod 640 $conf
chown root:$dns_group $conf
fi
if [ -e '/etc/bind/named.conf' ]; then
dns_conf='/etc/bind/named.conf'
fi
# Adding zone in named.conf
named="zone \"$domain_idn\" {type master; file"
named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};"
echo "$named" >> $dns_conf
# Updating domain dns zone
update_domain_zone
# Set permissions
if [ "$DNS_SYSTEM" = 'named' ]; then
dns_group='named'
else
dns_group='bind'
fi
chmod 640 $conf
chown root:$dns_group $conf
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
cmd="$BIN/v-add-remote-dns-domain $user $domain no"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe

View file

@ -81,9 +81,11 @@ chmod 660 $zone
sort_dns_records
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)

View file

@ -41,7 +41,7 @@ is_object_unsuspended 'dns' 'DOMAIN' "$domain"
# Changing exp
update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp"
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)

View file

@ -50,9 +50,11 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip"
sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)

View file

@ -44,9 +44,11 @@ is_object_unsuspended 'dns' 'DOMAIN' "$domain"
update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa"
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)

View file

@ -53,9 +53,6 @@ for nameserver in ${ns//,/ };do
done
# Changing tpl
update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
# Adding zone to dns dir
cat $DNSTPL/$template.tpl |\
sed -e "s/%ip%/$ip/g" \
-e "s/%domain_idn%/$domain_idn/g" \
@ -66,11 +63,14 @@ cat $DNSTPL/$template.tpl |\
-e "s/%ns4%/$ns4/g" \
-e "s/%time%/$TIME/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')"
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
@ -85,6 +85,10 @@ fi
# Vesta #
#----------------------------------------------------------#
# Updating vesta config
update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
# Restart named
if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns

View file

@ -43,9 +43,11 @@ is_object_unsuspended 'dns' 'DOMAIN' "$domain"
update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl"
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)

View file

@ -77,9 +77,11 @@ echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
sort_dns_records
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)

View file

@ -50,9 +50,11 @@ sed -i "s/^ID='$id'/ID='$newid'/" $USER_DATA/dns/$domain.conf
sort_dns_records
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)

View file

@ -40,20 +40,19 @@ is_object_unsuspended 'dns' 'DOMAIN' "$domain"
records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ')
# Get dns config path
if [ -e '/etc/named.conf' ]; then
dns_conf='/etc/named.conf'
# Deleting system configs
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
if [ -e '/etc/named.conf' ]; then
dns_conf='/etc/named.conf'
else
dns_conf='/etc/bind/named.conf'
fi
sed -i "/\/$user\/conf\/dns\/$domain.db\"/d" $dns_conf
rm -f $HOMEDIR/$user/conf/dns/$domain.db
fi
if [ -e '/etc/bind/named.conf' ]; then
dns_conf='/etc/bind/named.conf'
fi
# Deleting domain in named.conf
sed -i "/\/$user\/conf\/dns\/$domain.db\"/d" $dns_conf
rm -f $HOMEDIR/$user/conf/dns/$domain.db
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
cmd="$BIN/v-delete-remote-dns-domain $user $domain"
echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe

View file

@ -44,9 +44,11 @@ is_dns_record_critical
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
# dns-cluster
# Updating dns-cluster queue
if [ ! -z "$DNS_CLUSTER" ]; then
# Check for first sync
dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)

View file

@ -53,7 +53,9 @@ echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
sort_dns_records
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
#----------------------------------------------------------#

View file

@ -52,7 +52,9 @@ echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
sort_dns_records
# Updating zone
update_domain_zone
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
update_domain_zone
fi
#----------------------------------------------------------#