v_change_dns_domain_soa 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # info: changing dns domain soa
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. domain=$(idn -t --quiet -u "$2" )
  9. domain_idn=$(idn -t --quiet -a "$domain")
  10. soa="$3"
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_FUNC/shared_func.sh
  14. source $V_FUNC/domain_func.sh
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. # Checking arg number
  19. check_args '3' "$#" 'user domain soa'
  20. # Checking argument format
  21. format_validation 'user' 'domain' 'soa'
  22. # Checking web system is enabled
  23. is_system_enabled 'dns'
  24. # Checking user
  25. is_user_valid
  26. # Checking user is active
  27. is_user_suspended
  28. # Checking domain exist
  29. is_dns_domain_valid
  30. # Checking domain is not suspened
  31. is_domain_suspended 'dns'
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. # Get old soa
  36. old_soa=$(get_dns_domain_value '$SOA')
  37. # Changing soa
  38. update_dns_domain_value '$SOA' "$soa"
  39. # Updating zone
  40. update_domain_zone
  41. #----------------------------------------------------------#
  42. # Vesta #
  43. #----------------------------------------------------------#
  44. # Adding task to the vesta pipe
  45. restart_schedule 'dns'
  46. # Logging
  47. log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_soa"
  48. log_event 'system' "$V_EVENT"
  49. exit $OK