OSDN Git Service

add comments
[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 ! [ -e /root/instantARCH/config/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
44     askregion
45
46     while [ -z "$DISK" ]; do
47         wallstatus install
48         DISK=$(fdisk -l | grep -i '^Disk /.*:' | imenu -l "select disk> ")
49         if ! echo "Install on $DISK ?
50 this will delete all existing data" | imenu -C; then
51             unset DISK
52         fi
53     done
54
55     echo "$DISK" | grep -o '/dev/[^:]*' >/root/instantARCH/config/disk
56
57     # choice between multiple nvidia drivers
58     askdrivers
59
60     # create user and add to groups
61     askuser
62
63     while [ -z "$NEWHOSTNAME" ]; do
64         NEWHOSTNAME=$(imenu -i "enter name of this computer")
65     done
66
67     echo "$NEWHOSTNAME" >/root/instantARCH/config/hostname
68
69     wallstatus install
70     SUMMARY="Installation Summary:"
71
72     addsum "Username" "user"
73     addsum "Locale" "locale"
74     addsum "Region" "region"
75     addsum "Nearest City" "city"
76     addsum "Keyboard layout" "keyboard"
77     addsum "Target install drive" "disk"
78     addsum "Hostname" "hostname"
79
80     if efibootmgr; then
81         SUMMARY="$SUMMARY
82 GRUB: UEFI"
83     else
84         SUMMARY="$SUMMARY
85 GRUB: BIOS"
86     fi
87
88     SUMMARY="$SUMMARY
89 Should installation proceed with these parameters?"
90
91     if imenu -C <<<"$SUMMARY"; then
92         touch /root/instantARCH/config/confirm
93     else
94         unset CITY
95         unset REGION
96         unset DISK
97         unset NEWKEY
98         unset NEWLOCALE
99         unset NEWPASS2
100         unset NEWPASS
101         unset NEWHOSTNAME
102         unset NEWUSER
103     fi
104
105 done
106
107 imenu -M <<<"The installation will now begin.
108 This could take a while.
109 Keep the machine powered and connected to the internet"