v-delete-web-domain-backend 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. # info: deleting web domain backend configuration
  3. # options: USER DOMAIN [RESTART]
  4. #
  5. # The function of deleting the virtualhost backend configuration.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. domain=$(idn -t --quiet -u "$2" )
  12. domain_idn=$(idn -t --quiet -a "$domain")
  13. # Includes
  14. source $VESTA/func/main.sh
  15. source $VESTA/func/domain.sh
  16. source $VESTA/conf/vesta.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '2' "$#" 'USER DOMAIN'
  21. is_format_valid 'user' 'domain'
  22. is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
  23. is_object_valid 'user' 'USER' "$user"
  24. is_object_unsuspended 'user' 'USER' "$user"
  25. is_object_valid 'web' 'DOMAIN' "$domain"
  26. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  27. #----------------------------------------------------------#
  28. # Action #
  29. #----------------------------------------------------------#
  30. # Defining pool directory
  31. if [ -d "/etc/php-fpm.d" ]; then
  32. pool="/etc/php-fpm.d"
  33. fi
  34. if [ -d "/etc/php5/fpm/pool.d" ]; then
  35. pool="/etc/php5/fpm/pool.d"
  36. fi
  37. if [ ! -e "$pool" ]; then
  38. pool=$(find /etc/php* -type d \( -name "pool.d" -o -name "*fpm.d" \))
  39. if [ ! -e "$pool" ]; then
  40. check_result $E_NOTEXIST "php-fpm pool doesn't exist"
  41. fi
  42. fi
  43. # Defining backend type
  44. backend_type="$domain"
  45. if [ "$WEB_BACKEND_POOL" = 'user' ]; then
  46. backend_type="$user"
  47. fi
  48. # Checking last webdomain
  49. if [ "$WEB_BACKEND_POOL" = 'user' ]; then
  50. domains=$(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'|wc -l)
  51. if [ "$backend" = "$user" ] && [ "$domains" -gt 1 ]; then
  52. exit
  53. fi
  54. fi
  55. # Deleting backend
  56. rm -f $pool/$backend_type.conf
  57. #----------------------------------------------------------#
  58. # Vesta #
  59. #----------------------------------------------------------#
  60. # Restarting backend server
  61. if [ "$restart" != 'no' ]; then
  62. $BIN/v-restart-web-backend
  63. check_result $? "Backend restart failed" >/dev/null
  64. fi
  65. # Logging
  66. log_history "deleting backend support for $domain"
  67. log_event "$OK" "$ARGUMENTS"
  68. exit