v-update-sys-queue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. # shellcheck source=/usr/local/hestia/func/main.sh
  23. source $HESTIA/func/main.sh
  24. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  25. source $HESTIA/conf/hestia.conf
  26. # Export PATH for cron
  27. PATH=$PATH:$BIN
  28. #----------------------------------------------------------#
  29. # Verifications #
  30. #----------------------------------------------------------#
  31. check_args '1' "$#" 'QUEUE'
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. b_task=$(ps auxf |grep -v "grep" |grep "$HESTIA/bin/v-update-sys-queue backup")
  36. b_task=$(echo "$b_task" |grep -v sudo |wc -l)
  37. d_task=$(ps auxf |grep -v "grep" |grep "$HESTIA/bin/v-update-sys-queue dns")
  38. d_task=$(echo "$d_task" |grep -v sudo |wc -l)
  39. if [ "$b_task" -gt 2 ] || [ "$d_task" -gt 2 ]; then
  40. exit
  41. fi
  42. # Defining pipe functions
  43. case $queue in
  44. restart) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1;;
  45. webstats) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  46. backup) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  47. disk) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1;;
  48. daily) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1;;
  49. traffic) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1;;
  50. dns-cluster) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  51. letsencrypt) bash $HESTIA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
  52. *) check_args '1' '0' 'QUEUE' ;;
  53. esac
  54. #----------------------------------------------------------#
  55. # Hestia #
  56. #----------------------------------------------------------#
  57. # No Logging
  58. #log_event "$OK" "$ARGUMENTS"
  59. exit