v_change_web_domain_ip 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. # info: changing domain ip
  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. ip="$3"
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_FUNC/shared_func.sh
  14. source $V_FUNC/domain_func.sh
  15. source $V_FUNC/ip_func.sh
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. # Checking arg number
  20. check_args '3' "$#" 'user domain ip'
  21. # Checking argument format
  22. format_validation 'user' 'domain' 'ip'
  23. # Checking web system is enabled
  24. is_system_enabled 'web'
  25. # Checking user
  26. is_user_valid
  27. # Checking user is active
  28. is_user_suspended
  29. # Checking domain exist
  30. is_web_domain_valid
  31. # Checking domain is not suspened
  32. is_domain_suspended 'web_domains'
  33. # Checking ip
  34. is_ip_avalable
  35. #----------------------------------------------------------#
  36. # Action #
  37. #----------------------------------------------------------#
  38. # Get tpl
  39. tpl_name=$(get_web_domain_value '$TPL')
  40. tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
  41. conf="$V_HOME/$user/conf/httpd.conf"
  42. old_ip=$(get_web_domain_value '$IP')
  43. # Changing ip
  44. change_domain_ip "$conf" "$domain" "$ip" "$old_ip" "$tpl_file"
  45. # Checking ssl
  46. cert=$(get_web_domain_value '$SSL_CERT')
  47. if [ ! -z "$cert" ]; then
  48. # Get tpl
  49. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  50. conf="$V_HOME/$user/conf/shttpd.conf"
  51. # Adding elog
  52. change_domain_ip "$conf" "$domain" "$ip" "$old_ip" "$tpl_file"
  53. fi
  54. #----------------------------------------------------------#
  55. # Vesta #
  56. #----------------------------------------------------------#
  57. # Increasing ip value
  58. increase_ip_value
  59. # Decreasing old ip value
  60. decrease_ip_value "$old_ip"
  61. # Adding ip in config
  62. update_web_domain_value '$IP' "$ip"
  63. # Adding task to the vesta pipe
  64. restart_schedule 'web'
  65. # Logging
  66. log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ip"
  67. log_event 'system' "$V_EVENT"
  68. exit $OK