v-update-sys-queue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 defenition
  14. queue=$1
  15. # Importing system enviroment as we run this script
  16. # mostly by cron wich not read it by itself
  17. source /etc/profile
  18. # Includes
  19. source $VESTA/conf/vesta.conf
  20. source $VESTA/func/main.sh
  21. # Export PATH for cron
  22. PATH=$PATH:$BIN
  23. #----------------------------------------------------------#
  24. # Verifications #
  25. #----------------------------------------------------------#
  26. check_args '1' "$#" 'QUEUE'
  27. b_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue backup")
  28. b_task=$(echo "$b_task" |grep -v sudo |wc -l)
  29. if [ "$b_task" -gt 2 ]; then
  30. exit
  31. fi
  32. #----------------------------------------------------------#
  33. # Action #
  34. #----------------------------------------------------------#
  35. # Defining pipe functions
  36. case $queue in
  37. restart) bash $VESTA/data/queue/restart.pipe;
  38. rm $VESTA/data/queue/restart.pipe;
  39. touch $VESTA/data/queue/restart.pipe;;
  40. webstats) bash $VESTA/data/queue/webstats.pipe > /dev/null 2>&1 ;;
  41. backup) bash $VESTA/data/queue/backup.pipe > /dev/null 2>&1 ;;
  42. disk) bash $VESTA/data/queue/disk.pipe;;
  43. traffic) bash $VESTA/data/queue/traffic.pipe;;
  44. *) check_args '1' '0' 'QUEUE'
  45. esac
  46. #----------------------------------------------------------#
  47. # Vesta #
  48. #----------------------------------------------------------#
  49. # No Logging
  50. #log_event "$OK" "$EVENT"
  51. exit