v_change_web_domain_ip 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_CONF/vesta.conf
  14. source $V_FUNC/shared.func
  15. source $V_FUNC/domain.func
  16. source $V_FUNC/ip.func
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. # Checking arg number
  21. check_args '3' "$#" 'user domain ip'
  22. # Checking argument format
  23. format_validation 'user' 'domain' 'ip'
  24. # Checking web system is enabled
  25. is_system_enabled 'web'
  26. # Checking user
  27. is_user_valid
  28. # Checking user is active
  29. is_user_suspended
  30. # Checking domain exist
  31. is_web_domain_valid
  32. # Checking domain is not suspened
  33. is_domain_suspended 'web'
  34. # Checking ip
  35. is_ip_avalable
  36. #----------------------------------------------------------#
  37. # Action #
  38. #----------------------------------------------------------#
  39. # Define variable for replace
  40. get_web_domain_values
  41. tpl_file="$V_WEBTPL/apache_$TPL.tpl"
  42. conf="$V_HOME/$user/conf/httpd.conf"
  43. old=$IP
  44. new=$ip
  45. replace_web_config
  46. # Checking ssl
  47. if [ "$SSL" = 'yes' ]; then
  48. tpl_file="$V_WEBTPL/apache_$TPL.stpl"
  49. conf="$V_HOME/$user/conf/shttpd.conf"
  50. replace_web_config
  51. fi
  52. # Checking nginx
  53. if [ ! -z "$NGINX" ]; then
  54. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
  55. conf="$V_HOME/$user/conf/nginx.conf"
  56. replace_web_config
  57. fi
  58. # Checking nginx
  59. if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then
  60. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
  61. conf="$V_HOME/$user/conf/snginx.conf"
  62. replace_web_config
  63. fi
  64. #----------------------------------------------------------#
  65. # Vesta #
  66. #----------------------------------------------------------#
  67. # Increasing ip value
  68. increase_ip_value "$new"
  69. # Decreasing old ip value
  70. decrease_ip_value "$old"
  71. # Adding ip in config
  72. update_web_domain_value '$IP' "$new"
  73. # Adding task to the vesta pipe
  74. restart_schedule 'web'
  75. # Logging
  76. log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ip"
  77. log_event 'system' "$V_EVENT"
  78. exit