v_add_web_domain_nginx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/bash
  2. # info: adding nginx support
  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. template=${3-default}
  11. default_extentions="jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,\
  12. pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm"
  13. extentions=${4-$default_extentions}
  14. # Importing variables
  15. source $VESTA/conf/vars.conf
  16. source $V_CONF/vesta.conf
  17. source $V_FUNC/shared.func
  18. source $V_FUNC/domain.func
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. # Checking arg number
  23. check_args '2' "$#" 'user domain [template] [extentions]'
  24. # Checking argument format
  25. format_validation 'user' 'domain' 'template' 'extentions'
  26. # Checking proxy system is enabled
  27. is_system_enabled 'proxy'
  28. # Checking user
  29. is_user_valid
  30. # Checking user is active
  31. is_user_suspended
  32. # Checking domain exist
  33. is_web_domain_valid
  34. # Checking domain is not suspened
  35. is_domain_suspended 'web'
  36. # Check nginx is not added
  37. is_web_domain_key_empty '$NGINX'
  38. # Checking template
  39. is_template_valid "proxy"
  40. #----------------------------------------------------------#
  41. # Action #
  42. #----------------------------------------------------------#
  43. # Defining domain parameters
  44. get_web_domain_values
  45. NGINX="$template"
  46. NGINX_EXT="$extentions"
  47. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
  48. conf="$V_HOME/$user/conf/nginx.conf"
  49. # Preparing domain values for the template substitution
  50. upd_web_domain_values
  51. add_web_config
  52. if [ "$SSL" = 'yes' ]; then
  53. proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
  54. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
  55. conf="$V_HOME/$user/conf/snginx.conf"
  56. add_web_config
  57. fi
  58. #----------------------------------------------------------#
  59. # Vesta #
  60. #----------------------------------------------------------#
  61. echo "NGINX=$NGINX"
  62. echo "NGINX_EXT=$NGINX_EXT"
  63. # Adding nginx params to config
  64. update_web_domain_value '$NGINX' "$NGINX"
  65. update_web_domain_value '$NGINX_EXT' "$extentions"
  66. # Adding task to the vesta pipe
  67. restart_schedule 'web'
  68. log_history "$V_EVENT" "v_del_web_domain_nginx $user $domain"
  69. log_event 'system' "$V_EVENT"
  70. exit