-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathstep2.sh
More file actions
executable file
·140 lines (116 loc) · 4.11 KB
/
step2.sh
File metadata and controls
executable file
·140 lines (116 loc) · 4.11 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/sh
# SPDX-License-Identifier: MIT
set -e
VGID="##VGID##"
PREBOOT="##PREBOOT##"
self="$0"
cd "${self%%step2.sh}"
system_dir="$(cd ../../../; pwd)"
os_name="${system_dir##*/}"
# clear
printf '\033[2J\033[H'
echo "Asahi Linux installer (second step)"
echo
echo "VGID: $VGID"
echo "System volume: $system_dir"
echo
bputil -d -v "$VGID" >/tmp/bp.txt
if ! grep -q ': Paired' /tmp/bp.txt; then
echo "Your system did not boot into the correct recoveryOS."
echo
echo "Each OS in your machine comes with its own copy of recoveryOS."
echo "In order to complete the installation, we need to boot into"
echo "the brand new recoveryOS that matches the OS which you are"
echo "installing. The final installation step cannot be completed from"
echo "a different recoveryOS."
echo
echo "Normally this should happen automatically after the initial"
echo "installer sets up your new OS as the default boot option,"
echo "but it seems something went wrong there. Let's try that again."
echo
echo "Press enter to continue."
read
while ! bless --setBoot --mount "$system_dir"; do
echo
echo "bless failed. Did you mistype your password?"
echo "Press enter to try again."
read
done
echo
echo "Phew, hopefully that fixed it!"
echo
echo "Your system will now shut down. Once the screen goes blank,"
echo "please wait 10 seconds, then press the power button and do not"
echo "release it until you see the 'Entering startup options...'"
echo "message, then select '$os_name' again."
echo
echo "Press enter to shut down your system."
read
shutdown -h now
exit 1
fi
if ! grep -q 'one true recoveryOS' /tmp/bp.txt; then
echo "Your system did not boot in One True RecoveryOS (1TR) mode."
echo
echo "To finish the installation, the system must be in this special"
echo "mode. Perhaps you forgot to hold down the power button, or"
echo "momentarily released it at some point?"
echo
echo "Note that tapping and then pressing the power button again will"
echo "allow you to see the boot picker screen, but you will not be"
echo "in the correct 1TR mode. You must hold down the power button"
echo "in one continuous motion as you power on the machine."
echo
echo "Your system will now shut down. Once the screen goes blank,"
echo "please wait 10 seconds, then press the power button and do not"
echo "release it until you see the 'Entering startup options...'"
echo "message, then select '$os_name' again."
echo
echo "Press enter to shut down your system."
read
shutdown -h now
exit 1
fi
echo "You will be prompted for login credentials two times."
echo "Please enter your macOS credentials (for the macOS that you"
echo "used to run the first step of the installation)."
echo
echo "Press enter to continue."
echo
read
while ! bputil -nc -v "$VGID"; do
echo
echo "bputil failed. Did you mistype your password?"
echo "Press enter to try again."
read
done
echo
echo
if [ -e "/System/Volumes/iSCPreboot/$VGID/boot" ]; then
# This is an external volume, and kmutil has a problem with trying to pick
# up the AdminUserRecoveryInfo.plist from the wrong place. Work around that.
diskutil mount "$PREBOOT"
preboot="$(diskutil info "$PREBOOT" | grep "Mount Point" | sed 's, *Mount Point: *,,')"
cp -R "$preboot/$VGID/var" "/System/Volumes/iSCPreboot/$VGID/"
fi
while ! kmutil configure-boot -c boot.bin --raw --entry-point 2048 --lowest-virtual-address 0 -v "$system_dir"; do
echo
echo "kmutil failed. Did you mistype your password?"
echo "Press enter to try again."
read
done
echo
echo "Wrapping up..."
echo
mount -u -w "$system_dir"
if [ -e "$system_dir/.IAPhysicalMedia" ]; then
mv "$system_dir/.IAPhysicalMedia" "$system_dir/IAPhysicalMedia-disabled.plist"
fi
if [ -e "$system_dir/System/Library/CoreServices/SystemVersion-disabled.plist" ]; then
mv -f "$system_dir/System/Library/CoreServices/SystemVersion"{-disabled,}".plist"
fi
chflags hidden "$system_dir"
echo
echo "Installation complete! Press enter to reboot."
read
reboot