Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vbox-scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto LIVIO BECCARIA
vbox-scripts
Commits
610dc107
Commit
610dc107
authored
6 years ago
by
Alberto LIVIO BECCARIA
Browse files
Options
Downloads
Patches
Plain Diff
Added feature: create VM by script without a template
Added test profile win10test
parent
05d191b1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
settings/settings
+20
-1
20 additions, 1 deletion
settings/settings
settings/win10test.settings
+20
-0
20 additions, 0 deletions
settings/win10test.settings
settings/win7.settings
+8
-1
8 additions, 1 deletion
settings/win7.settings
vm-setup
+59
-14
59 additions, 14 deletions
vm-setup
with
107 additions
and
16 deletions
settings/settings
+
20
−
1
View file @
610dc107
...
...
@@ -3,7 +3,7 @@
##############################################
# images home dir
IMG_HOME="/opt/vm-images"
IMG_HOME="/
media/wd250/
opt/vm-images"
# media folder (USB mounting point)
MEDIA_DIR="${HOME}/vbox_media"
...
...
@@ -33,3 +33,22 @@ SNAPSHOT_HD_UUID=""
# autoreset
AUTORESET=1
# some defaults
DESCRIPTION="VirtualBox VM"
CHIPSET=piix3
IO_APIC=on
CPUS=2
ACCEL_2D=off
ACCEL_3D=off
NIC_TYPE=82545EM
MEMORY=1024
VRAM=128
STORAGE_CONTROLLER_NAME=SATA
STORAGE_CONTROLLER_TYPE=sata
AUDIO_DRIVER=pulse
AUDIO_CONTROLLER=hda
POINTING_DEVICE=usbtablet
HW_VIRTEX=on
NESTED_PAGING=on
PARAVIRT_PROVIDER=legacy
This diff is collapsed.
Click to expand it.
settings/win10test.settings
0 → 100644
+
20
−
0
View file @
610dc107
# VM name in VirtualBox
VM_NAME="Windows10Test"
# OS type
OS_TYPE="Windows10_64"
# VM template
TEMPLATE="win10"
# snapshot name
SNAPSHOT_NAME=""
# start vm in fullscreen mode
FULLSCREEN=0
CREATE_VM=1
DESCRIPTION="Windows 10 Lab - VM created by script"
MEMORY=1024
DISK_IMAGE="win10test.vdi"
HARDWARE_UUID=d49b62b7-6239-4a99-94fa-df0431510063
This diff is collapsed.
Click to expand it.
settings/win7.settings
+
8
−
1
View file @
610dc107
# VM name in VirtualBox
VM_NAME="Windows
7"
VM_NAME="Windows7"
# OS type
OS_TYPE="Windows7"
...
...
@@ -12,3 +12,10 @@ SNAPSHOT_NAME="shortcut"
#DIFF_DISK_FILE="diff_win7.vdi"
CREATE_VM=1
MEMORY=1024
DISK_IMAGE="win7.vdi"
HARDWARE_UUID=eebd2bf4-dc68-47c1-8201-5678e5e43cb2
This diff is collapsed.
Click to expand it.
vm-setup
+
59
−
14
View file @
610dc107
#!/bin/bash
#############################################
# VirtualBox VM Scripts v0.
10
# VirtualBox VM Scripts v0.
2
# by ulisse aka A. Livio Beccaria
#
# Sets a VM up
...
...
@@ -57,22 +57,67 @@ echo " Name: ${VM_NAME}"
echo
" UUID:
${
UUID
}
"
echo
# use template
echo
-n
"Configuring VM... "
cp
"
${
TEMPLATE_DIR
}
/
${
TEMPLATE
}
.vbox"
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
# se servisse: " = \x22
sed
-i
's@\(Machine.*uuid="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
UUID
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(Machine.*name="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
VM_NAME
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(Machine.*snapshotFolder="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
USER_TMP_DIR
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(SharedFolder.*name="'
"
`
echo
"
${
SF_LINUX_NAME
}
"
`
"
'".*hostPath="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
SF_LINUX_TARGET
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(SharedFolder.*name="'
"
`
echo
"
${
SF_MEDIA_NAME
}
"
`
"
'".*hostPath="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
SF_MEDIA_TARGET
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(MACAddress="\)\([^"]*\)\("\)@\1'
"
`
printf
'080027%02X%02X%02X'
$[
RANDOM%256]
$[
RANDOM%256]
$[
RANDOM%256]
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
if
[
"
${
DIFF_DISK_FILE
}
"
!=
""
]
;
then
sed
-i
's@\(HardDisk.*location="\)\([^"]*diff_[^"]*\)\("\)@\1'
"
`
echo
"
${
USER_TMP_DIR
}
/
${
DIFF_DISK_FILE
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
if
[[
${
CREATE_VM
}
==
"1"
]]
;
then
# register VM
VBoxManage registervm
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
# network
VBoxManage modifyvm
"
${
VM_NAME
}
"
--nictype1
${
NIC_TYPE
}
--nic1
nat
--natpf1
"http, tcp, , 80, , 8080"
# hardware UUID
VBoxManage modifyvm
"
${
VM_NAME
}
"
--hardwareuuid
${
HARDWARE_UUID
}
# USB
VBoxManage modifyvm
"
${
VM_NAME
}
"
--usb
on
--usbehci
off
--usbxhci
off
# System: Memory, Chipset, Pointing device, I/O APIC, # of CPUs, PAE,
# Paravirtualization interface, Hardware Virtualization, Nested Paging
#
VBoxManage modifyvm
${
VM_NAME
}
--memory
${
MEMORY
}
--chipset
${
CHIPSET
}
\
--mouse
${
POINTING_DEVICE
}
--ioapic
${
IO_APIC
}
--cpus
${
CPUS
}
\
--paravirtprovider
${
PARAVIRT_PROVIDER
}
\
--hwvirtex
${
HW_VIRTEX
}
--nestedpaging
${
NESTED_PAGING
}
# all other things
VBoxManage modifyvm
"
${
VM_NAME
}
"
--vram
${
VRAM
}
--snapshotfolder
${
USER_TMP_DIR
}
\
--accelerate2dvideo
${
ACCEL_2D
}
--accelerate3d
${
ACCEL_3D
}
\
--clipboard
bidirectional
--draganddrop
bidirectional
--audio
${
AUDIO_DRIVER
}
\
--audiocontroller
${
AUDIO_CONTROLLER
}
--audioin
on
--audioout
on
\
--description
"
${
DESCRIPTION
}
"
# set storage
VBoxManage storagectl
"
${
VM_NAME
}
"
--name
${
STORAGE_CONTROLLER_NAME
}
--add
${
STORAGE_CONTROLLER_TYPE
}
VBoxManage storageattach
"
${
VM_NAME
}
"
--storagectl
${
STORAGE_CONTROLLER_NAME
}
--port
0
--device
0
--type
dvddrive
--medium
emptydrive
VBoxManage storageattach
"
${
VM_NAME
}
"
--storagectl
${
STORAGE_CONTROLLER_NAME
}
--port
1
--device
0
--type
hdd
--medium
"
${
IMG_HOME
}
/
${
VM_ID
}
/
${
DISK_IMAGE
}
"
# shared folders
VBoxManage sharedfolder add
"
${
VM_NAME
}
"
--name
"
${
SF_LINUX_NAME
}
"
--hostpath
"
${
SF_LINUX_TARGET
}
"
VBoxManage sharedfolder add
"
${
VM_NAME
}
"
--name
"
${
SF_MEDIA_NAME
}
"
--hostpath
"
${
SF_MEDIA_TARGET
}
"
else
# use template
cp
"
${
TEMPLATE_DIR
}
/
${
TEMPLATE
}
.vbox"
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
# se servisse: " = \x22
sed
-i
's@\(Machine.*uuid="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
UUID
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(Machine.*name="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
VM_NAME
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(Machine.*snapshotFolder="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
USER_TMP_DIR
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(SharedFolder.*name="'
"
`
echo
"
${
SF_LINUX_NAME
}
"
`
"
'".*hostPath="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
SF_LINUX_TARGET
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(SharedFolder.*name="'
"
`
echo
"
${
SF_MEDIA_NAME
}
"
`
"
'".*hostPath="\)\([^"]*\)\("\)@\1'
"
`
echo
"
${
SF_MEDIA_TARGET
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
sed
-i
's@\(MACAddress="\)\([^"]*\)\("\)@\1'
"
`
printf
'080027%02X%02X%02X'
$[
RANDOM%256]
$[
RANDOM%256]
$[
RANDOM%256]
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
if
[
"
${
DIFF_DISK_FILE
}
"
!=
""
]
;
then
sed
-i
's@\(HardDisk.*location="\)\([^"]*diff_[^"]*\)\("\)@\1'
"
`
echo
"
${
USER_TMP_DIR
}
/
${
DIFF_DISK_FILE
}
"
`
"
'\3@g'
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
fi
# register VM
VBoxManage registervm
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
fi
VBoxManage registervm
"
${
VM_DIR
}
/
${
VM_NAME
}
.vbox"
echo
"OK"
echo
exit
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment