v_delete_dns_domain_record 1.7 KB

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