v_unsuspend_cron_job 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # info: unuspend cron job
  3. # options: user job [restart]
  4. #
  5. # The function unsuspen certain cron job.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. job=$2
  12. restart="${3-yes}"
  13. # Includes
  14. source $VESTA/conf/vesta.conf
  15. source $VESTA/func/shared.sh
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '2' "$#" 'user job [restart]'
  20. validate_format 'user' 'job' 'restart'
  21. is_object_valid 'user' 'USER' "$user"
  22. is_object_valid 'cron' 'JOB' "$job"
  23. is_object_suspended 'cron' 'JOB' "$job"
  24. #----------------------------------------------------------#
  25. # Action #
  26. #----------------------------------------------------------#
  27. # Unsuspending job
  28. update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'no'
  29. decrease_user_value "$user" '$SUSPENDED_CRON'
  30. # Sync system cron with user
  31. sync_cron_jobs
  32. #----------------------------------------------------------#
  33. # Vesta #
  34. #----------------------------------------------------------#
  35. # Restart crond
  36. if [ "$restart" != 'no' ]; then
  37. $BIN/v_restart_cron "$EVENT"
  38. fi
  39. # Logging
  40. log_event "$OK" "$EVENT"
  41. exit