Created
March 7, 2020 14:09
-
-
Save ipolyzos/0981f4b420ca850d2fa2ff26da650582 to your computer and use it in GitHub Desktop.
automate the VirtuaBox VM configuration to host MacOS
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
#!/bin/bash | |
# This script to aims to automate the VirtuaBox VM | |
# configuration to host MacOS | |
# Exit immediately if a pipeline returns a non-zero status. | |
set -o errexit | |
# Return value of a pipeline is the value of the last command to exit with a non-zero status or zero | |
# if all commands in the pipeline exit successfully. | |
set -o pipefail | |
# Treat unset variables and parameters other than the special parameters ‘@’ or ‘*’ as | |
# an error when performing parameter expansion. | |
set -o nounset | |
function initVM(){ | |
VBoxManage modifyvm "${VM_NAME}" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff | |
VBoxManage setextradata "${VM_NAME}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3" | |
VBoxManage setextradata "${VM_NAME}" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0" | |
VBoxManage setextradata "${VM_NAME}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple" | |
VBoxManage setextradata "${VM_NAME}" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" | |
VBoxManage setextradata "${VM_NAME}" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1 | |
} | |
function printHelp(){ | |
echo "setupMacOSVM.sh : Initialise the MacOS VirtualBox VM." | |
echo "Usage: ./setupVm.sh [options]" | |
echo "options: " | |
echo " -n, --name The name of the VM to initialise (default is \"MACOS\") " | |
echo " -h, --help Display this help message." | |
exit 0 | |
} | |
# parse arguments | |
while (( "$#" )); do | |
case "$1" in | |
-n|--name) | |
echo "Initialise VM " | |
VM_NAME=-${2:-default} | |
initVM | |
exit 0 | |
;; | |
-h|--help) | |
printHelp | |
exit 0 | |
;; | |
*) | |
echo -e "Invalid Option: $1" | |
exit 1 | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment