OSDN Git Service

make gui optional
[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 fi
41
42 # go back to the beginning if user isn't happy with settings
43 # this loop wraps the rest of the installer
44 while ! iroot confirm; do
45
46     # warning message for artix
47     artixinfo
48
49     # ask for keyboard layout
50     asklayout
51     if head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY" | grep -q '[^ ][^ ]'; then
52         loadkeys $(head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")
53     fi
54     guimode && setxkbmap -layout $(tail -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")
55
56     asklocale
57
58     # artix and manjaro mirrors work differently
59     if command -v pacstrap; then
60         askmirrors
61     fi
62
63     askvm
64     askregion
65
66     while [ -z "$DISK" ]; do
67         wallstatus install
68         DISK=$(fdisk -l | grep -i '^Disk /.*:' | sed -e "\$aother (experimental)" | imenu -l "select disk> ")
69         if ! grep -q '^other' <<<"$DISK"; then
70             if ! echo "Install on $DISK ?
71 this will delete all existing data" | imenu -C; then
72                 unset DISK
73             fi
74         else
75             chmod +x /root/instantARCH/askdisk.sh
76             /root/instantARCH/askdisk.sh
77             if [ -e /tmp/loopaskdisk ]; then
78                 unset DISK
79                 rm /tmp/loopaskdisk
80             fi
81         fi
82     done
83
84     if ! grep -q '^other' <<<"$DISK"; then
85
86         echo "$DISK" | grep -o '/dev/[^:]*' | iroot i disk
87
88         if ! efibootmgr; then
89             echo "$DISK" | grep -o '/dev/[^:]*' | iroot i grubdisk
90         fi
91     fi
92
93     # choice between multiple nvidia drivers
94     if ! grep -iq manjaro /etc/os-release; then
95         askdrivers
96     fi
97
98     # create user and add to groups
99     askuser
100
101     while [ -z "$NEWHOSTNAME" ]; do
102         NEWHOSTNAME=$(imenu -i "enter name of this computer")
103     done
104
105     iroot hostname "$NEWHOSTNAME"
106
107     if imenu -c -i "edit advanced settings? (use only if you know what you're doing)"; then
108         /root/instantARCH/askadvanced.sh
109     fi
110
111     wallstatus install
112     SUMMARY="Installation Summary:"
113
114     addsum "Username" "user"
115     addsum "Locale" "locale"
116     addsum "Region" "region"
117     addsum "Nearest City" "city"
118     addsum "Keyboard layout" "keyboard"
119     addsum "Target install drive" "disk"
120     addsum "Hostname" "hostname"
121
122     if efibootmgr; then
123         SUMMARY="$SUMMARY
124 GRUB: UEFI"
125     else
126         SUMMARY="$SUMMARY
127 GRUB: BIOS"
128     fi
129
130     SUMMARY="$SUMMARY
131 Should installation proceed with these parameters?"
132
133     if imenu -C <<<"$SUMMARY"; then
134         iroot confirm 1
135     else
136         unset CITY
137         unset REGION
138         unset DISK
139         unset NEWKEY
140         unset NEWLOCALE
141         unset NEWPASS2
142         unset NEWPASS
143         unset NEWHOSTNAME
144         unset NEWUSER
145     fi
146
147 done
148
149 imenu -M <<<"The installation will now begin.
150 This could take a while.
151 Keep the machine powered and connected to the internet. 
152 After the installation, the machine will automatically reboot"