v-delete-remote-dns-domains 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # info: delete remote dns domains
  3. # options: [HOST]
  4. # The function deletes remote dns domains.
  5. #----------------------------------------------------------#
  6. # Variable&Function #
  7. #----------------------------------------------------------#
  8. # Argument definition
  9. host=$1
  10. # Includes
  11. source $VESTA/func/main.sh
  12. source $VESTA/func/remote.sh
  13. source $VESTA/conf/vesta.conf
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
  18. is_procces_running
  19. remote_dns_health_check
  20. #----------------------------------------------------------#
  21. # Action #
  22. #----------------------------------------------------------#
  23. IFS=$'\n'
  24. if [ -z $host ]; then
  25. hosts=$(cat $VESTA/conf/dns-cluster.conf)
  26. else
  27. hosts=$(grep "HOST='$host'" $VESTA/conf/dns-cluster.conf)
  28. fi
  29. # Starting cluster loop
  30. for cluster in $hosts; do
  31. # Parsing remote host parameters
  32. eval $cluster
  33. # Deleting source records
  34. cluster_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME 'no'
  35. check_result $? "$HOST connection failed (cleanup)" $E_CONNECT
  36. # Rebuilding dns zones
  37. $send_cmd v-rebuild-dns-domains $DNS_USER 'yes'
  38. check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
  39. done
  40. #----------------------------------------------------------#
  41. # Vesta #
  42. #----------------------------------------------------------#
  43. # Updating pipe
  44. pipe="$VESTA/data/queue/dns-cluster.pipe"
  45. str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
  46. if [ ! -z "$str" ]; then
  47. sed -i "$str d" $pipe
  48. fi
  49. exit