/
create-vm.sh
executable file
·65 lines (53 loc) · 1.27 KB
/
create-vm.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
#!/bin/bash
vm_name="$1"
installer_path="$2"
macinbox=$(which macinbox)
format="virtualbox"
disk=64
memory=4096
cpu=2
filesystem="APFS"
username="vagrant"
fullname="Vagrant"
password="vagrant"
echo
if [ -z "${macinbox}" ]; then
echo "[WARNING] Could not find macinbox. Attempting to install with Bundler."
bundle=$(which bundle)
if [ -z "${bundle}" ]; then
echo "[ERROR] Could not find bundle. Install macinbox using:"
echo
echo " gem install macinbox"
echo
exit 1
fi
bundle install
fi
if [ ! -d "${installer_path}" ]; then
echo "[ERROR] Could find installer at ${installer_path}."
exit 1
fi
echo "VM Name: ${vm_name}"
echo "Installer: ${installer_path}"
echo
read -p "Are these values correct? (y/N) " proceed
echo
if [[ "${proceed}" != "y" && "${proceed}" != "Y" ]]; then
echo "Exiting, since you indicated the values are incorrect."
exit 1
fi
echo "Proceeding..."
echo
sudo macinbox \
--box-format "${format}" \
--name "${vm_name}" \
--disk "${disk}" \
--memory "${memory}" \
--fstype "${filesystem}" \
--cpu "${cpu}" \
--full "${fullname}" \
--short "${username}" \
--password "${password}" \
--no-gui \
--no-auto-login \
--installer "${installer_path}"