v-update-sys-queue 2.5 KB

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