From 75b40d8168f619b305a52dc90109317ea804e9d8 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Mon, 9 Mar 2015 14:56:22 +0500 Subject: [PATCH 1/5] VirtualBox convenience scripts --- scripts/build-vbox-vm | 29 ++++++++++++++++++++--------- scripts/vboxnet-dhcp | 11 +++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) create mode 100755 scripts/vboxnet-dhcp diff --git a/scripts/build-vbox-vm b/scripts/build-vbox-vm index bd508b38..dec4e1fb 100755 --- a/scripts/build-vbox-vm +++ b/scripts/build-vbox-vm @@ -1,6 +1,12 @@ #!/bin/bash +set -x -e -set -e + +## DOC: create a RancherOS VM for VirtualBox +## the VM uses 2 network interfaces: eth0 (NAT) is for Internet access +## eth1 (host-only) is for internal virtual network + +## NOTE: host-only NIC `vboxnet1` should already exist! cd $(dirname $0)/.. : RANCHER_ISO=${RANCHER_ISO:="./dist/artifacts/rancheros.iso"} @@ -19,17 +25,22 @@ fi GITSHA=$(git rev-parse --short HEAD) VM="RancherOS-${GITSHA}" -VBoxManage createhd --format vhd --filename ./dist/artifacts/$VM.vhd --size 8000 +VBoxManage createhd --format vmdk --filename ./dist/artifacts/$VM.vmdk --size 40000 VBoxManage createvm --name $VM --ostype "Linux_64" --register -VBoxManage storagectl $VM --name "IDE Controller" --add ide -VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 \ - --type hdd --medium ./dist/artifacts/$VM.vhd -VBoxManage storageattach $VM --storagectl "IDE Controller" --port 1 \ - --device 0 --type dvddrive --medium ${RANCHER_ISO} +VBoxManage storagectl $VM --name "SATA" --add sata +VBoxManage storageattach $VM --storagectl "SATA" --port 0 --type hdd --medium ./dist/artifacts/$VM.vmdk +VBoxManage storageattach $VM --storagectl "SATA" --port 1 --type dvddrive --medium ${RANCHER_ISO} -VBoxManage modifyvm $VM --memory 1024 --acpi on --boot1 dvd --boot2 disk +VBoxManage modifyvm $VM --memory 1024 --acpi on --boot1 disk --boot2 dvd +VBoxManage modifyvm $VM --rtcuseutc on VBoxManage modifyvm $VM --usb off VBoxManage modifyvm $VM --audio none -VBoxManage startvm $VM +VBoxManage modifyvm $VM --nic1 nat +VBoxManage modifyvm $VM --nictype1 virtio +VBoxManage modifyvm $VM --nic2 hostonly +VBoxManage modifyvm $VM --nictype2 virtio +VBoxManage modifyvm $VM --hostonlyadapter2 vboxnet1 + +#VBoxManage startvm $VM diff --git a/scripts/vboxnet-dhcp b/scripts/vboxnet-dhcp new file mode 100755 index 00000000..40b8b5a4 --- /dev/null +++ b/scripts/vboxnet-dhcp @@ -0,0 +1,11 @@ +#!/bin/bash +set -x -e + +## DOC: configure VirtualBox vboxnet1 host-only virtual network for use with a RancherOS VM cluster + +## NOTE: host-only NIC `vboxnet1` should already exist! + +vboxmanage hostonlyif ipconfig vboxnet1 --ip 172.17.7.1 +vboxmanage dhcpserver remove --ifname vboxnet1 && : +vboxmanage dhcpserver add --ifname vboxnet1 --ip 172.17.7.100 --netmask 255.255.255.0 \ + --lowerip 172.17.7.101 --upperip 172.17.7.254 --enable From bd5c6e08981d80186c67c62dbe0f74757887fb33 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Mon, 9 Mar 2015 19:34:24 +0500 Subject: [PATCH 2/5] VirtualBox: reduce SATA portcount to 2 --- scripts/build-vbox-vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-vbox-vm b/scripts/build-vbox-vm index dec4e1fb..dc54622c 100755 --- a/scripts/build-vbox-vm +++ b/scripts/build-vbox-vm @@ -29,7 +29,7 @@ VBoxManage createhd --format vmdk --filename ./dist/artifacts/$VM.vmdk --size 40 VBoxManage createvm --name $VM --ostype "Linux_64" --register -VBoxManage storagectl $VM --name "SATA" --add sata +VBoxManage storagectl $VM --name "SATA" --add sata --portcount 2 VBoxManage storageattach $VM --storagectl "SATA" --port 0 --type hdd --medium ./dist/artifacts/$VM.vmdk VBoxManage storageattach $VM --storagectl "SATA" --port 1 --type dvddrive --medium ${RANCHER_ISO} From 27c6f0f82226ba2818453d30c4b2c31f00517644 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Tue, 10 Mar 2015 19:31:15 +0500 Subject: [PATCH 3/5] parameterize host-only NIC and IP range --- scripts/build-vbox-vm | 5 +++-- scripts/vboxnet-dhcp | 15 +++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/build-vbox-vm b/scripts/build-vbox-vm index dc54622c..6980b0fa 100755 --- a/scripts/build-vbox-vm +++ b/scripts/build-vbox-vm @@ -1,12 +1,13 @@ #!/bin/bash set -x -e +vboxnet=vboxnet1 ## DOC: create a RancherOS VM for VirtualBox ## the VM uses 2 network interfaces: eth0 (NAT) is for Internet access ## eth1 (host-only) is for internal virtual network -## NOTE: host-only NIC `vboxnet1` should already exist! +## NOTE: host-only NIC ${vboxnet} should already exist! cd $(dirname $0)/.. : RANCHER_ISO=${RANCHER_ISO:="./dist/artifacts/rancheros.iso"} @@ -41,6 +42,6 @@ VBoxManage modifyvm $VM --nic1 nat VBoxManage modifyvm $VM --nictype1 virtio VBoxManage modifyvm $VM --nic2 hostonly VBoxManage modifyvm $VM --nictype2 virtio -VBoxManage modifyvm $VM --hostonlyadapter2 vboxnet1 +VBoxManage modifyvm $VM --hostonlyadapter2 ${vboxnet} #VBoxManage startvm $VM diff --git a/scripts/vboxnet-dhcp b/scripts/vboxnet-dhcp index 40b8b5a4..28a5d236 100755 --- a/scripts/vboxnet-dhcp +++ b/scripts/vboxnet-dhcp @@ -1,11 +1,14 @@ #!/bin/bash set -x -e -## DOC: configure VirtualBox vboxnet1 host-only virtual network for use with a RancherOS VM cluster +vboxnet=vboxnet1 +ip_prefix=172.17.7 -## NOTE: host-only NIC `vboxnet1` should already exist! +## DOC: configure VirtualBox ${vboxnet} host-only virtual network for use with a RancherOS VM cluster -vboxmanage hostonlyif ipconfig vboxnet1 --ip 172.17.7.1 -vboxmanage dhcpserver remove --ifname vboxnet1 && : -vboxmanage dhcpserver add --ifname vboxnet1 --ip 172.17.7.100 --netmask 255.255.255.0 \ - --lowerip 172.17.7.101 --upperip 172.17.7.254 --enable +## NOTE: host-only NIC ${vboxnet} should already exist! + +vboxmanage hostonlyif ipconfig ${vboxnet} --ip ${ip_prefix}.1 +vboxmanage dhcpserver remove --ifname ${vboxnet} && : +vboxmanage dhcpserver add --ifname ${vboxnet} --ip ${ip_prefix}.100 --netmask 255.255.255.0 \ + --lowerip ${ip_prefix}.101 --upperip ${ip_prefix}.254 --enable From a7ef1aac42d2a6c31986322ff384a9ab370e5d71 Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Mon, 13 Apr 2015 13:25:34 +0500 Subject: [PATCH 4/5] dump the extra NIC --- scripts/build-vbox-vm | 11 ----------- scripts/vboxnet-dhcp | 14 -------------- 2 files changed, 25 deletions(-) delete mode 100755 scripts/vboxnet-dhcp diff --git a/scripts/build-vbox-vm b/scripts/build-vbox-vm index 6980b0fa..e05a5ee7 100755 --- a/scripts/build-vbox-vm +++ b/scripts/build-vbox-vm @@ -1,14 +1,6 @@ #!/bin/bash set -x -e -vboxnet=vboxnet1 - -## DOC: create a RancherOS VM for VirtualBox -## the VM uses 2 network interfaces: eth0 (NAT) is for Internet access -## eth1 (host-only) is for internal virtual network - -## NOTE: host-only NIC ${vboxnet} should already exist! - cd $(dirname $0)/.. : RANCHER_ISO=${RANCHER_ISO:="./dist/artifacts/rancheros.iso"} @@ -40,8 +32,5 @@ VBoxManage modifyvm $VM --usb off VBoxManage modifyvm $VM --audio none VBoxManage modifyvm $VM --nic1 nat VBoxManage modifyvm $VM --nictype1 virtio -VBoxManage modifyvm $VM --nic2 hostonly -VBoxManage modifyvm $VM --nictype2 virtio -VBoxManage modifyvm $VM --hostonlyadapter2 ${vboxnet} #VBoxManage startvm $VM diff --git a/scripts/vboxnet-dhcp b/scripts/vboxnet-dhcp deleted file mode 100755 index 28a5d236..00000000 --- a/scripts/vboxnet-dhcp +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -x -e - -vboxnet=vboxnet1 -ip_prefix=172.17.7 - -## DOC: configure VirtualBox ${vboxnet} host-only virtual network for use with a RancherOS VM cluster - -## NOTE: host-only NIC ${vboxnet} should already exist! - -vboxmanage hostonlyif ipconfig ${vboxnet} --ip ${ip_prefix}.1 -vboxmanage dhcpserver remove --ifname ${vboxnet} && : -vboxmanage dhcpserver add --ifname ${vboxnet} --ip ${ip_prefix}.100 --netmask 255.255.255.0 \ - --lowerip ${ip_prefix}.101 --upperip ${ip_prefix}.254 --enable From 01ebb51b5411b30b2175f106f2c74a612ec6482c Mon Sep 17 00:00:00 2001 From: Ivan Mikushin Date: Mon, 13 Apr 2015 13:44:34 +0500 Subject: [PATCH 5/5] pwn dist dir --- scripts/build-vbox-vm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/build-vbox-vm b/scripts/build-vbox-vm index e05a5ee7..de7df721 100755 --- a/scripts/build-vbox-vm +++ b/scripts/build-vbox-vm @@ -18,6 +18,8 @@ fi GITSHA=$(git rev-parse --short HEAD) VM="RancherOS-${GITSHA}" +sudo chown -R `whoami`:`whoami` ./dist + VBoxManage createhd --format vmdk --filename ./dist/artifacts/$VM.vmdk --size 40000 VBoxManage createvm --name $VM --ostype "Linux_64" --register