-
Notifications
You must be signed in to change notification settings - Fork 18
/
run.sh
executable file
·56 lines (46 loc) · 1.61 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Bash strict mode, exit on failing command
set -e
echo "*** Checking for firmware files"
if [ ! -f firmware/OVMF_VARS-1024x768.fd ]; then
mkdir firmware
cp -a packaged-firmware/OVMF_VARS-1024x768.fd firmware/
fi
echo "*** Checking for Base System files"
echo "*** Check if dmg2img is available"
which dmg2img
echo "*** Check if BaseSystem dmg is downloaded. If downloaded convert to img"
if [ ! -f BaseSystem/BaseSystem.dmg ]; then
echo "*** Downloading BaseSystem dmg"
if python3 fetch-macos.py -o BaseSystem "$@"; then
echo "*** BaseSystem dmg downloaded."
else
echo "Failed to download base system."
exit 1
fi
fi
echo "*** BaseSystem dmg available."
echo "*** Check if BaseSystem dmg has been converted to img before."
if [ ! -f BaseSystem/BaseSystem.img ]; then
echo "*** Converting BaseSystem dmg to img."
dmg2img BaseSystem/BaseSystem.dmg BaseSystem/BaseSystem.img
fi
echo "*** BaseSystem img available."
echo "*** Checking for disk image"
if [ ! -f macos.qcow2 ]; then
qemu-img create -f qcow2 macos.qcow2 64G
fi
echo "*** Check if installer has been run"
# Probably a better way to do this, but checking the size of the macos qcow is probably best.
# If it's over an arbitrary size, we can guess the install finished
# On my machine a basic qcow is 262192 bytes, but let's put a buffer of 2x that
qcowfilesize=$(stat -c %s macos.qcow2)
if [ $qcowfilesize -gt 524384 ]; then
echo "*** Looks like the install was done, launching"
echo "*** Launch!"
exec ./launch-macos.sh
else
echo "*** Looks like the install hasn't been done yet, lets install"
echo "*** Install!"
exec ./install-macos.sh
fi