OSDN Git Service

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