-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstallutils.sh
More file actions
executable file
·119 lines (104 loc) · 2.57 KB
/
installutils.sh
File metadata and controls
executable file
·119 lines (104 loc) · 2.57 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
#!/bin/bash
# functions used for the actual installation
# reset working dir
rcd() {
cd /root/instantARCH
}
# this gets executed if a module fails
# it marks the installation as failed
serror() {
# touching noerror skips error checking for one check
if [ -e /opt/noerror ]; then
echo "skipping error"
rm /opt/noerror
else
# indicator file
touch /opt/installfailed
echo "script failed"
exit 1
fi
}
# this sets the status message
# displayed at the bottom of the screen when using the GUI installer
setinfo() {
if [ -e /usr/share/liveutils ]; then
pkill instantmenu
fi
echo "$@" >/opt/instantprogress
echo "$@"
}
testecho() {
if [ -n "$INSTANTARCHTESTING" ]; then
echo "test-message:" "$@"
notify-send "$@"
fi
}
isdebug() {
if {
[ -n "$INSTALLDEBUG" ] || [ -e /tmp/installdebug ]
}; then
echo 'debugging mode is enabled'
return 0
else
return 1
fi
}
# run a script inside the installation medium
escript() {
STARTDURATION="$SECONDS"
setinfo "${2:-info}"
rcd
testecho "running native script $1"
./"$1".sh || serror
echo "$1" >>/tmp/instantprogress
debugmenu "$1"
}
# scripts executed in installed environment
chrootscript() {
STARTDURATION="$SECONDS"
setinfo "${2:-info}"
# check if chroot environment is working
if ! mount | grep -q '/mnt'; then
echo "mount failed"
exit 1
fi
rcd
testecho "running chroot script $1"
arch-chroot /mnt "/root/instantARCH/${1}.sh" || serror
echo "chroot: $1" >>/tmp/instantprogress
debugmenu "$1"
}
# allows pausing the installer after each step
debugmenu() {
{
[ -n "$INSTALLDEBUG" ] || [ -e /tmp/installdebug ]
} || return 0
DURATION="$((SECONDS - STARTDURATION))"
DEBUGCHOICE="$(
{
echo "> ran task $1"
echo "> took $DURATION seconds"
echo ":ypause"
echo ":rcancel"
echo ":gcontinue"
} | imenu -l "debug menu"
)"
case "$DEBUGCHOICE" in
*pause)
echo 'pausing installation'
touch /tmp/installpause
echo 'installation paused, waiting for removal of /tmp/installpause'
while [ -e /tmp/installpause ]; do
sleep 10
done
;;
*cancel)
echo 'quitting installation'
echo 'TODO: implement'
;;
*continue)
echo "continuing installation"
;;
esac
STARTDURATION=0
}