v-change-dns-domain-soa 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 definition
  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/func/main.sh
  18. source $VESTA/func/domain.sh
  19. source $VESTA/conf/vesta.conf
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. check_args '3' "$#" 'USER DOMAIN SOA'
  24. is_format_valid 'user' 'domain' 'soa'
  25. is_system_enabled "$DNS_SYSTEM" '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. if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
  37. update_domain_serial
  38. update_domain_zone
  39. fi
  40. # Updating dns-cluster queue
  41. if [ ! -z "$DNS_CLUSTER" ]; then
  42. # Check for first sync
  43. dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
  44. if [ -z "$dlock" ]; then
  45. cmd="$BIN/v-change-remote-dns-domain-soa $user $domain $soa"
  46. echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
  47. fi
  48. fi
  49. #----------------------------------------------------------#
  50. # Vesta #
  51. #----------------------------------------------------------#
  52. # Restarting named
  53. if [ "$restart" != 'no' ]; then
  54. $BIN/v-restart-dns
  55. check_result $? "DNS restart failed" >/dev/null
  56. fi
  57. # Logging
  58. log_history "changed soa record for $domain to $soa"
  59. log_event "$OK" "$ARGUMENTS"
  60. exit