v_update_sys_queue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.d/vesta.sh
  18. # Importing variables
  19. source $VESTA/conf/vesta.conf
  20. source $VESTA/func/shared.sh
  21. # Export PATH for cron
  22. PATH=$PATH:$BIN
  23. # Defining pipe functions
  24. restart_pipe() {
  25. bash $VESTA/data/queue/restart.pipe
  26. rm $VESTA/data/queue/restart.pipe
  27. touch $VESTA/data/queue/restart.pipe
  28. }
  29. stats_pipe() {
  30. bash $VESTA/data/queue/stats.pipe
  31. }
  32. disk_pipe() {
  33. bash $VESTA/data/queue/disk.pipe
  34. }
  35. traff_pipe() {
  36. bash $VESTA/data/queue/traffic.pipe
  37. }
  38. backup_pipe() {
  39. bash $VESTA/data/queue/backup.pip
  40. }
  41. #----------------------------------------------------------#
  42. # Verifications #
  43. #----------------------------------------------------------#
  44. # Checking arg number
  45. check_args '1' "$#" 'queue'
  46. #----------------------------------------------------------#
  47. # Action #
  48. #----------------------------------------------------------#
  49. case $queue in
  50. restart) restart_pipe ;;
  51. stats) stats_pipe ;;
  52. backup) backup_pipe ;;
  53. disk) disk_pipe ;;
  54. traffic) traff_pipe ;;
  55. *) check_args '1' '0' 'queue'
  56. esac
  57. #----------------------------------------------------------#
  58. # Vesta #
  59. #----------------------------------------------------------#
  60. # Logging
  61. log_event "$OK" "$EVENT"
  62. exit