v-delete-remote-dns-record 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. # info: delete remote dns domain record
  3. # options: USER DOMAIN ID
  4. #
  5. # The function synchronize dns with the remote server.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. domain=$2
  12. id=$3
  13. # Includes
  14. source $VESTA/func/main.sh
  15. source $VESTA/func/remote.sh
  16. source $VESTA/conf/vesta.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '3' "$#" 'USER DOMAIN ID'
  21. is_format_valid 'user' 'domain' 'id'
  22. is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
  23. is_procces_running
  24. remote_dns_health_check
  25. #----------------------------------------------------------#
  26. # Action #
  27. #----------------------------------------------------------#
  28. # Starting cluster loop
  29. IFS=$'\n'
  30. for cluster in $(cat $VESTA/conf/dns-cluster.conf); do
  31. # Parsing remote host parameters
  32. eval $cluster
  33. # Syncing serial
  34. str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
  35. cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
  36. check_result $? "$HOST connection failed (soa sync)" $E_CONNECT
  37. # Sync domain
  38. cluster_cmd v-delete-dns-record $DNS_USER $domain $id 'no'
  39. #check_result $? "$HOST connection failed (delete)" $E_CONNECT
  40. # Rebuilding dns zone
  41. cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
  42. check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
  43. done
  44. #----------------------------------------------------------#
  45. # Vesta #
  46. #----------------------------------------------------------#
  47. # Updating pipe
  48. pipe="$VESTA/data/queue/dns-cluster.pipe"
  49. str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
  50. if [ ! -z "$str" ]; then
  51. sed -i "$str d" $pipe
  52. fi
  53. exit