v_add_web_domain_elog 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. # info: add error logging for domain
  3. # options: user domain [restart]
  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. restart="$3"
  15. # Includes
  16. source $VESTA/conf/vesta.conf
  17. source $VESTA/func/main.sh
  18. source $VESTA/func/domain.sh
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '2' "$#" 'user domain [restart]'
  23. validate_format 'user' 'domain'
  24. is_system_enabled "$WEB_SYSTEM"
  25. is_object_valid 'user' 'USER' "$user"
  26. is_object_unsuspended 'user' 'USER' "$user"
  27. is_object_valid 'web' 'DOMAIN' "$domain"
  28. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Parsing domain values
  33. get_domain_values 'web'
  34. if [ $ELOG == 'yes' ]; then
  35. exit 0
  36. fi
  37. tpl_file="$WEBTPL/apache_$TPL.tpl"
  38. conf="$HOMEDIR/$user/conf/web/httpd.conf"
  39. ELOG='yes'
  40. # Preparing domain values for the template substitution
  41. upd_web_domain_values
  42. # Recreating vhost
  43. del_web_config
  44. add_web_config
  45. # Checking ssl
  46. if [ "$SSL" = 'yes' ]; then
  47. tpl_file="$WEBTPL/apache_$TPL.stpl"
  48. conf="$HOMEDIR/$user/conf/web/shttpd.conf"
  49. del_web_config
  50. add_web_config
  51. fi
  52. # Checking nginx
  53. if [ ! -z "$NGINX" ]; then
  54. tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
  55. conf="$HOMEDIR/$user/conf/web/nginx.conf"
  56. del_web_config
  57. add_web_config
  58. if [ "$SSL" = 'yes' ]; then
  59. tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
  60. conf="$HOMEDIR/$user/conf/web/snginx.conf"
  61. del_web_config
  62. add_web_config
  63. fi
  64. fi
  65. #----------------------------------------------------------#
  66. # Vesta #
  67. #----------------------------------------------------------#
  68. # Update config
  69. update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes'
  70. # Adding task to the vesta pipe
  71. if [ "$restart" != 'no' ]; then
  72. $BIN/v_restart_web "$EVENT"
  73. fi
  74. # Logging
  75. log_history "$EVENT"
  76. log_event "$OK" "$EVENT"
  77. exit