v-change-remote-dns-domain-ttl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # info: change remote dns domain TTL
  3. # options: USER DOMAIN
  4. #
  5. # The function synchronize dns domain 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. is_format_valid 'user' 'domain'
  21. is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
  22. is_object_valid 'user' 'USER' "$user"
  23. is_object_valid 'dns' 'DOMAIN' "$domain"
  24. is_procces_running
  25. remote_dns_health_check
  26. #----------------------------------------------------------#
  27. # Action #
  28. #----------------------------------------------------------#
  29. IFS=$'\n'
  30. for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
  31. # Parsing remote host parameters
  32. eval $cluster
  33. # Syncing TTL
  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 (sync)" $E_CONNECT
  37. # Rebuilding dns zone
  38. cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
  39. check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
  40. done
  41. #----------------------------------------------------------#
  42. # Vesta #
  43. #----------------------------------------------------------#
  44. # Updating pipe
  45. pipe="$VESTA/data/queue/dns-cluster.pipe"
  46. str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
  47. if [ ! -z "$str" ]; then
  48. sed -i "$str d" $pipe
  49. fi
  50. exit