v_delete_dns_domain_record 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. # info: delete dns record
  3. # options: user domain id
  4. #
  5. # The function for deleting a certain record of DNS zone.
  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. id=$3
  14. # Importing variables
  15. source $VESTA/conf/vars.conf
  16. source $V_CONF/vesta.conf
  17. source $V_FUNC/shared.func
  18. source $V_FUNC/domain.func
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. # Checking arg number
  23. check_args '3' "$#" 'user domain id'
  24. # Checking argument format
  25. format_validation 'user' 'domain' 'id'
  26. # Checking user
  27. is_user_valid
  28. # Checking user is active
  29. is_user_suspended
  30. # Checking domain exist
  31. is_dns_domain_valid
  32. # Checking domain is not suspened
  33. is_domain_suspended 'dns'
  34. # Checking record valid
  35. is_dns_record_valid
  36. #----------------------------------------------------------#
  37. # Action #
  38. #----------------------------------------------------------#
  39. # Deleting record
  40. conf="$V_USERS/$user/dns/$domain"
  41. rm_string=$(grep -n "^ID='$id'" $conf|cut -d : -f 1)
  42. if [ ! -z "$rm_string" ]; then
  43. sed -i "$rm_string d" $conf
  44. fi
  45. # Sorting records
  46. sort_dns_records
  47. # Updating zone
  48. update_domain_zone
  49. #----------------------------------------------------------#
  50. # Vesta #
  51. #----------------------------------------------------------#
  52. # Adding task to the vesta pipe
  53. restart_schedule 'dns'
  54. # Logging
  55. log_event 'system' "$V_EVENT"
  56. exit