OSDN Git Service

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