v_update_sys_queue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/bash
  2. # info: updating system queue
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. pipe=$1
  8. # Importing system enviroment as we run this script
  9. # mostly by cron wich not read it by itself
  10. source /etc/profile.d/vesta.sh
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_CONF/vesta.conf
  14. source $V_FUNC/shared.func
  15. # Defining pipe functions
  16. restart_pipe() {
  17. for service in $(cat $V_QUEUE/restart.pipe |sort |uniq); do
  18. $V_BIN/v_restart_$service
  19. done
  20. echo > $V_QUEUE/restart.pipe
  21. }
  22. stats_pipe() {
  23. bash $V_QUEUE/stats.pipe
  24. }
  25. disk_pipe() {
  26. bash $V_QUEUE/disk.pipe
  27. }
  28. traff_pipe() {
  29. bash $V_QUEUE/traffic.pipe
  30. }
  31. backup_pipe() {
  32. for user in $(cat $V_QUEUE/backup.pipe |sort |uniq ); do
  33. sed -i "/^$user$/d" $V_QUEUE/backup.pipe
  34. bash $V_BIN/v_backup_user $user
  35. # Send notification to user
  36. done
  37. }
  38. #----------------------------------------------------------#
  39. # Verifications #
  40. #----------------------------------------------------------#
  41. # Checking arg number
  42. check_args '1' "$#" 'pipe'
  43. # Checking argument format
  44. format_validation 'pipe'
  45. #----------------------------------------------------------#
  46. # Action #
  47. #----------------------------------------------------------#
  48. case $pipe in
  49. restart) restart_pipe ;;
  50. stats) stats_pipe ;;
  51. backup) backup_pipe ;;
  52. disk) disk_pipe ;;
  53. traffic) traff_pipe ;;
  54. *) check_args '1' '0' 'pipe'
  55. esac
  56. #----------------------------------------------------------#
  57. # Vesta #
  58. #----------------------------------------------------------#
  59. # Logging
  60. log_event 'system' "$V_EVENT"
  61. exit