-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-vm
executable file
·179 lines (168 loc) · 4.11 KB
/
create-vm
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#! /usr/bin/env bash
set -e
read -r -p "Docker username? " docker_username
read -r -s -p "Docker password? " docker_password
echo
docker login \
--username="${docker_username}" \
--password="${docker_password}"
echo "Creating the virtual machine for the model checking contest."
# Clean:
VBoxManage controlvm "mcc4mcc" \
poweroff \
|| true
VBoxManage modifyvm "mcc4mcc" \
--hdb "none" \
|| true
VBoxManage unregistervm "mcc4mcc" \
--delete \
|| true
cp "ToolSubmissionKit/mcc2018.vmdk" \
"mcc4mcc.vmdk"
# Launch the virtual machine:
VBoxManage createvm \
--name "mcc4mcc" \
--ostype "Debian_64" \
--register
VBoxManage storagectl "mcc4mcc" \
--name "IDE Controller" \
--add "ide" \
--bootable "on"
VBoxManage modifyvm "mcc4mcc" \
--description "Model Checker Collection for the Model Checking Contest" \
--memory 8192 \
--cpus 4 \
--hda "mcc4mcc.vmdk" \
--hdb "$(pwd)/ToolSubmissionKit/mcc2018-input.vmdk" \
--natpf1 ssh,tcp,,2222,,22
VBoxManage startvm "mcc4mcc" \
--type "headless"
# Find docker images:
docker images mccpetrinets/*:latest --format "{{.Repository}}:{{.Tag}}" \
> "images.txt"
# Create directory for mcc4mcc:
ssh \
-o "UserKnownHostsFile=/dev/null" \
-o "StrictHostKeyChecking=no" \
-i "ToolSubmissionKit/bk-private_key" \
-p 2222 \
root@localhost \
'bash -s' <<'EOS'
set -e
mkdir -p /usr/share/mcc4mcc
EOS
# Copy required files:
rm -rf mcc4mcc/__pycache__/
scp \
-r \
-o "UserKnownHostsFile=/dev/null" \
-o "StrictHostKeyChecking=no" \
-i "ToolSubmissionKit/bk-private_key" \
-P 2222 \
setup.py requirements.txt images.txt \
./*.p ./*.json \
mcc4mcc \
root@localhost:/usr/share/mcc4mcc/
scp \
-o "UserKnownHostsFile=/dev/null" \
-o "StrictHostKeyChecking=no" \
-i "ToolSubmissionKit/bk-private_key" \
-P 2222 \
BenchKit_head.sh \
mcc@localhost:BenchKit/
# Install dependencies:
ssh \
-o "UserKnownHostsFile=/dev/null" \
-o "StrictHostKeyChecking=no" \
-i "ToolSubmissionKit/bk-private_key" \
-p 2222 \
root@localhost \
'bash -s' <<'EOS'
set -e
echo "deb http://ftp.de.debian.org/debian testing main" \
>> /etc/apt/sources.list
echo 'APT::Default-Release "stable";' \
| tee -a /etc/apt/apt.conf.d/00local
apt-get update --yes
apt-get dist-upgrade --yes
apt-get upgrade --yes
apt-get install --yes \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg \
| apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) \
stable"
apt-get update --yes
apt-get install --yes \
-t testing \
docker-ce \
python3-pip \
python3-setuptools
adduser mcc docker
pip3 install wheel
pip3 install scipy
pip3 install /usr/share/mcc4mcc
chown -R mcc /usr/share/mcc4mcc
EOS
# shellcheck disable=SC2029
ssh \
-o "UserKnownHostsFile=/dev/null" \
-o "StrictHostKeyChecking=no" \
-i "ToolSubmissionKit/bk-private_key" \
-p 2222 \
mcc@localhost \
"DOCKER_USERNAME=${docker_username} \
DOCKER_PASSWORD=${docker_password} \
bash -s" <<"EOS"
set -e
chown -R mcc /usr/share/mcc4mcc
docker login \
--username="${DOCKER_USERNAME}" \
--password="${DOCKER_PASSWORD}"
for image in $(cat /usr/share/mcc4mcc/images.txt)
do
docker pull ${image}
done
EOS
# Stop:
ssh \
-o "UserKnownHostsFile=/dev/null" \
-o "StrictHostKeyChecking=no" \
-i "ToolSubmissionKit/bk-private_key" \
-p 2222 \
root@localhost \
'bash -s' <<"EOS"
set -e
apt-get install --yes \
zerofree
apt-get autoremove --yes
apt-get clean
rm -rf /var/lib/apt/lists/*
sync
# mount -n -o remount,ro /dev/sda1 /
# zerofree /dev/sda1
EOS
VBoxManage controlvm "mcc4mcc" \
poweroff
# rm -f "mcc4mcc.vdi"
# rm -f "mcc4mcc-2018.vmdk"
# VBoxManage clonemedium \
# --format=VDI \
# "mcc4mcc.vmdk" \
# "mcc4mcc.vdi"
# VboxManage modifymedium \
# --compact \
# "mcc4mcc.vdi"
# VBoxManage clonemedium \
# --format=VMDK \
# "mcc4mcc.vmdk" \
# "mcc4mcc-2018.vmdk"
# rm -f "mcc4mcc.vdi"
echo "The virtual machine has been generated in mcc4mcc.vmdk."