OSDN Git Service

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