v_suspend_web_domain 2.2 KB

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