v-delete-remote-dns-domain 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # info: delete remote dns domain
  3. # options: USER DOMAIN
  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. # Includes
  13. source $VESTA/func/main.sh
  14. source $VESTA/func/remote.sh
  15. source $VESTA/conf/vesta.conf
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '2' "$#" 'USER DOMAIN'
  20. validate_format 'user' 'domain'
  21. is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
  22. if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
  23. check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
  24. fi
  25. if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
  26. check_result $E_EXISTS "another sync process already running"
  27. fi
  28. remote_dns_health_check
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Starting cluster loop
  33. IFS=$'\n'
  34. for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
  35. # Parsing remote host parameters
  36. eval $cluster
  37. # Syncing domain
  38. cluster_cmd v-delete-dns-domain $DNS_USER $domain 'yes'
  39. rc=$?
  40. if [ "$rc" -ne 0 ] && [ $rc -ne 3 ]; then
  41. check_result $rc "$HOST connection failed (sync)" $E_CONNECT
  42. fi
  43. done
  44. #----------------------------------------------------------#
  45. # Vesta #
  46. #----------------------------------------------------------#
  47. # Updating pipe
  48. pipe="$VESTA/data/queue/dns-cluster.pipe"
  49. str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
  50. if [ ! -z "$str" ]; then
  51. sed -i "$str d" $pipe
  52. fi
  53. exit