v_delete_web_domain_nginx 2.6 KB

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