lokiRecode.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. MPATH="/Volumes/Shared/TV"
  3. if [ -n "${1}" ]; then
  4. if [ -d "${1}" ]; then
  5. MPATH="${1}"
  6. fi
  7. fi
  8. echo "Using MPATH: ${MPATH}"
  9. RUNCHECK="`ps auwx | grep xargs | grep video/findRecode0`"
  10. if [ -z "${RUNCHECK}" ]; then
  11. export NO_LAST_RECODE_FILE=1
  12. find "${MPATH}" -type d -print0 | \
  13. xargs -0 -I RPLSTR -n 1 ~/bin/video/findRecode0 RPLSTR | \
  14. xargs -0 -n 1 -t ~/bin/video/recode &
  15. RUNCHECK=$!
  16. echo "Started recoder as PID: ${RUNCHECK}"
  17. else
  18. echo 'findRecode already running:'
  19. echo "${RUNCHECK}"
  20. fi
  21. # Background this too so we can get HB fully detached
  22. (while [ 1 ]; do
  23. # Slowly
  24. for i in {1..2}; do
  25. echo
  26. sleep 5
  27. done
  28. # Grab a status
  29. HB="`ps auwx | grep -v grep | grep -i handbrake`"
  30. if [ -z "${HB}" ]; then
  31. HB="`ps awux | grep -v grep | grep -i video/findRecode`"
  32. fi
  33. if [ -z "${HB}" ]; then
  34. HB="`ps awux | grep -v grep | grep "${RUNCHECK}"`"
  35. fi
  36. # Stop when we find nothing to monitor
  37. if [ -z "${HB}" ]; then
  38. echo
  39. echo Done
  40. date
  41. echo
  42. echo
  43. exit 0
  44. fi
  45. # Display status
  46. echo "${HB}"
  47. echo
  48. done) &
  49. echo "Started monitor as PID: ${!}"
  50. exit 0