-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwin_home_dockerMESA.sh
executable file
·164 lines (138 loc) · 4.27 KB
/
win_home_dockerMESA.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
# Check to see we are on windows home
if [[ -f "/c/Windows/System32/BitLockerWizard.exe" ]];then
echo "Warning you are running Windows Pro instead of Windows Home"
echo "Please follow the instructions for Windows Pro"
exit 1
fi
# Check if virtulization has been enabled
if [[ ! $(systeminfo | grep -q "Virtualization Enabled In Firmware: Yes") -eq 0 ]];then
echo "Warning virtualization is not enabled"
echo "Please reboot your system and change the settings in your BIOS"
exit 1
fi
usage="$(basename "$0") [-h] [-v num] [-d let]
options:
-h show this help text
-v MESA version number. r24.03.1 (default), r23.05.1, r22.11.1, r22.05.1, r21.12.1, 15140, 12778, 12115, 11701, 11554, 11532, 10398, 10108, 10000, or 9793.
-d letter for drive to install on. Default is C."
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize variables:
version=r24.03.1
# default drive letter:
install_drive=C
while getopts "hv:d:" opt; do
case "$opt" in
h) echo "$usage"
exit
;;
v) version=$OPTARG
;;
d) install_drive=$OPTARG
;;
esac
done
shift $((OPTIND-1)) # In case I add other stuff later...
#Set to the best tag for that version number.
case "$version" in
9793) tag=9793.03
;;
10000) tag=10000.01
;;
10108) tag=10108.01
;;
10398) tag=10398.04
;;
11532) tag=11532.01
;;
11554) tag=11554.02
;;
11701) tag=11701.01
;;
12115) tag=12115.01
;;
12778) tag=12778.01
;;
15140) tag=15140.01
;;
r21.12.1) tag=r21.12.1.01
;;
r22.05.1) tag=r22.05.1.01
;;
r22.11.1) tag=r22.11.1.01
;;
r23.05.1) tag=r23.05.1.01
;;
r24.03.1) tag=r24.03.1.01
;;
esac
#echo $tag
tmp=$(command -v docker-machine)
if [[ $? != 0 ]];then
echo "Warning docker-machine not found"
echo 'Check docker-machine folder is in $PATH'
exit 1
fi
tmp=$(command -v docker)
if [[ $? != 0 ]];then
echo "Warning docker not found"
echo 'Check docker folder is in $PATH'
exit 1
fi
export DISPLAY=localhost:0.0
export MACHINE_STORAGE_PATH=${install_drive}:\\docker
echo $MACHINE_STORAGE_PATH
#Check to see if mesa-machine exists
MACHINE_EXISTS=$(docker-machine ls | grep mesa-machine -c)
# Initial VM configuration
if [ $MACHINE_EXISTS -eq 0 ]
then
# Creating a machine with 2GB of RAM and 2 CPUs
docker-machine create \
-d virtualbox \
--virtualbox-memory=2048 \
--virtualbox-cpu-count=2 \
--virtualbox-disk-size=25000 \
mesa-machine
echo "MESA MACHINE CREATED"
fi
#Setup shared folder, we delete and recrete it as its the best way to make sure it allways exists
echo "Stopping for mount point"
# Stop for mounting. Normally its allready stopped
docker-machine stop mesa-machine 2>/dev/null
# Needs a windows style path to mount.
export HERE=$(echo $PWD | sed -e 's/^\///' -e 's/\//\\/g' -e 's/^./\0:/')
export VBOX=$(find /c -name VBoxManage.exe -print -quit 2>/dev/null | head -n 1)
if [[ -z "$VBOX" ]];then
echo "Warning VBoxManage.exe not found"
echo 'Check VBoxManage.exe is installed'
exit 1
fi
# Add docker-machine mount folder
"$VBOX" \
sharedfolder add mesa-machine \
--name mesa_mount \
--hostpath "$HERE/docker_work" \
--automount 2>/dev/null
docker-machine start mesa-machine
echo "MESA MACHINE STARTED"
#Connect terminal to the docker machine to allow running docker commands.
eval "$(docker-machine env mesa-machine)"
# Construct a comand string to pass into the docker-machine
# ssh for starting the container.
START_DOCK='docker run -d --rm --name mesa_dock -p 6158:22 '
START_DOCK+='-v /mesa_mount:/home/docker/docker_work '
START_DOCK+="evbauer/mesa_lean:$tag sleep infinity"
# Needs ssh connection to run the docker command from within the VM
# for the mounting part of the command to work.
docker-machine ssh mesa-machine "$START_DOCK"
docker exec --user root mesa_dock service ssh start
ip=$(docker-machine ip mesa-machine)
# Bind port of docker container inside the machine to local port 20000
echo "password is tcuser"
ssh -Nf -L20000:localhost:6158 docker@$ip
# ssh with X11 forwarding for pgstar.
echo "password is mesa"
ssh -Y -p 20000 docker@localhost
docker kill mesa_dock
docker-machine stop mesa-machine