OSDN Git Service

fix flatpak opener
[instantos/instantARCH.git] / ask.sh
1 #!/bin/bash
2
3 # This is the interactive part of the installer
4 # Everything requiring user input is asked first,
5 # NO INSTALLATION IS DONE IN THIS SCRIPT
6 # Results get saved in /root/instantARCH/config
7 # and read out during installation
8 # results also get copied to the target root partition
9
10 mkdir /root/instantARCH/config
11 mkdir config
12
13 source <(curl -Ls git.io/paperbash)
14 pb dialog
15
16 source /root/instantARCH/askutils.sh
17
18 if [ -e /usr/share/liveutils ] && ! [ -e /tmp/nogui ]; then
19     echo "GUI Mode active"
20     export GUIMODE="True"
21     GUIMODE="True"
22 fi
23
24 # switch imenu to fzf and dialog
25 if ! guimode; then
26     touch /tmp/climenu
27     imenu -m "Welcome to the instantOS installer"
28 else
29     NEXTCHOICE="$(echo '>>h              Welcome to the instantOS installer
30 :g Next
31 :r ﰸCancel' | instantmenu -q 'select using the mouse, keywords and arrow keys' -i -l 209 -h -1 -bw 8 -a 60 -w -1 -c)"
32
33     if grep -iq 'cancel' <<<"$NEXTCHOICE"; then
34         echo "canceling installation"
35         mkdir /opt/instantos
36         touch /opt/instantos/installcanceled
37         touch /opt/instantos/statuscanceled
38         exit 1
39     fi
40     if iroot installtest
41     then
42         imenu -m "WARNING: you're running a test version of the installer"
43     fi
44 fi
45
46 # go back to the beginning if user isn't happy with settings
47 # this loop wraps the rest of the installer
48 while ! iroot confirm; do
49
50     # warning message for artix
51     artixinfo
52
53     # ask for keyboard layout
54     asklayout
55     if head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY" | grep -q '[^ ][^ ]'; then
56         loadkeys "$(head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")"
57     fi
58     guimode && setxkbmap -layout "$(tail -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")"
59
60     asklocale
61
62     # artix and manjaro mirrors work differently
63     if command -v pacstrap; then
64         askmirrors
65     fi
66
67     askvm
68     askregion
69
70     while [ -z "$DISK" ]; do
71         wallstatus install
72         DISK=$(fdisk -l | grep -i '^Disk /.*:' | sed -e "\$aother (experimental)" | imenu -l "select disk> ")
73         if ! grep -q '^other' <<<"$DISK"; then
74             if ! echo "Install on $DISK ?
75 this will delete all existing data" | imenu -C; then
76                 unset DISK
77             fi
78         else
79             chmod +x /root/instantARCH/askdisk.sh
80             /root/instantARCH/askdisk.sh
81             if [ -e /tmp/loopaskdisk ]; then
82                 unset DISK
83                 rm /tmp/loopaskdisk
84             fi
85         fi
86     done
87
88     if ! grep -q '^other' <<<"$DISK"; then
89
90         echo "$DISK" | grep -o '/dev/[^:]*' | iroot i disk
91
92         if ! efibootmgr; then
93             echo "$DISK" | grep -o '/dev/[^:]*' | iroot i grubdisk
94         fi
95     fi
96
97     # choice between multiple nvidia drivers
98     if ! grep -iq manjaro /etc/os-release; then
99         askdrivers
100     fi
101
102     # create user and add to groups
103     askuser
104
105     while [ -z "$NEWHOSTNAME" ]; do
106         NEWHOSTNAME=$(imenu -i "enter name of this computer")
107     done
108
109     iroot hostname "$NEWHOSTNAME"
110
111     if imenu -c -i "edit advanced settings? (use only if you know what you're doing)"; then
112         /root/instantARCH/askadvanced.sh
113     fi
114
115     wallstatus install
116     SUMMARY="Installation Summary:"
117
118     addsum "Username" "user"
119     addsum "Locale" "locale"
120     addsum "Region" "region"
121     addsum "Subregion" "city"
122     addsum "Keyboard layout" "keyboard"
123     addsum "Target install drive" "disk"
124     addsum "Hostname" "hostname"
125
126     if efibootmgr; then
127         SUMMARY="$SUMMARY
128 GRUB: UEFI"
129     else
130         SUMMARY="$SUMMARY
131 GRUB: BIOS"
132     fi
133
134     SUMMARY="$SUMMARY
135 Should installation proceed with these parameters?"
136
137     echo "summary:
138 $SUMMARY"
139
140     if imenu -C <<<"$SUMMARY"; then
141         iroot confirm 1
142     else
143         unset CITY
144         unset REGION
145         unset DISK
146         unset NEWKEY
147         unset NEWLOCALE
148         unset NEWPASS2
149         unset NEWPASS
150         unset NEWHOSTNAME
151         unset NEWUSER
152     fi
153
154 done
155
156 imenu -M <<<'The installation will now begin.
157 This could take a while.
158 You can check install progress by clicking on "2" in the top right
159 Keep the machine powered and connected to the internet. 
160 After the installation, the machine will automatically reboot'