v_delete_web_domain_nginx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. # info: deleting web domain nginx configuration
  3. # options: user domain
  4. #
  5. # The function of deleting the virtualhost nginx configuration.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. domain=$(idn -t --quiet -u "$2" )
  12. domain_idn=$(idn -t --quiet -a "$domain")
  13. # Importing variables
  14. source $VESTA/conf/vars.conf
  15. source $V_CONF/vesta.conf
  16. source $V_FUNC/shared.func
  17. source $V_FUNC/domain.func
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. # Checking arg number
  22. check_args '2' "$#" 'user domain'
  23. # Checking argument format
  24. format_validation 'user' 'domain'
  25. # Checking web system is enabled
  26. is_system_enabled 'web'
  27. # Checking user
  28. is_user_valid
  29. # Checking user is active
  30. is_user_suspended
  31. # Checking domain exist
  32. is_web_domain_valid
  33. # Checking domain is not suspened
  34. is_domain_suspended 'web'
  35. # Checking ssl is added
  36. is_web_domain_value_exist '$NGINX'
  37. #----------------------------------------------------------#
  38. # Action #
  39. #----------------------------------------------------------#
  40. # Defining domain parameters
  41. get_web_domain_values
  42. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
  43. conf="$V_HOME/$user/conf/nginx.conf"
  44. del_web_config
  45. # Checking ssl
  46. if [ "$SSL" = 'yes' ]; then
  47. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
  48. conf="$V_HOME/$user/conf/snginx.conf"
  49. del_web_config
  50. fi
  51. #----------------------------------------------------------#
  52. # Vesta #
  53. #----------------------------------------------------------#
  54. # Deleting nginx keys
  55. update_web_domain_value '$NGINX' ''
  56. update_web_domain_value '$NGINX_EXT' ''
  57. # Checking last nginx domain
  58. conf='/etc/nginx/conf.d/vesta_users.conf'
  59. last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf)
  60. last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
  61. if [ -z "$last_snginx" ]; then
  62. sed -i "/$user\/conf\/snginx.conf/d" $conf
  63. rm -f $V_HOME/$user/conf/snginx.conf
  64. fi
  65. if [ -z "$last_nginx" ]; then
  66. sed -i "/$user\/conf\/nginx.conf/d" $conf
  67. rm -f $V_HOME/$user/conf/nginx.conf
  68. fi
  69. # Adding task to the vesta pipe
  70. restart_schedule 'web'
  71. # Logging
  72. log_history "$V_EVENT" "v_add_web_domain_nginx $user $domain $NGINX $NGINX_EXT"
  73. log_event 'system' "$V_EVENT"
  74. exit