v_delete_web_domain_alias 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/bash
  2. # info: deliting web domain alias
  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. dom_alias=$(idn -t --quiet -u "$3" )
  11. dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
  12. # Importing variables
  13. source $VESTA/conf/vars.conf
  14. source $V_CONF/vesta.conf
  15. source $V_FUNC/shared.func
  16. source $V_FUNC/domain.func
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. # Checking arg number
  21. check_args '3' "$#" 'user domain dom_alias'
  22. # Checking argument format
  23. format_validation 'user' 'domain' 'dom_alias'
  24. # Checking web system is enabled
  25. is_system_enabled 'web'
  26. # Checking user
  27. is_user_valid
  28. # Checking user is active
  29. is_user_suspended
  30. # Checking domain exist
  31. is_web_domain_valid
  32. # Checking domain is not suspened
  33. is_domain_suspended 'web'
  34. # Checking alias is added
  35. get_web_domain_values
  36. check_alias=$(echo ${ALIAS//,/ }|grep -w "$dom_alias")
  37. if [ -z "$check_alias" ]; then
  38. echo "Error: alias not exist"
  39. log_event 'debug' "$E_NOTEXIST $V_EVENT"
  40. exit $E_NOTEXIST
  41. fi
  42. #----------------------------------------------------------#
  43. # Action #
  44. #----------------------------------------------------------#
  45. # Defining new alias string
  46. ALIAS=$(echo "$ALIAS" |\
  47. sed -e "s/,/\n/g"|\
  48. sed -e "s/^$dom_alias$//g"|\
  49. sed -e "/^$/d"|\
  50. sed -e ':a;N;$!ba;s/\n/,/g')
  51. tpl_file="$V_WEBTPL/apache_$TPL.tpl"
  52. conf="$V_HOME/$user/conf/httpd.conf"
  53. # Preparing domain values for the template substitution
  54. upd_web_domain_values
  55. # Recreating vhost
  56. del_web_config
  57. add_web_config
  58. if [ "$SSL" = 'yes' ]; then
  59. tpl_file="$V_WEBTPL/apache_$TPL.stpl"
  60. conf="$V_HOME/$user/conf/shttpd.conf"
  61. del_web_config
  62. add_web_config
  63. fi
  64. # Checking nginx
  65. if [ ! -z "$NGINX" ]; then
  66. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
  67. conf="$V_HOME/$user/conf/nginx.conf"
  68. del_web_config
  69. add_web_config
  70. if [ "$SSL" = 'yes' ]; then
  71. proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
  72. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
  73. conf="$V_HOME/$user/conf/snginx.conf"
  74. del_web_config
  75. add_web_config
  76. fi
  77. fi
  78. #----------------------------------------------------------#
  79. # Vesta #
  80. #----------------------------------------------------------#
  81. # Deleting alias
  82. update_web_domain_value '$ALIAS' "$ALIAS"
  83. # Adding task to the vesta pipe
  84. restart_schedule 'web'
  85. # Logging
  86. log_history "$V_EVENT" "v_add_web_domain_alias $user $domain $dom_alias"
  87. log_event 'system' "$V_EVENT"
  88. exit