v-suspend-dns-record 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. domain_idn="$domain"
  15. if [[ "$domain" = *[![:ascii:]]* ]]; then
  16. domain_idn=$(idn -t --quiet -a $domain)
  17. fi
  18. # Includes
  19. source $VESTA/func/main.sh
  20. source $VESTA/func/domain.sh
  21. source $VESTA/conf/vesta.conf
  22. #----------------------------------------------------------#
  23. # Verifications #
  24. #----------------------------------------------------------#
  25. check_args '3' "$#" 'USER DOMAIN ID [RESTART]'
  26. is_format_valid 'user' 'domain' 'id'
  27. is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
  28. is_object_valid 'user' 'USER' "$user"
  29. is_object_valid 'dns' 'DOMAIN' "$domain"
  30. is_object_unsuspended 'dns' 'DOMAIN' "$domain"
  31. is_object_valid "dns/$domain" 'ID' "$id"
  32. is_object_unsuspended "dns/$domain" 'ID' "$id"
  33. #----------------------------------------------------------#
  34. # Action #
  35. #----------------------------------------------------------#
  36. line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
  37. eval $line
  38. sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
  39. # Adding record
  40. dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'"
  41. dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'"
  42. echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
  43. # Sorting records
  44. sort_dns_records
  45. # Updating zone
  46. if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
  47. update_domain_serial
  48. update_domain_zone
  49. fi
  50. #----------------------------------------------------------#
  51. # Vesta #
  52. #----------------------------------------------------------#
  53. # Logging
  54. log_event "$OK" "$ARGUMENTS"
  55. exit