v-insert-dns-record 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. # info: insert dns record
  3. # options: USER DOMAIN DATA [RESTART]
  4. # labels:
  5. #
  6. # The function inserts raw dns record to the domain conf
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument definition
  11. user=$1
  12. domain=$2
  13. data=$3
  14. restart=$4
  15. # Includes
  16. # shellcheck source=/usr/local/hestia/func/main.sh
  17. source $HESTIA/func/main.sh
  18. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  19. source $HESTIA/conf/hestia.conf
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. check_args '3' "$#" 'USER DOMAIN DATA [RESTART]'
  24. is_format_valid 'user' 'domain' 'data'
  25. is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
  26. is_object_valid 'user' 'USER' "$user"
  27. is_object_unsuspended 'user' 'USER' "$user"
  28. is_object_valid 'dns' 'DOMAIN' "$domain"
  29. parse_object_kv_list "$data"
  30. # Perform verification if read-only mode is enabled
  31. check_hestia_demo_mode
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. # Insert values
  36. echo "$data" >> $USER_DATA/dns/$domain.conf
  37. #----------------------------------------------------------#
  38. # Hestia #
  39. #----------------------------------------------------------#
  40. # Restarting named
  41. $BIN/v-restart-dns $restart
  42. check_result $? "Bind restart failed" >/dev/null
  43. # Logging
  44. log_event "$OK" "$ARGUMENTS"
  45. exit