v-suspend-dns-record 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # info: suspend dns domain record
  3. # options: USER DOMAIN ID [RESTART]
  4. #
  5. # The function suspends a certain domain record.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. domain=$2
  12. id=$3
  13. restart=$4
  14. # Includes
  15. source $VESTA/func/main.sh
  16. source $VESTA/func/domain.sh
  17. source $VESTA/conf/vesta.conf
  18. # Additional argument formatting
  19. format_domain
  20. format_domain_idn
  21. #----------------------------------------------------------#
  22. # Verifications #
  23. #----------------------------------------------------------#
  24. check_args '3' "$#" 'USER DOMAIN ID [RESTART]'
  25. is_format_valid 'user' 'domain' 'id'
  26. is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
  27. is_object_valid 'user' 'USER' "$user"
  28. is_object_valid 'dns' 'DOMAIN' "$domain"
  29. is_object_unsuspended 'dns' 'DOMAIN' "$domain"
  30. is_object_valid "dns/$domain" 'ID' "$id"
  31. is_object_unsuspended "dns/$domain" 'ID' "$id"
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
  36. eval $line
  37. sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
  38. # Adding record
  39. dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'"
  40. dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'"
  41. echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
  42. # Sorting records
  43. sort_dns_records
  44. # Updating zone
  45. if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
  46. update_domain_serial
  47. update_domain_zone
  48. fi
  49. #----------------------------------------------------------#
  50. # Vesta #
  51. #----------------------------------------------------------#
  52. # Logging
  53. log_event "$OK" "$ARGUMENTS"
  54. exit