Created
July 5, 2018 14:57
-
-
Save zentavr/a74827cad4987c6637d5d8382a0e56c7 to your computer and use it in GitHub Desktop.
Cuckoo Helpers for Building OS X Images
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 | |
function usage() { | |
cat << EOF | |
usage: $0 options | |
The script creates MacOS X Guest VM. | |
OPTIONS: | |
-h, --help | |
Show this message | |
-f, --from <NAME> | |
The source drive | |
-t, --to <NAME> | |
The destibation drive | |
-m, --multiattach | |
Set up multiattach flag | |
EOF | |
} | |
SHORTARGS="hf:t:m" | |
LONGARGS="help,from:,to:,multiattach" | |
ARGS=$(getopt -o "${SHORTARGS}" -l "${LONGARGS}" -n "DriveClone" -- "$@") | |
if [ $? -ne 0 ]; then | |
echo "Bad argument to getopt was given" | |
exit 1 | |
fi | |
eval set -- "$ARGS" | |
FROM="" | |
TO="" | |
MULTIATTACH=false | |
# Extract the options | |
while true; do | |
case "$1" in | |
-h|--help) | |
usage | |
exit;; | |
-f|--from) | |
if [ -n "$2" ]; then | |
FROM="$2" | |
else | |
echo "No name was specified (-f | --from)." | |
exit 1; | |
fi | |
shift 2;; | |
-t|--to) | |
if [ -n "$2" ]; then | |
TO="$2" | |
else | |
echo "No name was specified (-t | --to)." | |
exit 1; | |
fi | |
shift 2;; | |
-m|--multiattach) | |
MULTIATTACH=true | |
shift;; | |
--) | |
shift | |
break;; | |
esac | |
done | |
if [ -e "${FROM}" ]; then | |
/usr/bin/VBoxManage clonemedium disk "${FROM}" "${TO}" | |
if ${MULTIATTACH}; then | |
/usr/bin/VBoxManage modifyhd "${TO}" --type multiattach | |
fi | |
fi |
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 | |
trap bashtrap INT | |
function bashtrap() { | |
echo "CTRL+C Detected !..." | |
exit 1 | |
} | |
function usage() { | |
cat << EOF | |
usage: $0 options | |
The script creates MacOS X Guest VM. | |
OPTIONS: | |
-h, --help | |
Show this message | |
-n, --name <NAME> | |
VM Name | |
-t, --type <TYPE> | |
VM Type: | |
* MacOS Mac OS X (32-bit) | |
* MacOS_64 Mac OS X (64-bit) | |
* MacOS106 Mac OS X 10.6 Snow Leopard (32-bit) | |
* MacOS106_64 Mac OS X 10.6 Snow Leopard (64-bit) | |
* MacOS107_64 Mac OS X 10.7 Lion (64-bit) | |
* MacOS108_64 Mac OS X 10.8 Mountain Lion (64-bit) | |
* MacOS109_64 Mac OS X 10.9 Mavericks (64-bit) | |
* MacOS1010_64 Mac OS X 10.10 Yosemite (64-bit) | |
* MacOS1011_64 Mac OS X 10.11 El Capitan (64-bit) | |
* MacOS1012_64 Mac OS X 10.12 Sierra (64-bit) | |
* MacOS1013_64 Mac OS X 10.13 High Sierra (64-bit) | |
-i, --identifier <equipment> | |
Spoof the equipment: | |
* iMac11,3 iMac (27-inch, Mid 2010) | |
* MacBookPro11,3 MacBook Pro (Retina, 15-inch, Mid 2014) | |
* Macmini6,2 Mac mini (Late 2012) | |
-b, --bios <type> | |
Bios Type: | |
* bios | |
* efi | |
* efi32 | |
* efi64 | |
"bios" is the default | |
-c, --cpus <count> | |
CPU Count. Virtualbox says it support only 1 CPU | |
--cpuid <name> | |
Pretend CPU as: | |
* Intel Unknown | |
* Lynnfield i5 750 | |
* IvyBridge i7-3770 | |
-m, --memory <megabytes> | |
Amount of Memory to allocate. 4096Mb is the default. | |
-v, --videoram <megabytes> | |
Amount of video memory to allocate. 16Mb is the default | |
-d, --drive <megabytes> | |
Amount of harddisk to allocate. 128Gb is the default | |
--ext-drive <path> | |
The drive to use instead of an empty one. When defined, '-d' ('--drive') is ignored. | |
If you want to share the same drive between the VMs, you need to set it up with 'multiattach' type. | |
-r, --rdp | |
Enable RDP | |
--rdpuser <user> | |
RDP User Name | |
--rdppassword <password> | |
RDP Password | |
--start | |
Start the Machine after creation | |
--dosnapshot <name> | |
Create a snapshot with <name> after the start. 'vminit' is the default. | |
--cd <path> | |
Attach CD/DVD iso | |
--usb <type> | |
USB Type 1/2/3 | |
EOF | |
} | |
# Apple Identifiers for iMac: https://support.apple.com/en-us/ht201634 | |
# Apple Identifiers for Mac Mini: https://support.apple.com/en-gb/ht201894 | |
# Apple Identifiers for Mac Pro: https://support.apple.com/en-gb/ht201300 | |
SHORTARGS="hn:t:i:c:m:v:d:rb:" | |
LONGARGS="help,name:,type:,identifier:,cpus:,memory:,videoram:,drive:,rdp,cpuid:,start,cd:,bios:,usb:" | |
LONGARGS="${LONGARGS},rdpuser:,rdppassword:,dosnapshot:,ext-drive:" | |
ARGS=$(getopt -o "${SHORTARGS}" -l "${LONGARGS}" -n "OSXCreate" -- "$@") | |
if [ $? -ne 0 ]; then | |
echo "Bad argument to getopt was given" | |
exit 1 | |
fi | |
eval set -- "$ARGS" | |
# | |
# Set up the default variables | |
# | |
# VM Name | |
VM="MacOS X" | |
# OS Type | |
OS="MacOS_64" | |
# Identifier | |
IDENT="" | |
BIOS="bios" | |
# CPUs Count | |
CPUCOUNT=1 | |
# CPU Id | |
CPUID="" | |
# Ram Size | |
RAM=4096 | |
# Video Ram | |
VRAM=16 | |
# Disk Size | |
DISKSIZE=131072 | |
# Start VM | |
STARTVM=false | |
RDP=false | |
ISOFILE="" | |
EXTDRIVE="" | |
USBTYPE=1 | |
# RDP Users and passwords | |
RDPUSER="" | |
RDPPASSWORD="password" | |
# Snapshot name to do | |
SNAPSHOT="" | |
# 82545EM - Intel PRO/1000 MT Server | |
# Am79C973 - PCnet-FAST III | |
# Am79C970A - PCnet-PCI II | |
# 82540EM - Intel PRO/1000 MT Desktop | |
# 82543GC - Intel PRO/1000 T Server | |
NICTYPE="82545EM" | |
MAC="000102030405" | |
case "${NICTYPE}" in | |
"82545EM") | |
# Intel PRO/1000 MT Server | |
MAC=$(hexdump -n3 -e'/3 "000203" 3/1 "%02X"' /dev/random) | |
;; | |
"Am79C973") | |
# PCnet-FAST III | |
MAC=$(hexdump -n3 -e'/3 "006094" 3/1 "%02X"' /dev/random) | |
;; | |
"Am79C970A") | |
# PCnet-PCI II | |
MAC=$(hexdump -n3 -e'/3 "006094" 3/1 "%02X"' /dev/random) | |
;; | |
"82540EM") | |
# Intel PRO/1000 MT Desktop | |
MAC=$(hexdump -n3 -e'/3 "000347" 3/1 "%02X"' /dev/random) | |
;; | |
"82543GC") | |
# Intel PRO/1000 T Server | |
MAC=$(hexdump -n3 -e'/3 "0007E9" 3/1 "%02X"' /dev/random) | |
;; | |
*) | |
# Everything else | |
MAC=$(hexdump -n3 -e'/3 "00602F" 3/1 "%02X"' /dev/random) | |
;; | |
esac | |
# Extract the options | |
while true; do | |
case "$1" in | |
-h|--help) | |
usage | |
exit;; | |
-n|--name) | |
if [ -n "$2" ]; then | |
VM="$2" | |
else | |
echo "No name was specified (-n | --name)." | |
exit 1; | |
fi | |
shift 2;; | |
-t|--type) | |
if [ -n "$2" ]; then | |
OS="$2" | |
if [[ $OS != MacOS* ]]; then | |
echo "Some weird os type is specified: ${OS}" | |
exit 1; | |
fi | |
else | |
echo "No os type was specified (-t | --type)." | |
exit 1; | |
fi | |
shift 2;; | |
-i|--identifier) | |
if [ -n "$2" ]; then | |
IDENT="$2" | |
else | |
echo "No name was specified (-i | --identifier)." | |
exit 1; | |
fi | |
shift 2;; | |
-b|--bios) | |
if [ -n "$2" ]; then | |
BIOS="$2" | |
else | |
echo "No bios was specified (-b | --bios)." | |
exit 1; | |
fi | |
shift 2;; | |
-c|--cpus) | |
if [ -n "$2" ]; then | |
CPUCOUNT="$2" | |
else | |
echo "No cpu count was specified (-c | --cpus)." | |
exit 1; | |
fi | |
shift 2;; | |
--cpuid) | |
if [ -n "$2" ]; then | |
CPUID="$2" | |
else | |
echo "No cpuid was specified (-cpuid)." | |
exit 1; | |
fi | |
shift 2;; | |
-m|--memory) | |
if [ -n "$2" ]; then | |
RAM="$2" | |
else | |
echo "No value was specified for RAM (-m | --memory)." | |
exit 1; | |
fi | |
shift 2;; | |
-v|--videoram) | |
if [ -n "$2" ]; then | |
VRAM="$2" | |
else | |
echo "No value was specified for Video RAM (-v | --videoram)." | |
exit 1; | |
fi | |
shift 2;; | |
-d|--drive) | |
if [ -n "$2" ]; then | |
DISKSIZE="$2" | |
else | |
echo "No value was specified for Video RAM (-d | --drive)." | |
exit 1; | |
fi | |
shift 2;; | |
-r|--rdp) | |
RDP=true | |
shift;; | |
--rdpuser) | |
if [ -n "$2" ]; then | |
RDPUSER="$2" | |
else | |
echo "No value was specified for rdpuser (--rdpuser)." | |
exit 1; | |
fi | |
shift 2;; | |
--rdppassword) | |
if [ -n "$2" ]; then | |
RDPPASSWORD="$2" | |
else | |
echo "No value was specified for rdppassword (--rdppassword)." | |
exit 1; | |
fi | |
shift 2;; | |
--start) | |
STARTVM=true | |
shift;; | |
--cd) | |
if [ -n "$2" ]; then | |
ISOFILE="$2" | |
if [ ! -f "${ISOFILE}" ]; then | |
echo "There is no such file: ${ISOFILE}" | |
exit 1; | |
fi | |
else | |
echo "No value was specified for cd (--cd)." | |
exit 1; | |
fi | |
shift 2;; | |
--ext-drive) | |
if [ -n "$2" ]; then | |
EXTDRIVE="$2" | |
if [ ! -f "${EXTDRIVE}" ]; then | |
echo "There is no such file: ${EXTDRIVE}" | |
exit 1; | |
fi | |
else | |
echo "No value was specified for ext-drive (--ext-drive)." | |
exit 1; | |
fi | |
shift 2;; | |
--dosnapshot) | |
if [ -n "$2" ]; then | |
SNAPSHOT="$2" | |
else | |
echo "No value was specified for dosnapshot (--dosnapshot)." | |
exit 1; | |
fi | |
shift 2;; | |
--usb) | |
if [ -n "$2" ]; then | |
USBTYPE="$2" | |
else | |
echo "No value was specified for usb (--usb)." | |
exit 1; | |
fi | |
shift 2;; | |
--) | |
shift | |
break;; | |
esac | |
done | |
echo "${VM}: Creating ${OS} machine with ${MAC} address" | |
/usr/bin/VBoxManage createvm --register --name "${VM}" | |
/usr/bin/VBoxManage modifyvm "${VM}" --ostype ${OS} | |
# Enable IO APIC and setup CPU count | |
/usr/bin/VBoxManage modifyvm "${VM}" --ioapic on --cpus "${CPUCOUNT}" | |
# Enable PAE/NX | |
/usr/bin/VBoxManage modifyvm "${VM}" --pae on | |
# Set up peripherals (mouse/keyboard) | |
/usr/bin/VBoxManage modifyvm "${VM}" --mouse usbtablet | |
/usr/bin/VBoxManage modifyvm "${VM}" --keyboard usb | |
# Set up memory settings | |
/usr/bin/VBoxManage modifyvm "${VM}" --memory "${RAM}" | |
/usr/bin/VBoxManage modifyvm "${VM}" --vram "${VRAM}" | |
# Set up the chipset piix3/ich9 | |
/usr/bin/VBoxManage modifyvm "${VM}" --chipset ich9 | |
# Set up firmware bios/efi/efi32/efi64 | |
/usr/bin/VBoxManage modifyvm "${VM}" --firmware "${BIOS}" | |
/usr/bin/VBoxManage modifyvm "${VM}" --bioslogodisplaytime 3000 | |
/usr/bin/VBoxManage modifyvm "${VM}" --biosbootmenu messageandmenu | |
/usr/bin/VBoxManage modifyvm "${VM}" --bioslogofadein off | |
/usr/bin/VBoxManage modifyvm "${VM}" --bioslogofadeout off | |
# Paravirtualization interface | |
/usr/bin/VBoxManage modifyvm "${VM}" --paravirtprovider default | |
# Enabling nested paging (on/off) | |
/usr/bin/VBoxManage modifyvm "${VM}" --nestedpaging on | |
# Hardware Clock is in UTC time (on|off) | |
/usr/bin/VBoxManage modifyvm "${VM}" --rtcuseutc on | |
# Enable HPET (on/off) | |
/usr/bin/VBoxManage modifyvm "${VM}" --hpet on | |
# Enable USB Controller | |
/usr/bin/VBoxManage modifyvm "${VM}" --usb on | |
case "${USBTYPE}" in | |
"1") | |
echo "USB 1 is already enabled" | |
;; | |
"2") | |
echo "Enabling USB 2" | |
/usr/bin/VBoxManage modifyvm "${VM}" --usbehci on | |
;; | |
"3") | |
echo "Enabling USB 3" | |
/usr/bin/VBoxManage modifyvm "${VM}" --usbxhci on | |
;; | |
*) | |
echo "I have no idea what USB ${USBTYPE} is" | |
;; | |
esac | |
# Attaching SATA Controller | |
/usr/bin/VBoxManage storagectl "${VM}" --add sata --name SATA | |
# Creating the disk file | |
mkdir -p "${HOME}/VirtualBox VMs" | |
if [ -z "${EXTDRIVE}" ]; then | |
echo "Creating personal drive in ${HOME}/VirtualBox VMs/${VM}/disk.vdi" | |
/usr/bin/VBoxManage createmedium disk \ | |
--filename "${HOME}/VirtualBox VMs/${VM}/disk.vdi" \ | |
--size "${DISKSIZE}" \ | |
--format VDI | |
# Attaching the disk | |
/usr/bin/VBoxManage storageattach "${VM}" --storagectl SATA --device 0 \ | |
--type hdd --medium "${HOME}/VirtualBox VMs/${VM}/disk.vdi" --port 0 | |
else | |
echo "Attaching ${EXTDRIVE}" | |
/usr/bin/VBoxManage storageattach "${VM}" --storagectl SATA --device 0 \ | |
--type hdd --medium "${EXTDRIVE}" --port 0 | |
fi | |
# Attaching the ISO File if needed | |
if [ -f "${ISOFILE}" ]; then | |
/usr/bin/VBoxManage storageattach "${VM}" --storagectl SATA --device 0 \ | |
--type dvddrive --medium "${ISOFILE}" --port 1 | |
/usr/bin/VBoxManage modifyvm "${VM}" --boot1 dvd | |
/usr/bin/VBoxManage modifyvm "${VM}" --boot2 disk | |
/usr/bin/VBoxManage modifyvm "${VM}" --boot3 none | |
/usr/bin/VBoxManage modifyvm "${VM}" --boot4 none | |
else | |
/usr/bin/VBoxManage modifyvm "${VM}" --boot1 disk | |
/usr/bin/VBoxManage modifyvm "${VM}" --boot2 none | |
/usr/bin/VBoxManage modifyvm "${VM}" --boot3 none | |
/usr/bin/VBoxManage modifyvm "${VM}" --boot4 none | |
fi | |
# Setting up Audio Outputs | |
/usr/bin/VBoxManage modifyvm "${VM}" --audio none | |
/usr/bin/VBoxManage modifyvm "${VM}" --audiocontroller hda | |
/usr/bin/VBoxManage modifyvm "${VM}" --audioout on | |
# Network Setup | |
/usr/bin/VBoxManage modifyvm "${VM}" --nictype1 "${NICTYPE}" --cableconnected1 on \ | |
--nicpromisc1 allow-all --hostonlyadapter1 vboxnet0 --nic1 hostonly | |
/usr/bin/VBoxManage modifyvm "${VM}" --macaddress1 "${MAC}" | |
# hardware virtualization extensions (on/off) | |
/usr/bin/VBoxManage modifyvm "${VM}" --hwvirtex on | |
# use of the nested paging feature | |
/usr/bin/VBoxManage modifyvm "${VM}" --nestedpaging on | |
# Enable Large Pages | |
/usr/bin/VBoxManage modifyvm "${VM}" --largepages off | |
# use of the tagged TLB (VPID) feature | |
/usr/bin/VBoxManage modifyvm "${VM}" --vtxvpid on | |
# use of the unrestricted guest mode feature for executing your guest | |
/usr/bin/VBoxManage modifyvm "${VM}" --vtxux on | |
# Enabling RDP | |
if ${RDP}; then | |
/usr/bin/VBoxManage modifyvm "${VM}" --vrde on | |
/usr/bin/VBoxManage modifyvm "${VM}" --vrdeproperty "TCP/Ports=9000-9100" | |
# TLS Encryption | |
if [ -e /etc/ssl/public.pem ] && [ -e /etc/ssl/private.pem ] && [ -e /etc/ssl/ca-bundle.pem ]; then | |
/usr/bin/VBoxManage modifyvm "${VM}" --vrdeproperty "Security/ServerCertificate=/etc/ssl/public.pem" | |
/usr/bin/VBoxManage modifyvm "${VM}" --vrdeproperty "Security/ServerPrivateKey=/etc/ssl/private.pem" | |
/usr/bin/VBoxManage modifyvm "${VM}" --vrdeproperty "Security/CACertificate=/etc/ssl/ca-bundle.pem" | |
else | |
echo "In order to have TLS with your RDP Setup, please put the next files to the disk:" | |
echo " * /etc/ssl/public.pem - Public key file (PEM Format)" | |
echo " * /etc/ssl/private.pem - Private key file (PEM Format)" | |
echo " * /etc/ssl/ca-bundle.pem - CA or CA chain (PEM Format)" | |
echo | |
echo " ....the setup of TLS for RDP was skipped." | |
fi | |
# RDP Authentication library | |
/usr/bin/VBoxManage modifyvm "${VM}" --vrdeauthlibrary "VBoxAuthSimple" | |
/usr/bin/VBoxManage modifyvm "${VM}" --vrdeauthtype external | |
# Set up Password | |
if [ ! -z ${RDPUSER} ]; then | |
NL=$'\n' | |
/usr/bin/VBoxManage modifyvm "${VM}" --description "RDP User: ${RDPUSER}${NL}RDP Password: ${RDPPASSWORD}" | |
RDPPASSWORD=$(/usr/bin/VBoxManage internalcommands passwordhash "${RDPPASSWORD}" | cut -d':' -f2) | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxAuthSimple/users/${RDPUSER}" ${RDPPASSWORD} | |
fi | |
fi | |
case "${IDENT}" in | |
"iMac11,3") | |
# CPU: Intel Core i5-760 | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" | |
#/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-F2238BAE" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1 | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial" "W8123456781A" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBoardSerial" "W81234567891A" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVendor" "Apple Inc." | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemFamily" "iMac" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBIOSVersion" "IM112.0057.03B" | |
;; | |
"MacBookPro11,3") | |
# CPU: Intel Core i7-4960HQ | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" | |
#/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-2BD1B31983FE1663" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1 | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBIOSVersion" "MBP112.88Z.0138.B40.1706201157" | |
;; | |
"Macmini6,2") | |
# CPU: Intel Core i7-3615QM | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "Macmini6,2" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" | |
#/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Mac-F65AE981FFA204ED" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1 | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal/Devices/efi/0/Config/DmiBIOSVersion" "MM61.88Z.010E.B00.1804111136" | |
;; | |
*) | |
echo "I have no idea about how to emulate ${IDENT}" | |
;; | |
esac | |
# Specify the screen resolution | |
# Where N can be one of 0,1,2,3,4,5 referring to the 640x480, 800x600, 1024x768, 1280x1024, 1440x900, 1920x1200 screen resolution respectively. | |
# pre 5.2.x | |
# /usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal2/EfiGopMode" 4 | |
# 5.2.x+ | |
/usr/bin/VBoxManage setextradata "${VM}" "VBoxInternal2/EfiGraphicsResolution" 1440x900 | |
# Specifying boot arguments | |
# /usr/bin/VBoxManage setextradata "${VM}" VBoxInternal2/EfiBootArgs <value> | |
# Spoofing CPU | |
case "${CPUID}" in | |
"IvyBridge i7-3770") | |
/usr/bin/VBoxManage modifyvm "${VM}" --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff | |
#/usr/bin/VBoxManage modifyvm "${VM}" --cpuidset 00000001 000306a9 00020800 80000201 178bfbff | |
;; | |
"Lynnfield i5 750") | |
/usr/bin/VBoxManage modifyvm "${VM}" --cpuidset 00000001 000106e5 06100800 0098e3fd bfebfbff | |
;; | |
*) | |
echo "I dont know how to spoof ${CPUID}" | |
;; | |
esac | |
# More CPU IDs you can try to seek here: | |
# https://www.insanelymac.com/forum/topic/309654-run-vanilla-os-x-el-capitan-sierra-or-high-sierra-in-virtualbox-5034-on-a-windows-host/?tab=comments#comment-2218638 | |
#/usr/bin/VBoxManage modifyvm ${VM} --cpuidset 00000001 000306a9 00020800 80000201 178bfbff | |
# Sierra (if CPUs > 1) | |
# | |
#/usr/bin/VBoxManage modifyvm ${VM} --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff | |
# Default frontend is headless | |
/usr/bin/VBoxManage modifyvm "${VM}" --defaultfrontend headless | |
if ${STARTVM}; then | |
/usr/bin/VBoxManage startvm "${VM}" --type headless | |
fi | |
if [ ! -z "${SNAPSHOT}" ]; then | |
echo | |
echo "Log into the VM (ssh/VirtualBox RDP/etc), set up unique hostname and IP address," | |
echo "install the software and continue." | |
echo "You machine will be powered off after the snapshot is done." | |
echo | |
read -p "Press enter to continue" | |
/usr/bin/VBoxManage snapshot "${VM}" take "${SNAPSHOT}" --live --description "Snapshot created during the provision" | |
/usr/bin/VBoxManage controlvm "${VM}" poweroff | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment