-
Notifications
You must be signed in to change notification settings - Fork 6
/
archinstall.sh
executable file
·339 lines (282 loc) · 8.28 KB
/
archinstall.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#!/bin/bash
##############################################
## The official installer for instantOS ##
##############################################
# Main startup script
if [ "$1" = "test" ]; then
echo "using testing branch"
export TESTBRANCH="${2:-testing}"
if [ -n "$3" ]; then
export CUSTOMINSTANTREPO="$3"
fi
echo "using installer branch $TESTBRANCH"
fi
USEBRANCH="${TESTBRANCH:-main}"
GITHUBRAW='https://raw.githubusercontent.com/instantos'
source /root/instantARCH/moduleutils.sh
if ! whoami | grep -iq '^root'; then
echo "not running as root, switching"
curl -s "$GITHUBRAW/instantARCH/$USEBRANCH/archinstall.sh" | sudo bash
exit
fi
# import general utils
source <(curl -Ls "$GITHUBRAW/instantARCH/$USEBRANCH/utils.sh")
command -v updaterepos &>/dev/null || {
echo "failed to import utils, github might be down"
exit 1
}
if [ -e /usr/share/liveutils ]; then
pgrep instantmenu || echo "preparing installation
OK" | instantmenu -c -bw 4 -l 2 &
else
# print logo
echo ""
echo ""
curl -s "$GITHUBRAW/instantLOGO/$USEBRANCH/ascii.txt" | sed 's/^/ /g'
echo ""
echo ""
fi
# this is duplicate code but getting rid of it would require much more code
# prevent multiple instances from being launched
if [ -e /tmp/instantarchpid ]; then
echo "pidfile found"
if kill -0 "$(cat /tmp/instantarchpid)"; then
notify-send "installer already running, please do not start multiple instances"
exit 1
fi
else
echo "$$" >/tmp/instantarchpid
fi
if ! command -v imenu; then
touch /tmp/removeimenu
fi
command -v tzupdate && ! pgrep tzupdate && sudo tzupdate &
# updated mirrorlist
echo "updating mirrorlist"
curl -s "$GITHUBRAW"/instantOS/main/repo.sh | bash
# download imenu
curl -s "$GITHUBRAW"/imenu/main/imenu.sh >/usr/bin/imenu
chmod 755 /usr/bin/imenu
while ! command -v imenu; do
echo "installing imenu"
curl -s "$GITHUBRAW"/imenu/main/imenu.sh >/usr/bin/imenu
chmod 755 /usr/bin/imenu
done
setinfo() {
if [ -e /usr/share/liveutils ]; then
pkill instantmenu
fi
echo "$@" >/opt/instantprogress
echo "$@"
}
if command -v python; then
echo "import time; time.sleep(10009)" | python &
sleep 2
pkill python3
fi
if ! command -v git; then
while [ -z "$CONTINUEINSTALLATION" ]; do
if ! updaterepos || ! yes | pacman -S git --needed; then
yes | pacman -Scc
updaterepos
else
export CONTINUEINSTALLATION="true"
fi
done
fi
# ensure git is working
if ! git --version; then
if git --version 2>&1 | grep -i glibc; then
echo "upgrading glibc"
pacman -Sy glibc --noconfirm || exit 1
fi
if ! git --version; then
echo "git is not working on your system."
echo "installing instantOS requires git to be installed and working"
exit 1
fi
fi
cd /root || exit 1
if [ -e instantARCH ]; then
echo "removing previous instantARCH data"
rm -rf instantARCH
fi
if [ -n "$TESTBRANCH" ]; then
if [ -n "$3" ]; then
export CUSTOMINSTANTREPO="$3"
fi
echo "using installer branch $TESTBRANCH"
git clone --single-branch --branch "$TESTBRANCH" --depth=1 https://github.com/instantos/instantARCH.git
export INSTANTARCHTESTING="true"
else
git clone --depth=1 https://github.com/instantos/instantARCH.git
fi
cd instantARCH || exit 1
mkdir config &>/dev/null
git rev-parse HEAD >config/instantarchversion
# use alternative versions of the installer
if [ -n "$1" ]; then
case "$1" in
"manual")
if ! [ -e /root/manualarch ]; then
echo "no manual instantARCH version found. Please clone it to /root/manualarch"
sleep 5
echo "exiting"
exit
fi
rm -rf ./*
cp -r /root/manualarch/* .
export INSTANTARCHMANUAL="true"
;;
*)
echo "running normal installer version"
;;
esac
fi
chmod +x ./*.sh
chmod +x ./*/*.sh
isdebug() {
if {
[ -n "$INSTALLDEBUG" ] || [ -e /tmp/installdebug ]
}; then
echo 'debugging mode is enabled'
return 0
else
return 1
fi
}
if isdebug; then
echo 'debugging mode enabled'
if [ -e /tmp/debugname ]; then
echo "debugging name: $(cat /tmp/installdebug)"
fi
fi
./depend/depend.sh
./artix/preinstall.sh
checkguimode
if guimode; then
# ensure instantmenu is working
if ! instantmenu -v; then
if instantmenu -v 2>&1 | grep -i glibc; then
echo "upgrading glibc"
pacman -Sy
pacman -S archlinux-keyring --noconfirm || exit 1
pacman -S glibc --noconfirm || exit 1
fi
if ! instantmenu -v; then
echo "instantmenu is not working on your system."
echo "installing instantOS requires instantmenu to be installed and working"
exit 1
fi
fi
fi
if [ -n "$INSTANTARCHTESTING" ]; then
echo "install config"
iroot installtest 1
fi
[ -e /usr/share/liveutils ] && pkill instantmenu
cd /root/instantARCH || exit
./ask.sh || {
if ! [ -e /opt/instantos/installcanceled ] && ! iroot cancelinstall; then
imenu -m "ask failed"
echo "ask failed" && exit
else
rm /opt/instantos/installcanceled
instantwallpaper set /usr/share/instantwallpaper/defaultphoto.png
# clear up installation data
rm -rf /root/instantARCH
pkill instantosinstall
sleep 1
pkill -f instantosinstall
pkill instantosinstaller
sleep 1
pkill -f instantosinstaller
exit
fi
}
if ! iroot confirm; then
echo "no confirmation found, installation cancelled"
exit
fi
unset IMENUACCEPTEMPTY
chmod +x ./*.sh
chmod +x ./**/*.sh
# pacstrap base system
echo "local install"
./localinstall.sh 2>&1 | tee /opt/localinstall &&
echo "system install" &&
./systeminstall.sh 2>&1 | tee /opt/systeminstall # install rest of the system
pkill imenu
pkill instantmenu
sudo pkill imenu
sudo pkill instantmenu
sleep 2
uploadlogs() {
echo "uploading installation log"
cat /opt/localinstall >/opt/install.log
if [ -e /opt/systeminstall ]; then
cat /opt/systeminstall >>/opt/install.log
fi
cd /opt || exit
cp /root/instantARCH/data/netrc ~/.netrc
curl -n -F 'f:[email protected]' ix.io
}
if isdebug && [ -e /tmp/debugname ]; then
echo "debug name: $(cat /tmp/debugname)"
fi
# ask to reboot, upload error data if install failed
if [ -z "$INSTANTARCHTESTING" ] && ! isdebug; then
if ! [ -e /opt/installfailed ] || ! [ -e /opt/installsuccess ]; then
echo 'installation was successful'
if command -v installapplet; then
sleep 2
if iroot logging; then
notify-send "uploading logs"
uploadlogs
sleep 2
fi
fi
# xorg breaks on isos older than beta 7, instantdotfiles cli was removed in beta 7
# auto restart should only happen on beta 7 iso and newer
if command -v instantdotfiles; then
reboot
else
# TODO: offer choice of uploading logs
if guimode; then
while [ -z "$FINISHCHOICE" ]; do
FINISHCHOICE="$(echo '>>h instantOS was installed successfully
:g Continue using live session
:y 勒Reboot Now' | instantmenu -q 'select using the mouse, keywords and arrow keys' -i -l 209 -h -1 -bw 8 -a 60 -w -1 -c)"
done
else
FINISHCHOICE="$(echo 'Continue using live session
Reboot Now' | imenu -l "installation successful")"
fi
if grep -iq 'reboot now' <<<"$FINISHCHOICE"; then
echo "rebooting now"
reboot
fi
fi
else
echo "installation failed
please go to https://instantos.io/support
for assistance or error reporting" | imenu -M
echo "uploading error data"
echo "installaion failed"
if imenu -c "upload installation log for easier troubleshooting?"; then
uploadlogs
fi
fi
else
uploadlogs
fi
if [ -e /tmp/removeimenu ]; then
rm /usr/bin/imenu
fi
echo "installation finished"
echo ""
echo ""
curl -s "$GITHUBRAW"'/instantLOGO/main/ascii.txt' | sed 's/^/ /g'
echo ""
echo ""
echo "the system can now be safely rebooted"