summaryrefslogtreecommitdiff
path: root/docker-ep.sh
blob: aa8e8a218159cc4c94c74da831d1c7ba015ef18d (plain)
  1. #!/bin/bash
  2. ##
  3. ## entrypoint for the docker images
  4. groupmod -g $gid voc
  5. usermod -u $uid -g $gid voc
  6. # check if homedir is mounted
  7. if grep -q '/home/voc' /proc/mounts; then
  8. # homedir is mounted into the docker so don't touch the ownership of the files
  9. true
  10. else
  11. # fixup for changed uid and gid
  12. chown -R voc:voc /home/voc
  13. fi
  14. function startCore() {
  15. if [ -x /bin/gosu ]; then
  16. gosu voc /opt/voctomix/voctocore/voctocore.py -v
  17. else
  18. echo "no gosu found..."
  19. exec su -l -c "/opt/voctomix/voctocore/voctocore.py -v" voc
  20. fi
  21. }
  22. function isVideoMounted() {
  23. return grep -q '/video' /proc/mounts
  24. }
  25. function startGui() {
  26. if [ -x /bin/gosu ]; then
  27. gosu voc /opt/voctomix/voctocore/voctocore.py -v
  28. else
  29. echo "no gosu found..."
  30. exec su -l -c "/opt/voctomix/voctogui/voctogui.py -v" voc
  31. fi
  32. }
  33. function listExamples() {
  34. cd example-scripts/
  35. find -type f
  36. }
  37. function runExample() {
  38. if [ -z $1 ]; then
  39. echo "no valid example! "
  40. fi
  41. FILENAME="example-scripts/$1"
  42. if [ -f ${FILENAME} ]; then
  43. echo "Running: ${FILENAME}"
  44. ${FILENAME}
  45. fi
  46. }
  47. function usage() {
  48. echo "Usage: $0 <cmd>"
  49. echo "help - this text"
  50. echo "core - starts voctomix gore"
  51. echo "gui - starts the voctomix GUI"
  52. echo "examples - lists the example scripts"
  53. echo "bash - run interactive bash"
  54. echo "scriptname.py - starts the example script named 'scriptname.py' "
  55. }
  56. case $1 in
  57. help )
  58. usage
  59. ;;
  60. examples )
  61. listExamples
  62. ;;
  63. gui )
  64. startGui
  65. ;;
  66. core )
  67. startCore
  68. ;;
  69. bash )
  70. shift
  71. bash $@
  72. ;;
  73. * )
  74. runExample $1
  75. ;;
  76. esac