v_delete_dns_domain_record 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. # Includes
  15. source $VESTA/conf/vesta.conf
  16. source $VESTA/func/main.sh
  17. source $VESTA/func/domain.sh
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '3' "$#" 'user domain id'
  22. validate_format 'user' 'domain' 'id'
  23. is_object_valid 'user' 'USER' "$user"
  24. is_object_unsuspended 'user' 'USER' "$user"
  25. is_object_valid 'dns' 'DOMAIN' "$domain"
  26. is_object_unsuspended 'dns' 'DOMAIN' "$domain"
  27. is_object_valid "dns/$domain" 'ID' "$id"
  28. #----------------------------------------------------------#
  29. # Action #
  30. #----------------------------------------------------------#
  31. # Deleting record
  32. sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
  33. # Updating zone
  34. update_domain_zone
  35. #----------------------------------------------------------#
  36. # Vesta #
  37. #----------------------------------------------------------#
  38. # Restart named
  39. $BIN/v_restart_dns "$EVENT"
  40. # Logging
  41. log_event "$OK" "$EVENT"
  42. exit