Last active
August 29, 2015 14:09
-
-
Save lorandszakacs/26cefae7fc9b8edc8abd to your computer and use it in GitHub Desktop.
This file contains 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
# Don't forget to modify the values of all variables to suit your setup. | |
# | |
# This script assumes: | |
# 1. that you have a valid SEEDUbuntu VM hard drive at the path specified by | |
# the SERVER_HDD_PATH variable. | |
# 2. That you have precreated a "HostOnly" adapter from the VirtualBox Global settings | |
# from the GUI. The name of this adapter is usually "vboxnet0" which is hardcoded in this script, | |
# you might consider changing that :) | |
PATH_TO_VM_CONFIG_FILES="/home/ssc/zz-vm-configs" | |
SERVER_VM_NAME="ubuntu-server" | |
#this is the path to the SEED VM file that you would normally load as "existing hard drive" | |
#when creating a virtual machine from the GUI. | |
SERVER_HDD_PATH="/home/ssc/ubuntu-server/SEEDUbuntu12.04.vmdk" | |
SERVER_HDD_UUID="server-hdd" | |
MEMORY=512 | |
#cleanup | |
rm -rf $PATH_TO_VM_CONFIG_FILES | |
#make sure all VMs are stored in the desired folder. This is a global setting, | |
#needs to be set only once. TODO: Maybe move it to a separate file. | |
VBoxManage setproperty machinefolder $PATH_TO_VM_CONFIG_FILES | |
#global settings, create a host-only network | |
VBoxManage createvm --name $SERVER_VM_NAME --register | |
VBoxManage modifyvm $SERVER_VM_NAME --ostype Ubuntu --memory $MEMORY \ | |
--clipboard hosttoguest --draganddrop hosttoguest | |
#networking settings. TODO: figure out how to create the vboxnet0 adapter from the commandline, | |
#so far it was created from the GUI from the global Preferences -> Network -> Host-only adapters tab | |
VBoxManage modifyvm $SERVER_VM_NAME --nic1 hostonly --hostonlyadapter1 "vboxnet0" | |
#create a uuid for the vm's hdd | |
VBoxManage storagectl $SERVER_VM_NAME --name $SERVER_HDD_UUID --add ide | |
#attach the already existing vm hard drive to the above created UUID | |
VBoxManage storageattach $SERVER_VM_NAME --storagectl $SERVER_HDD_UUID --port 0 --device 0 --type hdd --medium $SERVER_HDD_PATH | |
#Now we clone the above created and configured image two more times | |
USER_HDD_PATH="/home/ssc/ubuntu-user" | |
USER_VM_NAME="ubuntu-user" | |
VBoxManage clonevm $SERVER_VM_NAME --name $USER_VM_NAME --basefolder $USER_HDD_PATH --register | |
ATTACKER_HDD_PATH="/home/ssc/ubuntu-attacker" | |
ATTACKER_VM_NAME="ubuntu-attacker" | |
VBoxManage clonevm $SERVER_VM_NAME --name $ATTACKER_VM_NAME --basefolder $ATTACKER_HDD_PATH --register |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment