summaryrefslogtreecommitdiff
path: root/docker-ep.sh
blob: 17b1ac46a1f7a7ca162bb2ac7110d3350a4874a6 (plain)
  1. #!/bin/bash
  2. ##
  3. ## entrypoint for the docker images
  4. if [ ! -f /.dockerenv ] && [ ! -f /.dockerinit ]; then
  5. echo "WARNING: this script should be only run 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. echo "Starting Voctomix CORE"
  22. if [ -x /bin/gosu ]; then
  23. gosu voc /opt/voctomix/voctocore/voctocore.py -v
  24. else
  25. echo "no gosu found..."
  26. exec su -l -c "/opt/voctomix/voctocore/voctocore.py -v" voc
  27. fi
  28. }
  29. function isVideoMounted() {
  30. return grep -q '/video' /proc/mounts
  31. }
  32. function startGui() {
  33. echo "Starting Voctomix GUI..."
  34. if [ -x /bin/gosu ]; then
  35. gosu voc /opt/voctomix/voctogui/voctogui.py -v
  36. else
  37. echo "no gosu found..."
  38. exec su -l -c "/opt/voctomix/voctogui/voctogui.py -v" voc
  39. fi
  40. }
  41. function listExamples() {
  42. cd example-scripts/
  43. find -type f
  44. }
  45. function runExample() {
  46. if [ -z $1 ]; then
  47. echo "no valid example! "
  48. fi
  49. FILENAME="example-scripts/$1"
  50. if [ -f ${FILENAME} ]; then
  51. echo "Running: ${FILENAME}"
  52. ${FILENAME}
  53. fi
  54. }
  55. function usage() {
  56. echo "Usage: $0 <cmd>"
  57. echo "help - this text"
  58. echo "core - starts voctomix gore"
  59. echo "gui - starts the voctomix GUI"
  60. echo "examples - lists the example scripts"
  61. echo "bash - run interactive bash"
  62. echo "scriptname.py - starts the example script named 'scriptname.py' "
  63. }
  64. if [ -z $1 ]; then
  65. usage
  66. exit
  67. fi
  68. case $1 in
  69. help )
  70. usage
  71. ;;
  72. examples )
  73. listExamples
  74. ;;
  75. gui )
  76. startGui
  77. ;;
  78. core )
  79. startCore
  80. ;;
  81. bash )
  82. shift
  83. bash $@
  84. ;;
  85. * )
  86. runExample $1
  87. ;;
  88. esac