Created
April 5, 2016 05:21
-
-
Save malandro-sv/c97f9518f9c5a74eaccc3e91a413f4fa to your computer and use it in GitHub Desktop.
Simple Automated VirtualBox Headless setup via Bash.
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/bash | |
| #will create an empty vbox. | |
| function pause(){ | |
| read -p "$*" | |
| } | |
| echo 'Will create a vbox now c:' | |
| pause 'Press Enter to continue... ' | |
| read -p 'Enter your Vbox name: ' -e vname | |
| echo $'The name you\'ve chosen for your Vbox is "'$vname'".' | |
| pause 'Press Enter to continue, Ctrl^C to Cancel...' | |
| echo | |
| vboxmanage createvm \ | |
| --name $vname --register && | |
| pause; echo; | |
| read -p 'Select the number of CPU cores | |
| you want to assign to "'$vname'" [1-4]: ' -e $cores && | |
| read -p $'Choose the amount of RAM to assign to '$vname': ' -e $RAM && | |
| read -p $'Select NIC device [1-9] for '$vname': ' -e $NIC && | |
| vboxmanage modifyvm $vname \ | |
| --ostype ArchLinux_64 \ | |
| --acpi on --cpus $cores \ | |
| --nic hostonly \ | |
| --vrde on --memory $RAM \ | |
| --boot3 none \ | |
| --boot2 none && | |
| echo 'Will show VM info now:' | |
| vboxmanage showvminfo $vname | |
| sleep 2; pause; echo && | |
| echo 'Will create && format \ | |
| drives now...' | |
| vboxmanage createmedium disk \ | |
| --filename $vname.vdi --size 1000 && | |
| vboxmanage storagectl $vname \ | |
| --name 'sata' \ | |
| --add sata \ | |
| --bootable on && | |
| vboxmanage storageattach $vname \ | |
| --storagectl 'sata' \ | |
| --port 0 --device 0 --type hdd \ | |
| --medium $vname.vdi && | |
| vboxmanage storageattach $vname \ | |
| --storagectl 'sata' port 1 \ | |
| --device 0 --type dvddrive \ | |
| --medium arch-march15.iso && | |
| echo | |
| echo 'All steps completed.'; sleep 1 | |
| pause 'Hit Enter to continue...' | |
| vboxmanage showvminfo $vname | |
| pause 'Will start machine now...'; echo | |
| echo 'Attempting to start machine now...' | |
| sleep 1 | |
| vboxmanage startvm $vname --type headless | |
| pause 'End of the script. All tasks completed c: | |
| Hit enter to exit...' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment