forked from voc/voctomix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·114 lines (97 loc) · 1.97 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
##
## entrypoint for the docker images
if [ ! -f /.dockerenv ] && [ ! -f /.dockerinit ]; then
>&2 echo "WARNING: this script should be only run inside docker!!"
exit 1
fi
# shellcheck disable=SC2154
if [[ ! -z $gid ]] && [[ ! -z $uid ]]; then
groupmod -g "${gid}" voc
usermod -u "${uid}" -g "${gid}" voc
# check if homedir is mounted
if ! grep -q '/home/voc' /proc/mounts; then
# fixup for changed uid and gid
chown -R voc:voc /home/voc
fi
fi
start_core() {
>&2 echo "Starting VoctoMix Core"
if [[ -x /bin/gosu ]]; then
gosu voc /opt/voctomix/voctocore/voctocore.py "$@"
else
>&2 echo "no gosu binary found..."
exec su -l -c "/opt/voctomix/voctocore/voctocore.py -v" voc
fi
}
is_video_mounted() {
grep -q '/video' /proc/mounts
}
start_gui() {
>&2 echo "Starting VoctoMix GUI..."
if [[ -x /bin/gosu ]]; then
gosu voc /opt/voctomix/voctogui/voctogui.py -v
else
>&2 echo "no gosu binary found..."
exec su -l -c "/opt/voctomix/voctogui/voctogui.py -v" voc
fi
}
list_examples() {
cd example-scripts/
find -type f
}
run_example() {
if [ -z $1 ]; then
echo "no valid example!"
fi
FILENAME="example-scripts/$1"
if [[ -f ${FILENAME} ]]; then
>&2 echo "Running: ${FILENAME}"
${FILENAME}
fi
}
usage() {
cat <<-USAGE
Usage: $0 <cmd>
Program for starting voctomix
COMMANDS:
help - this text
core - starts voctomix core
gui - starts voctomix GUI
examples - lists the example scripts
console - run interactive console
scriptname.py - starts the example script named 'scriptname.py'
USAGE
}
if [[ $# -le 0 ]]; then
usage
exit 1
fi
case $1 in
help )
usage
exit 1
;;
examples )
list_examples
exit 0
;;
gui)
start_gui
exit 0
;;
core)
shift
start_core "$@"
exit 0
;;
console)
shift
bash "$@"
exit 0
;;
*)
run_example "$1"
exit 0
;;
esac