v-delete-remote-dns-record 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. validate_format 'user' 'domain' 'id'
  22. is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
  23. if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
  24. check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
  25. fi
  26. if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
  27. check_result $E_EXISTS "another sync process already running"
  28. fi
  29. remote_dns_health_check
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Starting cluster loop
  34. IFS=$'\n'
  35. for cluster in $(cat $VESTA/conf/dns-cluster.conf); do
  36. # Parsing remote host parameters
  37. eval $cluster
  38. # Syncing serial
  39. str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
  40. cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
  41. check_result $? "$HOST connection failed (soa sync)" $E_CONNECT
  42. # Sync domain
  43. cluster_cmd v-delete-dns-record $DNS_USER $domain $id 'no'
  44. #check_result $? "$HOST connection failed (delete)" $E_CONNECT
  45. # Rebuilding dns zone
  46. cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
  47. check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
  48. done
  49. #----------------------------------------------------------#
  50. # Vesta #
  51. #----------------------------------------------------------#
  52. # Updating pipe
  53. pipe="$VESTA/data/queue/dns-cluster.pipe"
  54. str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
  55. if [ ! -z "$str" ]; then
  56. sed -i "$str d" $pipe
  57. fi
  58. exit