v_del_dns_domain_record 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # info: deleting dns record
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. domain=$(idn -t --quiet -u "$2" )
  9. id="$3"
  10. # Importing variables
  11. source $VESTA/conf/vars.conf
  12. source $V_FUNC/shared_func.sh
  13. source $V_FUNC/domain_func.sh
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking arg number
  18. check_args '3' "$#" 'user domain id'
  19. # Checking argument format
  20. format_validation 'user' 'domain' 'id'
  21. # Checking user
  22. is_user_valid
  23. # Checking user is active
  24. is_user_suspended
  25. # Checking domain exist
  26. is_dns_domain_valid
  27. # Checking domain is not suspened
  28. is_domain_suspended 'dns'
  29. # Checking record valid
  30. is_dns_record_valid
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Deleting record
  35. conf="$V_USERS/$user/zones/$domain"
  36. rm_string=$(grep -n "^ID='$id'" $conf|cut -d : -f 1)
  37. if [ ! -z "$rm_string" ]; then
  38. sed -i "$rm_string d" $conf
  39. fi
  40. # Sorting records
  41. sort_dns_records
  42. # Updating zone
  43. update_domain_zone
  44. #----------------------------------------------------------#
  45. # Vesta #
  46. #----------------------------------------------------------#
  47. # Adding task to the vesta pipe
  48. restart_schedule 'dns'
  49. # Logging
  50. log_event 'system' "$V_EVENT"
  51. exit $OK