Created
October 28, 2015 15:08
-
-
Save mkouhei/586a30e88ef449b12676 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh -e | |
| test -z $1 && exit 1 | |
| name=$1 | |
| cpus=$(( $(sysctl -n hw.ncpu) / 2)) | |
| mems=$(( $(sysctl -n hw.memsize) / 1024 ** 2 / 2)) | |
| #iso=debian-testing-amd64-netinst.iso | |
| iso=debian-8.2.0-amd64-netinst.iso | |
| #preseed="testing-preseed.txt" | |
| preseed="jessie-preseed.txt" | |
| basepath=${HOME}/VirtualBox\ VMs/${name} | |
| diskpath="${basepath}/${name}.vdi" | |
| download() { | |
| test ! -f $iso && curl -C - -L -O http://cdimage.debian.org/cdimage/weekly-builds/amd64/iso-cd/${iso} | |
| test ! -f $preseed && curl https://www.debian.org/releases/jessie/example-preseed.txt -o "${preseed}" | |
| } | |
| createVM() { | |
| VBoxManage list vms | grep -qw $name || VBoxManage createvm --name $name --register | |
| VBoxManage modifyvm $name \ | |
| --ostype Debian_64 \ | |
| --memory $mems \ | |
| --vram 128 \ | |
| --acpi on \ | |
| --ioapic on \ | |
| --hpet off \ | |
| --paravirtprovider kvm \ | |
| --hwvirtex on \ | |
| --nestedpaging on \ | |
| --largepages on \ | |
| --vtxvpid on \ | |
| --vtxux on \ | |
| --pae off \ | |
| --longmode on \ | |
| --cpuid-portability-level 0 \ | |
| --cpus $cpus \ | |
| --cpuexecutioncap 100 \ | |
| --rtcuseutc on \ | |
| --monitorcount 1 \ | |
| --accelerate3d on \ | |
| --accelerate2dvideo off \ | |
| --firmware bios \ | |
| --chipset piix3 \ | |
| --boot1 floppy \ | |
| --boot2 dvd \ | |
| --boot3 disk \ | |
| --boot4 none \ | |
| --nic1 nat \ | |
| --nictype1 virtio \ | |
| --cableconnected1 on \ | |
| --nictrace1 off \ | |
| --nicbootprio1 0 \ | |
| --nicpromisc1 deny \ | |
| --macaddress1 auto \ | |
| --mouse usbmultitouch \ | |
| --keyboard ps2 \ | |
| --audio coreaudio \ | |
| --audiocontroller ac97 \ | |
| --audiocodec ad1980 \ | |
| --clipboard bidirectional \ | |
| --draganddrop disabled \ | |
| --vrde off \ | |
| --usb on \ | |
| --usbehci on \ | |
| --snapshotfolder default \ | |
| --tracing-enabled off \ | |
| --autostart-enabled off \ | |
| --autostart-delay 0 \ | |
| --videocap off \ | |
| --defaultfrontend default | |
| } | |
| createStorage() { | |
| test ! -f "$diskpath" && VBoxManage list hdds | grep -qw "$diskpath" || VBoxManage createmedium disk --filename "$diskpath" \ | |
| --size $(( 200 * 1024 )) \ | |
| --format VDI \ | |
| --variant Standard | |
| VBoxManage storagectl $name --name IDE --add ide --controller PIIX4 --portcount 2 --hostiocache on | |
| VBoxManage storagectl $name --name SATA --add sata --controller IntelAHCI --portcount 2 | |
| #VBoxManage storageattach $name --storagectl IDE --port 1 --type dvddrive --device 0 --medium emptydrive | |
| VBoxManage storageattach $name --storagectl IDE --port 1 --type dvddrive --device 0 --medium $iso | |
| VBoxManage storageattach $name --storagectl SATA --port 0 --type hdd --medium "$diskpath" | |
| } | |
| installOS() { | |
| VBoxManage startvm $name --type gui | |
| } | |
| echo "### start httpd ###" | |
| python -m SimpleHTTPServer & | |
| httpd_pid=$! | |
| download | |
| createVM | |
| createStorage | |
| installOS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment