1
0
mirror of https://github.com/myvesta/vesta.git synced 2025-03-11 03:52:44 -07:00
myvesta/bin/v-sync-dns-cluster

88 lines
2.6 KiB
Plaintext
Raw Permalink Normal View History

2013-05-28 16:09:07 +03:00
#!/bin/bash
# info: synchronize dns domains
2013-05-29 14:20:05 +03:00
# options: HOST
2013-05-28 16:09:07 +03:00
# The function synchronize all dns domains.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2013-05-29 14:20:05 +03:00
host=$1
2013-05-28 16:09:07 +03:00
# Includes
source $VESTA/func/main.sh
source $VESTA/func/remote.sh
source $VESTA/conf/vesta.conf
2013-05-28 16:09:07 +03:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
2013-05-29 12:39:50 +03:00
is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
2016-08-25 19:45:37 +03:00
is_procces_running
2015-10-21 15:54:07 +03:00
remote_dns_health_check 'no_email'
2013-05-28 16:09:07 +03:00
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
2015-10-21 15:54:07 +03:00
# Selecting remote hosts
2013-05-28 16:09:07 +03:00
IFS=$'\n'
2013-05-29 14:20:05 +03:00
if [ -z $host ]; then
2015-10-21 15:54:07 +03:00
hosts=$(cat $VESTA/conf/dns-cluster.conf |grep "SUSPENDED='no'")
2013-05-29 14:20:05 +03:00
else
hosts=$(grep "HOST='$host'" $VESTA/conf/dns-cluster.conf)
fi
2013-05-28 16:09:07 +03:00
# Starting cluster loop
2015-10-21 15:54:07 +03:00
for cluster in $hosts; do
2013-05-28 16:09:07 +03:00
2015-10-21 15:54:07 +03:00
# Parsing host values
eval $cluster
# Wiping remote domains
cluster_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME no
check_result $? "$HOST connection failed" $E_CONNECT
2013-05-28 16:09:07 +03:00
2015-10-21 15:54:07 +03:00
# Syncing user domains
user_list=$(ls -d $VESTA/data/users/*/ | sed "s#$VESTA/data/users/##" | sed s"/.$//" | grep -v "dns-cluster")
2015-10-21 15:54:07 +03:00
for user in $user_list; do
2013-05-28 16:09:07 +03:00
for str in $(cat $VESTA/data/users/$user/dns.conf); do
2015-10-21 15:54:07 +03:00
# Syncing domain index
2013-05-28 16:09:07 +03:00
eval $str
2015-10-21 15:54:07 +03:00
cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME ' ' no
check_result $? "$HOST connection failed" $E_CONNECT
# Syncing domain records
tmp_file="/tmp/vst-sync.$DOMAIN"
cluster_file $USER_DATA/$user/dns/$DOMAIN.conf $tmp_file
check_result $? "$HOST connection failed" $E_CONNECT
cluster_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp_file 'no'
check_result $? "$HOST connection failed" $E_CONNECT
2013-05-28 16:09:07 +03:00
done
done
2015-10-21 15:54:07 +03:00
# Rebuilding dns zones
cluster_cmd v-rebuild-dns-domains $DNS_USER
check_result $? "$TYPE connection to $HOST failed" $E_CONNECT
2013-05-28 16:09:07 +03:00
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
2015-10-21 15:54:07 +03:00
# Flushing dns-cluster queue
rm -f $VESTA/data/queue/dns-cluster.pipe
touch $VESTA/data/queue/dns-cluster.pipe
chmod 660 $VESTA/data/queue/dns-cluster.pipe
2013-05-28 16:09:07 +03:00
exit