v_delete_web_domain_alias 3.0 KB

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