This repository has been archived by the owner on Jan 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mac-gradio-docker.sh
executable file
·65 lines (59 loc) · 1.75 KB
/
mac-gradio-docker.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
#!/bin/bash
VOL=$1
VMHOSTLOC=$(docker-machine inspect gnuradio --format {{.Driver.HostOnlyCIDR}}|cut -d'/' -f1)
AUDIOARG="-e PULSE_SERVER=$VMHOSTLOC"
X11ARG="-e DISPLAY=$VMHOSTLOC:0"
X11TMP="-v /tmp/.X11-unix:/tmp/.X11-unix"
PULSECOOKIE="-v $HOME/.config/pulse/:/root/.config/pulse/"
DHO="-e HOME=/home/gnuradio"
function cleanup {
eval $(docker-machine env -u)
if [[ $NOEXIT == "" ]]; then
docker-machine stop gnuradio
fi
}
function usage {
printf "Usage: ./macrunner.sh [--no-out|--gui] [--no-stop] <home volume>\n\t./macrunner.sh [--setup]\n\n\t--setup: run vm setup and exit\n\t--no-out: run docker without gui or sound\n\t--no-stop: don't stop vm when container exits\n\t--gui: only launch gui\n"
}
if [[ "$#" -lt 1 || "$#" -gt 4 ]]; then
usage
exit
fi
trap cleanup EXIT
while [[ ${1:0:1} == "-" ]]; do
case $1 in
--setup)
docker-machine create --driver virtualbox gnuradio
docker-machine stop gnuradio
trap - EXIT
vboxmanage modifyvm gnuradio --usbxhci on
exit
;;
--no-out)
VOL="$2"
AUDIOARG=""
X11ARG=""
X11TMP=""
PULSECOOKIE=""
;;
--gui)
VOL="$2"
ENTRYPOINT="--entrypoint=$1"
;;
--no-stop)
NOEXIT="t"
;;
*)
usage
exit
;;
esac
shift
done
pactl list>/dev/null 2>&1
if [[ $PULSECOOKIE != "" && $? -ne 0 ]]; then
xhost +>/dev/null 2>&1
fi
docker-machine start gnuradio
eval $(docker-machine env gnuradio)
docker run -it --rm $AUDIOARG $X11ARG $X11TMP $PULSECOOKIE $ENTRYPOINT $DHO -v $1:/home/gnuradio -u 0 --privileged rkinsey/gnuradio