v-suspend-web-domains 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # info: suspend web domains
  3. # options: USER [RESTART]
  4. #
  5. # The function of suspending all user's sites.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. restart=$2
  12. # Includes
  13. source $VESTA/func/main.sh
  14. source $VESTA/func/domain.sh
  15. source $VESTA/conf/vesta.conf
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '1' "$#" 'USER [RESTART]'
  20. validate_format 'user'
  21. is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
  22. is_object_valid 'user' 'USER' "$user"
  23. #----------------------------------------------------------#
  24. # Action #
  25. #----------------------------------------------------------#
  26. # Starting suspend loop
  27. for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do
  28. $BIN/v-suspend-web-domain "$user" "$domain" 'no'
  29. done
  30. #----------------------------------------------------------#
  31. # Vesta #
  32. #----------------------------------------------------------#
  33. # Restart web server
  34. if [ "$restart" != 'no' ]; then
  35. $BIN/v-restart-web
  36. if [ $? -ne 0 ]; then
  37. exit E_RESTART
  38. fi
  39. $BIN/v-restart-proxy
  40. if [ $? -ne 0 ]; then
  41. exit E_RESTART
  42. fi
  43. fi
  44. # Logging
  45. log_event "$OK" "$EVENT"
  46. exit