v_add_web_domain_elog 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/bash
  2. # info: add error logging for domain
  3. # options: user domain
  4. #
  5. # The function enables a separate ErrorLog file for a domain, accessible for
  6. # reading by users.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument defenition
  11. user=$1
  12. domain=$(idn -t --quiet -u "$2" )
  13. domain_idn=$(idn -t --quiet -a "$domain")
  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'
  24. # Checking argument format
  25. format_validation 'user' 'domain'
  26. # Checking web system is enabled
  27. is_system_enabled 'web'
  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. # Checking errorlog is not added
  37. is_web_domain_key_empty '$ELOG'
  38. #----------------------------------------------------------#
  39. # Action #
  40. #----------------------------------------------------------#
  41. # Parsing domain values
  42. get_web_domain_values
  43. tpl_file="$V_WEBTPL/apache_$TPL.tpl"
  44. conf="$V_HOME/$user/conf/httpd.conf"
  45. ELOG='yes'
  46. # Preparing domain values for the template substitution
  47. upd_web_domain_values
  48. # Recreating vhost
  49. del_web_config
  50. add_web_config
  51. # Checking ssl
  52. if [ "$SSL" = 'yes' ]; then
  53. tpl_file="$V_WEBTPL/apache_$TPL.stpl"
  54. conf="$V_HOME/$user/conf/shttpd.conf"
  55. del_web_config
  56. add_web_config
  57. fi
  58. # Checking nginx
  59. if [ ! -z "$NGINX" ]; then
  60. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
  61. conf="$V_HOME/$user/conf/nginx.conf"
  62. del_web_config
  63. add_web_config
  64. if [ "$SSL" = 'yes' ]; then
  65. proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
  66. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
  67. conf="$V_HOME/$user/conf/snginx.conf"
  68. del_web_config
  69. add_web_config
  70. fi
  71. fi
  72. #----------------------------------------------------------#
  73. # Vesta #
  74. #----------------------------------------------------------#
  75. # Adding elog in config
  76. update_web_domain_value '$ELOG' 'yes'
  77. # Adding task to the vesta pipe
  78. restart_schedule 'web'
  79. # Logging
  80. log_history "$V_EVENT" "v_delete_web_domain_elog $user $domain"
  81. log_event 'system' "$V_EVENT"
  82. exit