v-change-dns-domain-ttl 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # info: change dns domain ttl
  3. # options: USER DOMAIN TTL
  4. #
  5. # The function for chaning the time to live TTL parameter for all records.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. domain=$(idn -t --quiet -u "$2" )
  12. domain_idn=$(idn -t --quiet -a "$domain")
  13. ttl=$3
  14. restart=$4
  15. # Includes
  16. source $VESTA/conf/vesta.conf
  17. source $VESTA/func/main.sh
  18. source $VESTA/func/domain.sh
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '3' "$#" 'USER DOMAIN TTL'
  23. validate_format 'user' 'domain' 'ttl'
  24. is_system_enabled "$DNS_SYSTEM"
  25. is_object_valid 'user' 'USER' "$user"
  26. is_object_unsuspended 'user' 'USER' "$user"
  27. is_object_valid 'dns' 'DOMAIN' "$domain"
  28. is_object_unsuspended 'dns' 'DOMAIN' "$domain"
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Changing ttl
  33. update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl"
  34. # Updating zone
  35. update_domain_zone
  36. # dns-cluster
  37. if [ ! -z "$DNS_CLUSTER" ]; then
  38. cmd="v-change-remote-dns-domain-ttl $user $domain"
  39. echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
  40. fi
  41. #----------------------------------------------------------#
  42. # Vesta #
  43. #----------------------------------------------------------#
  44. # Restart named
  45. if [ "$restart" != 'no' ]; then
  46. $BIN/v-restart-dns "$EVENT"
  47. fi
  48. # Logging
  49. log_history "changed TTL for $domain to $ttl"
  50. log_event "$OK" "$EVENT"
  51. exit