v-update-sys-queue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. # info: update system queue
  3. # options: PIPE
  4. #
  5. # example: v-update-sys-queue
  6. #
  7. # This function is responsible queue processing. Restarts of services,
  8. # scheduled backups, web log parsing and other heavy resource consuming
  9. # operations are handled by this script. It helps to optimize system behaviour.
  10. # In a nutshell Apache will be restarted only once even if 10 domains are
  11. # added or deleted.
  12. #----------------------------------------------------------#
  13. # Variables & Functions #
  14. #----------------------------------------------------------#
  15. # Argument definition
  16. queue=$1
  17. # Includes
  18. # shellcheck source=/etc/hestiacp/hestia.conf
  19. source /etc/hestiacp/hestia.conf
  20. # shellcheck source=/usr/local/hestia/func/main.sh
  21. source $HESTIA/func/main.sh
  22. # load config file
  23. source_conf "$HESTIA/conf/hestia.conf"
  24. #----------------------------------------------------------#
  25. # Verifications #
  26. #----------------------------------------------------------#
  27. check_args '1' "$#" 'QUEUE'
  28. #----------------------------------------------------------#
  29. # Action #
  30. #----------------------------------------------------------#
  31. b_task=$(ps auxf | grep -v "grep" | grep "$BIN/v-update-sys-queue backup")
  32. b_task=$(echo "$b_task" | grep -v sudo | wc -l)
  33. d_task=$(ps auxf | grep -v "grep" | grep "$BIN/v-update-sys-queue dns")
  34. d_task=$(echo "$d_task" | grep -v sudo | wc -l)
  35. if [ "$b_task" -gt 2 ] || [ "$d_task" -gt 2 ]; then
  36. exit
  37. fi
  38. # Defining pipe functions
  39. case $queue in
  40. restart) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  41. webstats) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  42. backup) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  43. disk) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  44. daily) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  45. traffic) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  46. dns-cluster) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  47. letsencrypt) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  48. *) check_args '1' '0' 'QUEUE' ;;
  49. esac
  50. #----------------------------------------------------------#
  51. # Hestia #
  52. #----------------------------------------------------------#
  53. exit