v_change_web_domain_sslhome 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/bash
  2. # info: changing domain ssl home
  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. tpl_option="$3"
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_FUNC/shared_func.sh
  14. source $V_FUNC/domain_func.sh
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. # Checking arg number
  19. check_args '3' "$#" 'user domain sslhome'
  20. # Checking argument format
  21. format_validation 'user' 'domain'
  22. # Checking web system is enabled
  23. is_system_enabled 'web'
  24. # Checking user
  25. is_user_valid
  26. # Checking user is active
  27. is_user_suspended
  28. # Checking domain exist
  29. is_web_domain_valid
  30. # Checking domain is not suspened
  31. is_domain_suspended 'web_domains'
  32. # Check SSL is added
  33. is_web_domain_value_exist '$SSL_CERT'
  34. #----------------------------------------------------------#
  35. # Action #
  36. #----------------------------------------------------------#
  37. # Get template name
  38. tpl_name=$(get_web_domain_value '$TPL')
  39. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  40. # Defininig config
  41. conf="$V_HOME/$user/conf/shttpd.conf"
  42. # Defining search phrase
  43. search_phrase='DocumentRoot'
  44. # Parsing tpl_option
  45. case $tpl_option in
  46. single) docroot="$V_HOME/$user/domains/$domain/public_shtml" ;;
  47. same) docroot="$V_HOME/$user/domains/$domain/public_html" ;;
  48. *) check_args '3' "2" 'user domain sslhome'
  49. esac
  50. # Defining replace string
  51. str_repl=" DocumentRoot $docroot"
  52. # Changing sslhome
  53. change_web_config
  54. # Get old sslhome value
  55. ssl_home=$(get_web_domain_value '$SSL_HOME')
  56. # Parsing old sslhome
  57. case $ssl_home in
  58. single) dirroot="$V_HOME/$user/domains/$domain/public_shtml" ;;
  59. same) dirroot="$V_HOME/$user/domains/$domain/public_html" ;;
  60. *) check_args '3' "2" 'user domain sslhome'
  61. esac
  62. # Defining search phrase
  63. search_phrase="<Directory $dirroot>"
  64. # Defining replace string
  65. str_repl=" <Directory $docroot>"
  66. # Changing sslhome directory tag
  67. change_web_config
  68. #----------------------------------------------------------#
  69. # Vesta #
  70. #----------------------------------------------------------#
  71. # Adding sslhome in config
  72. update_web_domain_value '$SSL_HOME' "$tpl_option"
  73. # Adding task to the vesta pipe
  74. restart_schedule 'web'
  75. # Logging
  76. log_history "$V_EVENT" "$V_SCRIPT $user $domain $ssl_home"
  77. log_event 'system' "$V_EVENT"
  78. exit $OK