| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #!/bin/bash
- # info: delete remote dns domain record
- # options: USER DOMAIN ID
- #
- # The function synchronize dns with the remote server.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument definition
- user=$1
- domain=$2
- id=$3
- # Includes
- source $VESTA/func/main.sh
- source $VESTA/func/remote.sh
- source $VESTA/conf/vesta.conf
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- check_args '3' "$#" 'USER DOMAIN ID'
- validate_format 'user' 'domain' 'id'
- is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
- if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
- check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
- fi
- if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
- check_result $E_EXISTS "another sync process already running"
- fi
- remote_dns_health_check
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Starting cluster loop
- IFS=$'\n'
- for cluster in $(cat $VESTA/conf/dns-cluster.conf); do
- # Parsing remote host parameters
- eval $cluster
- # Syncing serial
- str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
- cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
- check_result $? "$HOST connection failed (soa sync)" $E_CONNECT
- # Sync domain
- cluster_cmd v-delete-dns-record $DNS_USER $domain $id 'no'
- #check_result $? "$HOST connection failed (delete)" $E_CONNECT
- # Rebuilding dns zone
- cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
- check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
- done
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- # Updating pipe
- pipe="$VESTA/data/queue/dns-cluster.pipe"
- str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
- if [ ! -z "$str" ]; then
- sed -i "$str d" $pipe
- fi
- exit
|