v-unsuspend-dns-record 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash
  2. # info: unsuspend dns domain record
  3. # options: USER DOMAIN ID [RESTART]
  4. #
  5. # The function unsuspends 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/conf/vesta.conf
  17. source $VESTA/func/main.sh
  18. source $VESTA/func/domain.sh
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '3' "$#" 'USER DOMAIN ID [RESTART]'
  23. validate_format 'user' 'domain' 'id'
  24. is_system_enabled "$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. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
  33. eval $line
  34. sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
  35. # Adding record
  36. dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'"
  37. dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
  38. echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
  39. # Sorting records
  40. sort_dns_records
  41. # Updating zone
  42. update_domain_zone
  43. #----------------------------------------------------------#
  44. # Vesta #
  45. #----------------------------------------------------------#
  46. # Restart named
  47. if [ "$restart" != 'no' ]; then
  48. $BIN/v-restart-dns "$EVENT"
  49. fi
  50. # Logging
  51. log_event "$OK" "$EVENT"
  52. exit