v_delete_web_domain_alias 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. # Importing variables
  17. source $VESTA/conf/vesta.conf
  18. source $VESTA/func/shared.sh
  19. source $VESTA/func/domain.sh
  20. #----------------------------------------------------------#
  21. # Verifications #
  22. #----------------------------------------------------------#
  23. # Checking arg number
  24. check_args '3' "$#" 'user domain dom_alias'
  25. # Checking argument format
  26. validate_format 'user' 'domain' 'dom_alias'
  27. # Checking web system is enabled
  28. is_system_enabled 'WEB_SYSTEM'
  29. # Checking user
  30. is_object_valid 'user' 'USER' "$user"
  31. # Checking user is active
  32. is_object_unsuspended 'user' 'USER' "$user"
  33. # Checking domain exist
  34. is_domain_valid 'web'
  35. # Checking domain is not suspened
  36. is_domain_suspended 'web'
  37. # Checking alias is added
  38. get_domain_values 'web'
  39. check_alias=$(echo ${ALIAS//,/ }|grep -w "$dom_alias")
  40. if [ -z "$check_alias" ]; then
  41. echo "Error: alias not exist"
  42. log_event 'debug' "$E_NOTEXIST $EVENT"
  43. exit $E_NOTEXIST
  44. fi
  45. #----------------------------------------------------------#
  46. # Action #
  47. #----------------------------------------------------------#
  48. # Defining new alias string
  49. ALIAS=$(echo "$ALIAS" |\
  50. sed -e "s/,/\n/g"|\
  51. sed -e "s/^$dom_alias$//g"|\
  52. sed -e "/^$/d"|\
  53. sed -e ':a;N;$!ba;s/\n/,/g')
  54. tpl_file="$WEBTPL/apache_$TPL.tpl"
  55. conf="$HOMEDIR/$user/conf/web/httpd.conf"
  56. # Preparing domain values for the template substitution
  57. upd_web_domain_values
  58. # Recreating vhost
  59. del_web_config
  60. add_web_config
  61. if [ "$SSL" = 'yes' ]; then
  62. tpl_file="$WEBTPL/apache_$TPL.stpl"
  63. conf="$HOMEDIR/$user/conf/web/shttpd.conf"
  64. del_web_config
  65. add_web_config
  66. fi
  67. # Checking nginx
  68. if [ ! -z "$NGINX" ]; then
  69. tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
  70. conf="$HOMEDIR/$user/conf/web/nginx.conf"
  71. del_web_config
  72. add_web_config
  73. if [ "$SSL" = 'yes' ]; then
  74. proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
  75. tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
  76. conf="$HOMEDIR/$user/conf/web/snginx.conf"
  77. del_web_config
  78. add_web_config
  79. fi
  80. fi
  81. #----------------------------------------------------------#
  82. # Vesta #
  83. #----------------------------------------------------------#
  84. # Deleting alias
  85. update_domain_value 'web' '$ALIAS' "$ALIAS"
  86. # Update counters
  87. decrease_user_value "$user" '$U_WEB_ALIASES'
  88. # Adding task to the vesta pipe
  89. $BIN/v_restart_web
  90. # Logging
  91. log_history "$EVENT" "v_add_web_domain_alias $user $domain $dom_alias"
  92. log_event "$OK" "$EVENT"
  93. exit