v_change_web_domain_ip 2.2 KB

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