v-update-sys-queue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # info: update system queue
  3. # options: PIPE
  4. #
  5. # This function is responsible queue processing. Restarts of services,
  6. # scheduled backups, web log parsing and other heavy resource consuming
  7. # operations are handled by this script. It helps to optimize system behaviour.
  8. # In a nutshell Apache will be restarted only once even if 10 domains are
  9. # added or deleted.
  10. #----------------------------------------------------------#
  11. # Variable&Function #
  12. #----------------------------------------------------------#
  13. # Argument definition
  14. queue=$1
  15. # Importing system environment as we run this script
  16. # mostly by cron wich not read it by itself
  17. source /etc/profile
  18. # Includes
  19. source $VESTA/func/main.sh
  20. source $VESTA/conf/vesta.conf
  21. # Export PATH for cron
  22. PATH=$PATH:$BIN
  23. #----------------------------------------------------------#
  24. # Verifications #
  25. #----------------------------------------------------------#
  26. check_args '1' "$#" 'QUEUE'
  27. #----------------------------------------------------------#
  28. # Action #
  29. #----------------------------------------------------------#
  30. b_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue backup")
  31. b_task=$(echo "$b_task" |grep -v sudo |wc -l)
  32. d_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue dns")
  33. d_task=$(echo "$d_task" |grep -v sudo |wc -l)
  34. if [ "$b_task" -gt 2 ] || [ "$d_task" -gt 2 ]; then
  35. exit
  36. fi
  37. # Defining pipe functions
  38. case $queue in
  39. restart) bash $VESTA/data/queue/$queue.pipe ;;
  40. webstats) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  41. backup) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  42. disk) bash $VESTA/data/queue/$queue.pipe ;;
  43. traffic) bash $VESTA/data/queue/$queue.pipe ;;
  44. dns-cluster) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  45. *) check_args '1' '0' 'QUEUE' ;;
  46. esac
  47. #----------------------------------------------------------#
  48. # Vesta #
  49. #----------------------------------------------------------#
  50. # No Logging
  51. #log_event "$OK" "$ARGUMENTS"
  52. exit