v_suspend_dns_domain 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. # info: suspend dns domain
  3. # options: user domain [restart]
  4. #
  5. # The function suspends a certain user's domain.
  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. restart="$3"
  14. # Includes
  15. source $VESTA/conf/vesta.conf
  16. source $VESTA/func/main.sh
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '2' "$#" 'user domain [restart]'
  21. validate_format 'user' 'domain'
  22. is_system_enabled "$DNS_SYSTEM"
  23. is_object_valid 'user' 'USER' "$user"
  24. is_object_valid 'dns' 'DOMAIN' "$domain"
  25. is_object_unsuspended 'dns' 'DOMAIN' "$domain"
  26. #----------------------------------------------------------#
  27. # Action #
  28. #----------------------------------------------------------#
  29. # Deleting domain from named.conf
  30. sed -i "/\/$domain.db\"/d" /etc/named.conf
  31. #----------------------------------------------------------#
  32. # Vesta #
  33. #----------------------------------------------------------#
  34. # Adding suspend in config
  35. update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
  36. sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf
  37. increase_user_value "$user" '$SUSPENDED_DNS'
  38. # Restart named
  39. if [ "$restart" != 'no' ]; then
  40. $BIN/v_restart_dns "$EVENT"
  41. fi
  42. # Logging
  43. log_event "$OK" "$EVENT"
  44. exit