absolute path for WSL only
This commit is contained in:
+25
-12
@@ -2,7 +2,7 @@
|
|||||||
# One-key semi-automatic installer of macOS on VirtualBox
|
# One-key semi-automatic installer 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/macos-guest-virtualbox
|
# url: https://github.com/img2tab/macos-guest-virtualbox
|
||||||
# version 0.45
|
# version 0.46
|
||||||
|
|
||||||
# Requirements: 33.5GB available storage on host
|
# Requirements: 33.5GB available storage on host
|
||||||
# Dependencies: bash>=4.0, unzip, wget, dmg2img,
|
# Dependencies: bash>=4.0, unzip, wget, dmg2img,
|
||||||
@@ -99,6 +99,13 @@ if [ -z "$(VBoxManage -v 2>/dev/null)" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# WSL working directory hijinks
|
||||||
|
tmp_path=""
|
||||||
|
if [[ "$(cat /proc/sys/kernel/osrelease 2>/dev/null)" == *"Microsoft"* ]]; then
|
||||||
|
tmp_path="${PWD}/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# dmg2img
|
# dmg2img
|
||||||
if [ -z "$(dmg2img -d 2>/dev/null)" ]; then
|
if [ -z "$(dmg2img -d 2>/dev/null)" ]; then
|
||||||
if [ -z "$(cygcheck -V 2>/dev/null)" ]; then
|
if [ -z "$(cygcheck -V 2>/dev/null)" ]; then
|
||||||
@@ -169,9 +176,15 @@ or http://swscan.apple.com/content/catalogs/others/
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
echo "Downloaded BaseSystem.dmg. Converting to BaseSystem.img"
|
echo "Downloaded BaseSystem.dmg. Converting to BaseSystem.img"
|
||||||
dmg2img "BaseSystem.dmg" "BaseSystem.img"
|
if [ -n "$(${PWD}/dmg2img -d 2>/dev/null)" ]; then
|
||||||
VBoxManage convertfromraw --format VDI "${PWD}/BaseSystem.img" "${PWD}/BaseSystem.vdi"
|
${PWD}/dmg2img "BaseSystem.dmg" "BaseSystem.img"
|
||||||
rm "BaseSystem.dmg" "BaseSystem.img"
|
else
|
||||||
|
dmg2img "BaseSystem.dmg" "BaseSystem.img"
|
||||||
|
fi
|
||||||
|
VBoxManage convertfromraw --format VDI "${tmp_path}BaseSystem.img" "${tmp_path}BaseSystem.vdi"
|
||||||
|
if [ -s BaseSystem.vdi ]; then
|
||||||
|
rm "BaseSystem.dmg" "BaseSystem.img" 2>/dev/null
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +199,7 @@ elif [ "${storagesize}" -lt 22000 ]; then
|
|||||||
else
|
else
|
||||||
echo "Creating ${vmname} target system virtual disk image."
|
echo "Creating ${vmname} target system virtual disk image."
|
||||||
VBoxManage createmedium --size="${storagesize}" \
|
VBoxManage createmedium --size="${storagesize}" \
|
||||||
--filename "${PWD}/${vmname}.vdi" \
|
--filename "${tmp_path}${vmname}.vdi" \
|
||||||
--variant standard 2>/dev/tty
|
--variant standard 2>/dev/tty
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -198,7 +211,7 @@ if [ -r "Install ${vmname}.vdi" ]; then
|
|||||||
else
|
else
|
||||||
echo "Creating ${vmname} installation media virtual disk image."
|
echo "Creating ${vmname} installation media virtual disk image."
|
||||||
VBoxManage createmedium --size=8000 \
|
VBoxManage createmedium --size=8000 \
|
||||||
--filename "${PWD}/Install ${vmname}.vdi" \
|
--filename "${tmp_path}Install ${vmname}.vdi" \
|
||||||
--variant fixed 2>/dev/tty
|
--variant fixed 2>/dev/tty
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -208,11 +221,11 @@ fi
|
|||||||
function attach_initial_storage() {
|
function attach_initial_storage() {
|
||||||
VBoxManage storagectl "${vmname}" --add sata --name SATA --hostiocache on
|
VBoxManage storagectl "${vmname}" --add sata --name SATA --hostiocache on
|
||||||
VBoxManage storageattach "${vmname}" --storagectl SATA --port 0 \
|
VBoxManage storageattach "${vmname}" --storagectl SATA --port 0 \
|
||||||
--type hdd --nonrotational on --medium "${PWD}/${vmname}.vdi"
|
--type hdd --nonrotational on --medium "${tmp_path}${vmname}.vdi"
|
||||||
VBoxManage storageattach "${vmname}" --storagectl SATA --port 1 \
|
VBoxManage storageattach "${vmname}" --storagectl SATA --port 1 \
|
||||||
--type hdd --nonrotational on --medium "${PWD}/Install ${vmname}.vdi"
|
--type hdd --nonrotational on --medium "${tmp_path}Install ${vmname}.vdi"
|
||||||
VBoxManage storageattach "${vmname}" --storagectl SATA --port 2 \
|
VBoxManage storageattach "${vmname}" --storagectl SATA --port 2 \
|
||||||
--type hdd --nonrotational on --medium "${PWD}/BaseSystem.vdi"
|
--type hdd --nonrotational on --medium "${tmp_path}BaseSystem.vdi"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Configure the VM
|
# Configure the VM
|
||||||
@@ -630,8 +643,8 @@ read -n 1 -p " [y/n] " delete 2>/dev/tty
|
|||||||
echo ""
|
echo ""
|
||||||
if [ "${delete}" == "y" ]; then
|
if [ "${delete}" == "y" ]; then
|
||||||
# temporary files cleanup
|
# temporary files cleanup
|
||||||
VBoxManage closemedium "BaseSystem.vdi"
|
VBoxManage closemedium "${tmp_path}BaseSystem.vdi"
|
||||||
VBoxManage closemedium "Install ${vmname}.vdi"
|
VBoxManage closemedium "${tmp_path}Install ${vmname}.vdi"
|
||||||
rm "BaseSystem.vdi" "Install ${vmname}.vdi"
|
rm "BaseSystem.vdi" "Install ${vmname}.vdi"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -663,5 +676,5 @@ if [ -z "${1}" ]; then
|
|||||||
else
|
else
|
||||||
check_dependencies
|
check_dependencies
|
||||||
initialize_script_functions
|
initialize_script_functions
|
||||||
${1}
|
for argument in $@; do ${argument}; done
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user