forked from jjasghar/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_vm_tmp.sh
executable file
·49 lines (46 loc) · 1.61 KB
/
create_vm_tmp.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
#!/usr/local/bin/bash
VDI_DIR='/home/asgharje/vdi/'
UBUNTU_GOLD_VDI="ubuntu_11_10_gold.vdi"
REDHAT_GOLD_VDI="centos_6_2_gold.vdi"
HOST_NIC="em0"
echo "Name of VM"
read name_of_vm
echo "OS type (Ubuntu, RedHat_64)"
read ostype
cd $VDI_DIR
if [ "$ostype" = "Ubuntu" ]; then
echo "Cloning Ubuntu vdi"
VBoxManage clonehd $UBUNTU_GOLD_VDI ubuntu_11_10_$name_of_vm.vdi
elif [ "$ostype" = "RedHat_64" ]; then
echo "Cloning RedHat vdi"
VBoxManage clonehd $REDHAT_GOLD_VDI centos_6_2_$name_of_vm.vdi
else
clear;
echo "something broke"
fi
VBoxManage createvm --name "$name_of_vm" --ostype "$ostype" -register
echo "Adding 4gigs of memory"
VBoxManage modifyvm "$name_of_vm" --memory 4096 --boot1 dvd
echo "Adding the storage ide controller"
VBoxManage storagectl "$name_of_vm" --name "IDE Controller" --add ide
echo "Attaching vdi to storage controller"
if [ "$ostype" = "Ubuntu" ]; then
VBoxManage storageattach "$name_of_vm" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium ubuntu_11_10_$name_of_vm.vdi
fi
if [ "$ostype" = "RedHat_64" ]; then
VBoxManage storageattach "$name_of_vm" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium centos_6_2_$name_of_vm.vdi
fi
echo "Adding NIC and making it a bridge adapter"
VBoxManage modifyvm "$name_of_vm" --nic1 bridged --nictype1 82543GC --bridgeadapter1 $HOST_NIC
clear
echo ""
echo ""
echo ""
echo "Starting it in headless mode have fun!"
echo ""
echo ""
echo "Check the NIC, it could change and you'll have to edit it via the console, hence the VNC connection here in a sec"
echo ""
echo ""
VBoxHeadless -s "$name_of_vm" -n
cd $HOME