OSDN Git Service

fix disk selection loop
[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     # ask for keyboard layout
36     asklayout
37     if head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY" | grep -q '[^ ][^ ]'; then
38         loadkeys $(head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")
39     fi
40     guimode && setxkbmap -layout $(tail -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")
41
42     asklocale
43     askmirrors
44     askvm
45     askregion
46
47     while [ -z "$DISK" ]; do
48         wallstatus install
49         DISK=$(fdisk -l | grep -i '^Disk /.*:' | sed -e "\$aother (experimental)" | imenu -l "select disk> ")
50         if ! grep -q '^other' <<<"$DISK"; then
51             if ! echo "Install on $DISK ?
52 this will delete all existing data" | imenu -C; then
53                 unset DISK
54             fi
55         else
56             chmod +x /root/instantARCH/askdisk.sh
57             /root/instantARCH/askdisk.sh
58             if [ -e /tmp/loopaskdisk ]; then
59                 unset DISK
60                 rm /tmp/loopaskdisk
61             fi
62         fi
63     done
64
65     if ! grep -q '^other' <<<"$DISK"; then
66
67         echo "$DISK" | grep -o '/dev/[^:]*' | iroot i disk
68
69         if ! efibootmgr; then
70             echo "$DISK" | grep -o '/dev/[^:]*' | iroot i grubdisk
71         fi
72     fi
73
74     # choice between multiple nvidia drivers
75     askdrivers
76
77     # create user and add to groups
78     askuser
79
80     while [ -z "$NEWHOSTNAME" ]; do
81         NEWHOSTNAME=$(imenu -i "enter name of this computer")
82     done
83
84     iroot hostname "$NEWHOSTNAME"
85
86     wallstatus install
87     SUMMARY="Installation Summary:"
88
89     addsum "Username" "user"
90     addsum "Locale" "locale"
91     addsum "Region" "region"
92     addsum "Nearest City" "city"
93     addsum "Keyboard layout" "keyboard"
94     addsum "Target install drive" "disk"
95     addsum "Hostname" "hostname"
96
97     if efibootmgr; then
98         SUMMARY="$SUMMARY
99 GRUB: UEFI"
100     else
101         SUMMARY="$SUMMARY
102 GRUB: BIOS"
103     fi
104
105     SUMMARY="$SUMMARY
106 Should installation proceed with these parameters?"
107
108     if imenu -C <<<"$SUMMARY"; then
109         iroot confirm 1
110     else
111         unset CITY
112         unset REGION
113         unset DISK
114         unset NEWKEY
115         unset NEWLOCALE
116         unset NEWPASS2
117         unset NEWPASS
118         unset NEWHOSTNAME
119         unset NEWUSER
120     fi
121
122 done
123
124 imenu -M <<<"The installation will now begin.
125 This could take a while.
126 Keep the machine powered and connected to the internet"