v-delete-remote-dns-host 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. # info: delete remote dns host
  3. # options: HOST
  4. #
  5. # The function for deleting the remote dns host from vesta configuration.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. host=$1
  11. # Includes
  12. source $VESTA/func/main.sh
  13. source $VESTA/func/remote.sh
  14. source $VESTA/conf/vesta.conf
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. check_args '1' "$#" 'HOST'
  19. is_format_valid 'host'
  20. is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
  21. is_object_valid "../../conf/dns-cluster" 'HOST' "$host"
  22. #----------------------------------------------------------#
  23. # Action #
  24. #----------------------------------------------------------#
  25. # Deleting remote domains
  26. $BIN/v-delete-remote-dns-domains $host >>/dev/null 2>&1
  27. # Deleting server
  28. sed -i "/HOST='$host' /d" $VESTA/conf/dns-cluster.conf
  29. # Deleting DNS_CLUSTER key
  30. check_cluster=$(grep HOST $VESTA/conf/dns-cluster.conf |wc -l)
  31. if [ "$check_cluster" -eq '0' ]; then
  32. rm -f $VESTA/conf/dns-cluster.conf
  33. sed -i "/DNS_CLUSTER=/d" $VESTA/conf/vesta.conf
  34. # Delete cron job
  35. cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster"
  36. check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null)
  37. if [ ! -z "$check_cron" ]; then
  38. eval $check_cron
  39. $BIN/v-delete-cron-job admin "$JOB"
  40. fi
  41. fi
  42. #----------------------------------------------------------#
  43. # Vesta #
  44. #----------------------------------------------------------#
  45. # Logging
  46. log_history "deleted remote dns server $host" '' 'admin'
  47. log_event "$OK" "$ARGUMENTS"
  48. exit