v-insert-dns-records 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # info: inserts dns records
  3. # options: USER DOMAIN DATA_FILE [RESTART]
  4. #
  5. # The function copy dns record to the domain conf
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. domain=$2
  12. data_file=$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 DATAFILE [RESTART]'
  21. validate_format 'user' 'domain' 'data_file'
  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. if [ -e "$data_file" ]; then
  31. mv -f $data_file $USER_DATA/dns/$domain.conf
  32. chmod 660 $USER_DATA/dns/$domain.conf
  33. fi
  34. #----------------------------------------------------------#
  35. # Vesta #
  36. #----------------------------------------------------------#
  37. # Restart named
  38. if [ "$restart" != 'no' ]; then
  39. $BIN/v-restart-dns
  40. if [ $? -ne 0 ]; then
  41. exit E_RESTART
  42. fi
  43. fi
  44. # Logging
  45. log_event "$OK" "$EVENT"
  46. exit