v_delete_web_domain_alias 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. # info: delete web domain alias
  3. # options: user domain alias
  4. #
  5. # The function of deleting the alias domain (parked domain). By this call
  6. # default www aliase can be removed as well.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument defenition
  11. user=$1
  12. domain=$(idn -t --quiet -u "$2" )
  13. domain_idn=$(idn -t --quiet -a "$domain" )
  14. dom_alias=$(idn -t --quiet -u "$3" )
  15. dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
  16. # Includes
  17. source $VESTA/conf/vesta.conf
  18. source $VESTA/func/main.sh
  19. source $VESTA/func/domain.sh
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. check_args '3' "$#" 'user domain dom_alias'
  24. validate_format 'user' 'domain' 'dom_alias'
  25. is_system_enabled 'WEB_SYSTEM'
  26. is_object_valid 'user' 'USER' "$user"
  27. is_object_unsuspended 'user' 'USER' "$user"
  28. is_object_valid 'web' 'DOMAIN' "$domain"
  29. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  30. get_domain_values 'web'
  31. if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then
  32. echo "Error: alias $dom_alias not exist"
  33. log_event "$E_NOTEXIST" "$EVENT"
  34. exit $E_NOTEXIST
  35. fi
  36. #----------------------------------------------------------#
  37. # Action #
  38. #----------------------------------------------------------#
  39. # Defining new alias string
  40. ALIAS=$(echo "$ALIAS" |\
  41. sed -e "s/,/\n/g"|\
  42. sed -e "s/^$dom_alias$//g"|\
  43. sed -e "/^$/d"|\
  44. sed -e ':a;N;$!ba;s/\n/,/g')
  45. tpl_file="$WEBTPL/apache_$TPL.tpl"
  46. conf="$HOMEDIR/$user/conf/web/httpd.conf"
  47. # Preparing domain values for the template substitution
  48. upd_web_domain_values
  49. # Recreating vhost
  50. del_web_config
  51. add_web_config
  52. if [ "$SSL" = 'yes' ]; then
  53. tpl_file="$WEBTPL/apache_$TPL.stpl"
  54. conf="$HOMEDIR/$user/conf/web/shttpd.conf"
  55. del_web_config
  56. add_web_config
  57. fi
  58. # Checking nginx
  59. if [ ! -z "$NGINX" ]; then
  60. tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
  61. conf="$HOMEDIR/$user/conf/web/nginx.conf"
  62. del_web_config
  63. add_web_config
  64. if [ "$SSL" = 'yes' ]; then
  65. proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
  66. tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
  67. conf="$HOMEDIR/$user/conf/web/snginx.conf"
  68. del_web_config
  69. add_web_config
  70. fi
  71. fi
  72. #----------------------------------------------------------#
  73. # Vesta #
  74. #----------------------------------------------------------#
  75. # Update config
  76. update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
  77. # Update counters
  78. decrease_user_value "$user" '$U_WEB_ALIASES'
  79. # Restart web server
  80. $BIN/v_restart_web "$EVENT"
  81. # Logging
  82. log_history "$EVENT"
  83. log_event "$OK" "$EVENT"
  84. exit