forked from boxcutter/windows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-box.sh
executable file
·38 lines (30 loc) · 875 Bytes
/
test-box.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
#!/bin/bash -eux
create_vagrantfile_linux() {
vagrant plugin list | grep vagrant-serverspec && echo "vagrant-serverspec installed" || vagrant plugin install vagrant-serverspec
cat << EOF > $tmp_path/Vagrantfile
Vagrant.configure('2') do |config|
config.vm.box = '$box_name'
config.vm.provision :serverspec do |spec|
spec.pattern = '$test_src_path'
end
end
EOF
}
box_path=$1
box_provider=$2
vagrant_provider=$3
test_src_path=$4
box_filename=$(basename "${box_path}")
box_name=${box_filename%.*}
tmp_path=/tmp/boxtest
rm -rf ${tmp_path}
vagrant box remove ${box_name} --provider ${box_provider} 2>/dev/null || true
vagrant box add ${box_name} ${box_path}
mkdir -p ${tmp_path}
pushd ${tmp_path}
create_vagrantfile_linux
VAGRANT_LOG=warn vagrant up --provider ${vagrant_provider}
sleep 10
vagrant destroy -f
popd
vagrant box remove ${box_name} --provider ${box_provider}