v-change-web-domain-sslhome 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. # info: changing domain ssl home
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument definition
  7. user=$1
  8. domain=$(idn -t --quiet -u "$2" )
  9. domain_idn=$(idn -t --quiet -a "$domain")
  10. ssl_home=$3
  11. restart=$4
  12. # Includes
  13. source $VESTA/func/main.sh
  14. source $VESTA/func/domain.sh
  15. source $VESTA/conf/vesta.conf
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '3' "$#" 'USER DOMAIN SSL_HOME [RESTART]'
  20. is_format_valid 'user' 'domain'
  21. is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
  22. is_object_valid 'user' 'USER' "$user"
  23. is_object_unsuspended 'user' 'USER' "$user"
  24. is_object_valid 'web' 'DOMAIN' "$domain"
  25. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  26. is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
  27. #----------------------------------------------------------#
  28. # Action #
  29. #----------------------------------------------------------#
  30. # Get domain values
  31. get_domain_values 'web'
  32. old_ssl_home=$SSL_HOME
  33. SSL_HOME=$ssl_home
  34. # Parsing tpl_option
  35. case $SSL_HOME in
  36. single) new="$HOMEDIR/$user/web/$domain/public_shtml" ;
  37. old="$HOMEDIR/$user/web/$domain/public_html" ;;
  38. same) new="$HOMEDIR/$user/web/$domain/public_html" ;
  39. old="$HOMEDIR/$user/web/$domain/public_shtml" ;;
  40. *) check_args '3' "2" 'USER DOMAIN SSLHOME'
  41. esac
  42. # Changing sslhome directory
  43. replace_web_config "$WEB_SYSTEM" "$TPL.stpl"
  44. # Changing proxy vhost
  45. if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
  46. replace_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
  47. fi
  48. #----------------------------------------------------------#
  49. # Vesta #
  50. #----------------------------------------------------------#
  51. # Update config
  52. update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
  53. # Restarting web server
  54. if [ "$restart" != 'no' ]; then
  55. $BIN/v-restart-web
  56. check_result $? "Web restart failed" >/dev/null
  57. if [ ! -z "$PROXY_SYSTEM" ]; then
  58. $BIN/v-restart-proxy
  59. check_result $? "Proxy restart failed" >/dev/null
  60. fi
  61. fi
  62. # Logging
  63. log_history "changed ssl home for $domain to $ssl_home"
  64. log_event "$OK" "$ARGUMENTS"
  65. exit