v_del_dns_domain_record 1.7 KB

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