mtsm 749 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # MTM event manager
  3. # Chris Dorman (C) 2021 - CC-BY-SA 3.0
  4. wrkdir=`pwd`
  5. events="mtm_db/events"
  6. pids="mtm_db/pids"
  7. while true
  8. do
  9. cd $wrkdir/$events
  10. for x in *
  11. do
  12. if [ -f "$x" ]; then
  13. execcmd=`cat $x`
  14. rm $x
  15. cd $wrkdir
  16. `$execcmd` &
  17. cd $events
  18. fi
  19. done
  20. cd $wrkdir/$pids
  21. for y in *
  22. do
  23. if [ -f "$y" ]; then
  24. if ps -p $(cat $y) > /dev/null
  25. then
  26. cd $wrkdir/mtm_db/users
  27. echo "<div style='display:inline;color:#00ff00;'>Running</div>" > $y.status
  28. echo -n "true" > $y.statuscode
  29. else
  30. cd $wrkdir/mtm_db/users
  31. echo "<div style='display:inline;color:#ff0000;'>Stopped</div>" > $y.status
  32. echo -n "false" > $y.statuscode
  33. fi
  34. cd $wrkdir/$pids
  35. fi
  36. done
  37. sleep 1
  38. done