v_suspend_web_domain 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # info: suspening web domain (with ssl)
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. domain="$2"
  9. # Importing variables
  10. source $VESTA/conf/vars.conf
  11. source $V_FUNC/shared_func.sh
  12. source $V_FUNC/domain_func.sh
  13. # Defining url
  14. url="${3-$V_SUSPEND_URL}"
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. # Checking arg number
  19. check_args '2' "$#" 'user domain [suspend_url]'
  20. # Checking argument format
  21. format_validation 'user' 'domain' 'url'
  22. # Checking web system is enabled
  23. is_system_enabled 'web'
  24. # Checking user
  25. is_user_valid
  26. # Checking domain exist
  27. is_web_domain_valid
  28. # Checking domain is not suspened
  29. is_domain_suspended 'web_domains'
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Get template name
  34. tpl_name=$(get_web_domain_value '$TPL')
  35. tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
  36. # Defining config
  37. conf="$V_HOME/$user/conf/httpd.conf"
  38. # Defining search phrase
  39. search_phrase='DocumentRoot '
  40. # Defining replace string
  41. str_repl=" Redirect / http://$url/"
  42. # Suspending vhost
  43. httpd_change_config
  44. # Check ssl vhost
  45. ssl=$(get_web_domain_value '$SSL')
  46. if [ "$ssl" = 'yes' ]; then
  47. # Defining teplate name
  48. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  49. # Defining config
  50. conf="$V_HOME/$user/conf/shttpd.conf"
  51. # Reefining replace string - old str_repl contains escaped chars
  52. str_repl=" Redirect / http://$url/"
  53. # Suspending vhost
  54. httpd_change_config
  55. fi
  56. #----------------------------------------------------------#
  57. # Vesta #
  58. #----------------------------------------------------------#
  59. # Adding suspend in config
  60. update_web_domain_value '$SUSPEND' 'yes'
  61. # Adding task to the vesta pipe
  62. restart_schedule 'web'
  63. # Logging
  64. log_event 'system' "$V_EVENT"
  65. exit $OK