v_change_web_domain_sslhome 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. ssl_home=$3
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_CONF/vesta.conf
  14. source $V_FUNC/shared.func
  15. source $V_FUNC/domain.func
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. # Checking arg number
  20. check_args '3' "$#" 'user domain ssl_home'
  21. # Checking argument format
  22. format_validation 'user' 'domain'
  23. # Checking web system is enabled
  24. is_system_enabled 'web'
  25. # Checking user
  26. is_user_valid
  27. # Checking user is active
  28. is_user_suspended
  29. # Checking domain exist
  30. is_web_domain_valid
  31. # Checking domain is not suspened
  32. is_domain_suspended 'web'
  33. # Check SSL is added
  34. is_web_domain_value_exist '$SSL'
  35. #----------------------------------------------------------#
  36. # Action #
  37. #----------------------------------------------------------#
  38. # Get domain values
  39. get_web_domain_values
  40. old_ssl_home=$SSL_HOME
  41. SSL_HOME=$ssl_home
  42. tpl_file="$V_WEBTPL/apache_$TPL.stpl"
  43. conf="$V_HOME/$user/conf/shttpd.conf"
  44. # Parsing tpl_option
  45. case $SSL_HOME in
  46. single) new="$V_HOME/$user/web/$domain/public_shtml" ;
  47. old="$V_HOME/$user/web/$domain/public_html" ;;
  48. same) new="$V_HOME/$user/web/$domain/public_html" ;
  49. old="$V_HOME/$user/web/$domain/public_shtml" ;;
  50. *) check_args '3' "2" 'user domain sslhome'
  51. esac
  52. # Changing sslhome directory
  53. replace_web_config
  54. # Checking nginx config
  55. if [ ! -z "$NGINX" ]; then
  56. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
  57. conf="$V_HOME/$user/conf/snginx.conf"
  58. replace_web_config
  59. fi
  60. #----------------------------------------------------------#
  61. # Vesta #
  62. #----------------------------------------------------------#
  63. # Adding sslhome in config
  64. update_web_domain_value '$SSL_HOME' "$SSL_HOME"
  65. # Adding task to the vesta pipe
  66. restart_schedule 'web'
  67. # Logging
  68. log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ssl_home"
  69. log_event 'system' "$V_EVENT"
  70. exit