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