v-insert-dns-record 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. # info: insert dns record
  3. # options: USER DOMAIN DATA [RESTART]
  4. #
  5. # The function inserts raw dns record to the domain conf
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. domain=$2
  12. data=$3
  13. restart=$4
  14. # Includes
  15. source $VESTA/func/main.sh
  16. source $VESTA/conf/vesta.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '3' "$#" 'USER DOMAIN DATA [RESTART]'
  21. is_format_valid 'user' 'domain' 'data'
  22. is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
  23. is_object_valid 'user' 'USER' "$user"
  24. is_object_unsuspended 'user' 'USER' "$user"
  25. is_object_valid 'dns' 'DOMAIN' "$domain"
  26. #----------------------------------------------------------#
  27. # Action #
  28. #----------------------------------------------------------#
  29. # Insert values
  30. echo "$data" >> $USER_DATA/dns/$domain.conf
  31. #----------------------------------------------------------#
  32. # Vesta #
  33. #----------------------------------------------------------#
  34. # Restarting named
  35. $BIN/v-restart-dns $restart
  36. check_result $? "Bind restart failed" >/dev/null
  37. # Logging
  38. log_event "$OK" "$ARGUMENTS"
  39. exit