v-change-dns-domain-soa 1.9 KB

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