v_suspend_web_domains 2.4 KB

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