replaced most echo statements with printf, added color

This commit is contained in:
img2tab
2019-01-03 07:44:07 +00:00
committed by GitHub
parent 71d00575b8
commit 3f75b85030
+64 -49
View File
@@ -2,7 +2,7 @@
# One-Key-Installation of macOS on VirtualBox # One-Key-Installation of macOS on VirtualBox
# (c) img2tab, licensed under GPL2.0 or higher # (c) img2tab, licensed under GPL2.0 or higher
# url: https://github.com/img2tab/okiomov # url: https://github.com/img2tab/okiomov
# version 0.24 # version 0.26
# Requirements: 33.5GB available storage on host # Requirements: 33.5GB available storage on host
# Dependencies: bash>4.0, unzip, wget, dmg2img, VirtualBox>5.2 # Dependencies: bash>4.0, unzip, wget, dmg2img, VirtualBox>5.2
@@ -23,14 +23,16 @@ boardid="Mac-2BD1B31983FE1663"
# welcome message # welcome message
whiteonred="\e[48;2;255;0;0m\e[38;2;255;255;255m" whiteonred="\e[48;2;255;0;0m\e[38;2;255;255;255m"
whiteonblack="\e[48;2;0;0;9m\e[38;2;255;255;255m" whiteonblack="\e[48;2;0;0;9m\e[38;2;255;255;255m"
defaultcolor="\033[0m"
printf ' printf '
One-Key-Installation of macOS On VirtualBox - Mojave 10.14.11 One-Key-Installation of macOS On VirtualBox - Mojave 10.14.11
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
'${whiteonblack}'This installer uses only open-source software and original '${whiteonblack}'This installer uses only open-source software and original
unmodified Apple binaries.\033[0m unmodified Apple binaries.'${defaultcolor}'
The installation requires '${whiteonred}'33.5GB\033[0m of available storage, The installation requires '${whiteonred}'33.5GB'${defaultcolor}' of available storage,
22GB for the virtual machine and 11.5GB for temporary installation files. 22GB for the virtual machine and 11.5GB for temporary installation files.
The script checks for dependencies and will prompt to install them if unmet. The script checks for dependencies and will prompt to install them if unmet.
@@ -38,7 +40,7 @@ The script checks for dependencies and will prompt to install them if unmet.
For iCloud and iMessage functionality, you will need to provide a valid For iCloud and iMessage functionality, you will need to provide a valid
Apple serial number. macOS will work without it, but not Apple-connected apps. Apple serial number. macOS will work without it, but not Apple-connected apps.
Press enter to continue, CTRL-C to exit.' '${whiteonblack}'Press enter to continue, CTRL-C to exit.'${defaultcolor}
read read
# silence stderr # silence stderr
@@ -103,10 +105,6 @@ if [ -n "$(VBoxManage showvminfo "${vmname}")" ]; then
exit exit
fi fi
echo "${vmname} virtual machine already exists. Exiting."
exit
fi
# Create the macOS base system virtual disk image: # Create the macOS base system virtual disk image:
if [ -r "BaseSystem.vdi" ]; then if [ -r "BaseSystem.vdi" ]; then
echo "BaseSystem.vdi bootstrap virtual disk image ready." echo "BaseSystem.vdi bootstrap virtual disk image ready."
@@ -333,24 +331,26 @@ function sendenter() {
} }
function promptlangutils() { function promptlangutils() {
echo "" printf ${whiteonblack}'
read -p "Press enter when the language select screen is ready." Press enter when the language select screen is ready.'${defaultcolor}
read -p ""
sendenter sendenter
echo "" printf ${whiteonblack}'
read -p "Press enter when the macOS Utilities screen is ready." Press enter when the macOS Utilities screen is ready.'${defaultcolor}
read -p ""
kbspecial='CTRLprs F2 CTRLrls u ENTER t ENTER' kbspecial='CTRLprs F2 CTRLrls u ENTER t ENTER'
sendspecial sendspecial
} }
promptlangutils
function promptterminalready() { function promptterminalready() {
echo "" printf ${whiteonblack}'
read -p "Press enter when the Terminal command prompt is ready." Press enter when the Terminal command prompt is ready.'${defaultcolor}
read -p ""
} }
promptlangutils
promptterminalready promptterminalready
echo "" echo ""
@@ -390,9 +390,10 @@ promptterminalready
kbstring='shutdown -h now' kbstring='shutdown -h now'
sendkeys sendkeys
echo "" printf ${whiteonblack}'
echo "Shutting down virtual machine." Shutting down virtual machine.
read -p "Press enter when the virtual machine shutdown is complete." Press enter when the virtual machine shutdown is complete.'${defaultcolor}
read -p ""
# Detach the original 2GB BaseSystem.vdi and boot from the new 8GB BaseSystem # Detach the original 2GB BaseSystem.vdi and boot from the new 8GB BaseSystem
echo "" echo ""
@@ -409,6 +410,7 @@ kbstring='mount -rw / && installpath="/Install macOS Mojave.app/Contents/SharedS
sendkeys sendkeys
# Rename InstallESDDmg.pkg to InstallESD.dmg and update InstallInfo.plist # Rename InstallESDDmg.pkg to InstallESD.dmg and update InstallInfo.plist
promptterminalready
kbstring='mv "${installpath}InstallESDDmg.pkg" "${installpath}InstallESD.dmg" && sed -i.bak -e "s/InstallESDDmg\.pkg/InstallESD.dmg/" -e "s/pkg\.InstallESDDmg/dmg.InstallESD/" "${installpath}InstallInfo.plist" && sed -i.bak2 -e "/InstallESD\.dmg/{n;N;N;N;d;}" "${installpath}InstallInfo.plist"' kbstring='mv "${installpath}InstallESDDmg.pkg" "${installpath}InstallESD.dmg" && sed -i.bak -e "s/InstallESDDmg\.pkg/InstallESD.dmg/" -e "s/pkg\.InstallESDDmg/dmg.InstallESD/" "${installpath}InstallInfo.plist" && sed -i.bak2 -e "/InstallESD\.dmg/{n;N;N;N;d;}" "${installpath}InstallInfo.plist"'
sendkeys sendkeys
@@ -424,28 +426,33 @@ promptterminalready
# Start the installer. # Start the installer.
kbstring='cd "/Install macOS Mojave.app/Contents/Resources/"; ./startosinstall --volume "/Volumes/'"${vmname}"'"' kbstring='cd "/Install macOS Mojave.app/Contents/Resources/"; ./startosinstall --volume "/Volumes/'"${vmname}"'"'
sendkeys sendkeys
echo "" printf ${whiteonblack}'
echo "Installer started. Please wait for the license prompt to appear at" Installer started. Please wait for the license prompt to appear at
echo "the bottom of the virtual machine terminal, then press enter here." the bottom of the virtual machine terminal, then press enter here.
read -p "This will accept the license on the virtual machine." This will accept the license on the virtual machine.'${defaultcolor}
read -p ""
kbspecial="A ENTER" kbspecial="A ENTER"
sendspecial sendspecial
echo "" echo ""
echo "When the installer finishes preparing, the virtual machine will reboot" echo "When the installer finishes preparing, the virtual machine will reboot"
echo "into the base system, not the installer." echo "into the base system, not the installer."
read -p "After the reboot, press enter when the language select screen is ready." printf ${whiteonblack}'
After the reboot, press enter when the language select screen is ready.'${defaultcolor}
read -p ""
sendenter sendenter
echo "" printf ${whiteonblack}'
read -p "Press enter when the macOS Utilities screen is ready." Press enter when the macOS Utilities screen is ready.'${defaultcolor}
read -p ""
# Start Safari (Get Help Online) # Start Safari (Get Help Online)
kbspecial="UP UP UP UP DOWN DOWN TAB SPACE" kbspecial="UP UP UP UP DOWN DOWN TAB SPACE"
sendspecial sendspecial
echo "" printf ${whiteonblack}'
read -p "Press enter when Safari is ready." Press enter when Safari is ready.'${defaultcolor}
read -p ""
# Browse the web! # Browse the web!
kbspecial="CMDprs l CMDrls" kbspecial="CMDprs l CMDrls"
@@ -453,16 +460,18 @@ sendspecial
kbstring="https://github.com/acidanthera/AppleSupportPkg/releases/tag/2.0.4" kbstring="https://github.com/acidanthera/AppleSupportPkg/releases/tag/2.0.4"
sendkeys sendkeys
echo "" echo ""
printf 'In the VM, '${whiteonred}'manually\033[0m right-click on AppleSupport-v2.0.4-RELEASE.zip' printf 'In the VM, '${whiteonred}'manually'${defaultcolor}' right-click on AppleSupport-v2.0.4-RELEASE.zip'
echo "and 'Download Linked File As...' and select ${vmname} for 'Where:'" echo ""
echo "and 'Download Linked File As...' then select ${vmname} for 'Where:'"
echo "from the dropdown menu. Then unbind the mouse cursor from the virtual" echo "from the dropdown menu. Then unbind the mouse cursor from the virtual"
printf 'machine with the '${whiteonblack}'right control key\033[0m.' printf 'machine with the '${whiteonblack}'right control key.'${defaultcolor}
read -p "Click here and press enter when the download is complete." read -p " Click here and press enter when the download is complete."
kbspecial="CMDprs q CMDrls" kbspecial="CMDprs q CMDrls"
sendspecial sendspecial
echo "" printf ${whiteonblack}'
read -p "Press enter when the macOS Utilities screen is ready." Press enter when the macOS Utilities screen is ready.'${defaultcolor}
read -p ""
kbspecial="CTRLprs F2 CTRLrls u ENTER t ENTER" kbspecial="CTRLprs F2 CTRLrls u ENTER t ENTER"
sendspecial sendspecial
promptterminalready promptterminalready
@@ -478,9 +487,11 @@ sendkeys
# create startup.nsh EFI script # create startup.nsh EFI script
kbstring='cd "/Volumes/'"${vmname}"'/mount_efi/" && vim startup.nsh' kbstring='cd "/Volumes/'"${vmname}"'/mount_efi/" && vim startup.nsh'
sendkeys sendkeys
echo ""
echo "Press enter when '\"startup.nsh\" [New File]' appears" printf ${whiteonblack}'
read -p "at the bottom of the terminal." Press enter when '${defaultcolor}'"startup.nsh" [New File]'${whiteonblack}' appears
at the bottom of the terminal.'${defaultcolor}
read -p ""
kbstring='Iecho -off'; sendkeys kbstring='Iecho -off'; sendkeys
kbstring='load fs0:\EFI\driver\AppleImageLoader.efi'; sendkeys kbstring='load fs0:\EFI\driver\AppleImageLoader.efi'; sendkeys
@@ -497,14 +508,17 @@ kbstring='endfor'; sendkeys
kbspecial="ESC : w q ENTER"; sendspecial kbspecial="ESC : w q ENTER"; sendspecial
# Shut down the virtual machine # Shut down the virtual machine
echo "" printf ${whiteonblack}'
read -p "Press enter when the terminal is ready." Press enter when the terminal is ready.'${defaultcolor}
read -p ""
kbstring='shutdown -h now' kbstring='shutdown -h now'
sendkeys sendkeys
echo "" echo ""
echo "Shutting down virtual machine." echo "Shutting down virtual machine."
read -p "Press enter when the virtual machine shutdown is complete." printf ${whiteonblack}'
Press enter when the virtual machine shutdown is complete.'${defaultcolor}
read -p ""
# detach installer from virtual machine # detach installer from virtual machine
VBoxManage storageattach "${vmname}" --storagectl SATA --port 1 --medium none VBoxManage storageattach "${vmname}" --storagectl SATA --port 1 --medium none
@@ -513,17 +527,18 @@ VBoxManage storageattach "${vmname}" --storagectl SATA --port 1 --medium none
# The VM will boot from the target virtual disk image and complete the installation. # The VM will boot from the target virtual disk image and complete the installation.
VBoxManage startvm "${vmname}" VBoxManage startvm "${vmname}"
echo "" printf '
echo "macOS Mojave 10.14.1 will now install and start up." macOS Mojave 10.14.1 will now install and start up.
echo ""
read -n 1 -p "Delete temporary files? [y/n] " delete '${whiteonred}'Delete temporary files?'${defaultcolor}
read -n 1 -p " [y/n] " delete
if [ "${delete}" == "y" ]; then if [ "${delete}" == "y" ]; then
# temporary files cleanup # temporary files cleanup
VBoxManage closemedium "BaseSystem.vdi" VBoxManage closemedium "BaseSystem.vdi"
VBoxManage closemedium "Install ${vmname}.vdi" VBoxManage closemedium "Install ${vmname}.vdi"
rm "BaseSystem.vdi" "Install ${vmname}.vdi" rm "BaseSystem.vdi" "Install ${vmname}.vdi"
fi
echo "" printf '
echo "macOS Mojave 10.14.1 installation should complete in a few minutes." macOS Mojave 10.14.1 installation should complete in a few minutes.
echo ""
echo "That's it. Enjoy your virtual machine." That'\''s it. Enjoy your virtual machine.'