v-suspend-dns-record 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 defenition
  10. user=$1
  11. domain=$(idn -t --quiet -u "$2" )
  12. domain_idn=$(idn -t --quiet -a "$domain")
  13. id=$3
  14. restart="$4"
  15. # Includes
  16. source $VESTA/func/main.sh
  17. source $VESTA/func/domain.sh
  18. source $VESTA/conf/vesta.conf
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '3' "$#" 'USER DOMAIN ID [RESTART]'
  23. validate_format 'user' 'domain' 'id'
  24. is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
  25. is_object_valid 'user' 'USER' "$user"
  26. is_object_valid 'dns' 'DOMAIN' "$domain"
  27. is_object_unsuspended 'dns' 'DOMAIN' "$domain"
  28. is_object_valid "dns/$domain" 'ID' "$id"
  29. is_object_unsuspended "dns/$domain" 'ID' "$id"
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
  34. eval $line
  35. sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
  36. # Adding record
  37. dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'"
  38. dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'"
  39. echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
  40. # Sorting records
  41. sort_dns_records
  42. # Updating zone
  43. update_domain_zone
  44. #----------------------------------------------------------#
  45. # Vesta #
  46. #----------------------------------------------------------#
  47. # Restart named
  48. #if [ "$restart" != 'no' ]; then
  49. # $BIN/v-restart-dns
  50. # if [ $? -ne 0 ]; then
  51. # exit E_RESTART
  52. # fi
  53. #fi
  54. # Logging
  55. log_event "$OK" "$EVENT"
  56. exit