v_add_dns_domain_record 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. # info: adding dns domain record
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. domain=$(idn -t --quiet -u "$2" )
  9. domain_idn=$(idn -t --quiet -a "$domain")
  10. record=$(idn -t --quiet -u "$3" )
  11. rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')
  12. value=$(idn -t --quiet -u "$5" )
  13. id="$6"
  14. # Importing variables
  15. source $VESTA/conf/vars.conf
  16. source $V_FUNC/shared_func.sh
  17. source $V_FUNC/domain_func.sh
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. # Checking arg number
  22. check_args '5' "$#" 'user domain record type value [id]'
  23. # Checking argument format
  24. format_validation 'user' 'domain' 'record' 'rtype'
  25. # Checking web system is enabled
  26. is_system_enabled 'dns'
  27. # Checking user
  28. is_user_valid
  29. # Checking user is active
  30. is_user_suspended
  31. # Checking domain exist
  32. is_dns_domain_valid
  33. # Checking domain is active
  34. is_domain_suspended 'dns'
  35. # Defining if emtpy
  36. if [ -z "$id"] ; then
  37. id=$(get_next_dns_record)
  38. fi
  39. # Checking id format
  40. format_validation 'id'
  41. # Checking id
  42. is_dns_record_free
  43. #----------------------------------------------------------#
  44. # Action #
  45. #----------------------------------------------------------#
  46. # Defining zone path
  47. zone="$V_USERS/$user/zones/$domain"
  48. # Adding record
  49. dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' VALUE='$value'"
  50. dns_rec="$dns_rec SUSPEND='no' DATE='$V_DATE'"
  51. echo "$dns_rec" >> $zone
  52. # Sorting records
  53. sort_dns_records
  54. # Updating zone
  55. update_domain_zone
  56. #----------------------------------------------------------#
  57. # Vesta #
  58. #----------------------------------------------------------#
  59. # Adding task to the vesta pipe
  60. restart_schedule 'dns'
  61. # Logging
  62. log_history "$V_EVENT" "v_del_dns_domain_record $user $domain $id"
  63. log_event 'system' "$V_EVENT"
  64. exit $OK