OSDN Git Service

fix flatpak opener
[instantos/instantARCH.git] / ask.sh
diff --git a/ask.sh b/ask.sh
index 4afb80d..35dc3ca 100755 (executable)
--- a/ask.sh
+++ b/ask.sh
 #!/bin/bash
 
+# This is the interactive part of the installer
+# Everything requiring user input is asked first,
+# NO INSTALLATION IS DONE IN THIS SCRIPT
+# Results get saved in /root/instantARCH/config
+# and read out during installation
+# results also get copied to the target root partition
+
 mkdir /root/instantARCH/config
 mkdir config
 
 source <(curl -Ls git.io/paperbash)
 pb dialog
 
-messagebox "welcome to instantARCH, the easy arch installer"
+source /root/instantARCH/askutils.sh
+
+if [ -e /usr/share/liveutils ] && ! [ -e /tmp/nogui ]; then
+    echo "GUI Mode active"
+    export GUIMODE="True"
+    GUIMODE="True"
+fi
+
+# switch imenu to fzf and dialog
+if ! guimode; then
+    touch /tmp/climenu
+    imenu -m "Welcome to the instantOS installer"
+else
+    NEXTCHOICE="$(echo '>>h              Welcome to the instantOS installer
+:g Next
+:r ﰸCancel' | instantmenu -q 'select using the mouse, keywords and arrow keys' -i -l 209 -h -1 -bw 8 -a 60 -w -1 -c)"
+
+    if grep -iq 'cancel' <<<"$NEXTCHOICE"; then
+        echo "canceling installation"
+        mkdir /opt/instantos
+        touch /opt/instantos/installcanceled
+        touch /opt/instantos/statuscanceled
+        exit 1
+    fi
+    if iroot installtest
+    then
+        imenu -m "WARNING: you're running a test version of the installer"
+    fi
+fi
 
 # go back to the beginning if user isn't happy with settings
-while ! [ -e /root/instantARCH/config/confirm ]; do
-    cd /root/instantARCH/data/lang/keyboard
-    while [ -z "$NEWKEY" ]; do
-        NEWKEY="$(ls | fzf --prompt 'Select keyboard layout> ')"
-    done
+# this loop wraps the rest of the installer
+while ! iroot confirm; do
 
-    echo "$NEWKEY" >/root/instantARCH/config/keyboard
-
-    loadkeys $(tail -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")
-
-    cd ../locale
-    while [ -z "$NEWLOCALE" ]; do
-        NEWLOCALE="$(ls | fzf --prompt 'Select language> ')"
-    done
-    echo "$NEWLOCALE" >/root/instantARCH/config/locale
+    # warning message for artix
+    artixinfo
 
-    cd /usr/share/zoneinfo
+    # ask for keyboard layout
+    asklayout
+    if head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY" | grep -q '[^ ][^ ]'; then
+        loadkeys "$(head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")"
+    fi
+    guimode && setxkbmap -layout "$(tail -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY")"
 
-    while [ -z "$REGION" ]; do
-        REGION=$(ls | fzf --prompt "select region> ")
-    done
+    asklocale
 
-    if [ -d "$REGION" ]; then
-        cd "$REGION"
-        while [ -z "$CITY" ]; do
-            CITY=$(ls | fzf --prompt "select the City nearest to you> ")
-        done
+    # artix and manjaro mirrors work differently
+    if command -v pacstrap; then
+        askmirrors
     fi
 
-    echo "$REGION" >/root/instantARCH/config/region
-    [ -n "$CITY" ] && echo "$CITY" >/root/instantARCH/config/city
+    askvm
+    askregion
 
     while [ -z "$DISK" ]; do
-        DISK=$(fdisk -l | grep -i '^Disk /.*:' | fzf --prompt "select disk> ")
-        if ! confirm "Install on $DISK ?\n this will delete all existing data"; then
-            unset DISK
+        wallstatus install
+        DISK=$(fdisk -l | grep -i '^Disk /.*:' | sed -e "\$aother (experimental)" | imenu -l "select disk> ")
+        if ! grep -q '^other' <<<"$DISK"; then
+            if ! echo "Install on $DISK ?
+this will delete all existing data" | imenu -C; then
+                unset DISK
+            fi
+        else
+            chmod +x /root/instantARCH/askdisk.sh
+            /root/instantARCH/askdisk.sh
+            if [ -e /tmp/loopaskdisk ]; then
+                unset DISK
+                rm /tmp/loopaskdisk
+            fi
         fi
     done
 
-    echo "$DISK" | grep -o '/dev/[^:]*' >/root/instantARCH/config/disk
+    if ! grep -q '^other' <<<"$DISK"; then
 
-    NEWUSER="$(textbox 'set username')"
+        echo "$DISK" | grep -o '/dev/[^:]*' | iroot i disk
 
-    while ! [ "$NEWPASS" = "$NEWPASS2" ] || [ -z "$NEWPASS" ]; do
-        NEWPASS="$(passwordbox 'set password')"
-        NEWPASS2="$(passwordbox 'confirm password')"
-    done
+        if ! efibootmgr; then
+            echo "$DISK" | grep -o '/dev/[^:]*' | iroot i grubdisk
+        fi
+    fi
+
+    # choice between multiple nvidia drivers
+    if ! grep -iq manjaro /etc/os-release; then
+        askdrivers
+    fi
 
-    echo "$NEWUSER" >/root/instantARCH/config/user
-    echo "$NEWPASS" >/root/instantARCH/config/password
+    # create user and add to groups
+    askuser
 
     while [ -z "$NEWHOSTNAME" ]; do
-        NEWHOSTNAME=$(textbox "enter name of this computer")
+        NEWHOSTNAME=$(imenu -i "enter name of this computer")
     done
 
-    echo "$NEWHOSTNAME" >/root/instantARCH/config/hostname
+    iroot hostname "$NEWHOSTNAME"
 
-    SUMMARY="Installation Summary:"
+    if imenu -c -i "edit advanced settings? (use only if you know what you're doing)"; then
+        /root/instantARCH/askadvanced.sh
+    fi
 
-    addsum() {
-        SUMMARY="$SUMMARY
-        $1: $(cat /root/instantARCH/config/$2)"
-    }
+    wallstatus install
+    SUMMARY="Installation Summary:"
 
     addsum "Username" "user"
     addsum "Locale" "locale"
     addsum "Region" "region"
-    addsum "Nearest City" "city"
+    addsum "Subregion" "city"
     addsum "Keyboard layout" "keyboard"
     addsum "Target install drive" "disk"
     addsum "Hostname" "hostname"
+
+    if efibootmgr; then
+        SUMMARY="$SUMMARY
+GRUB: UEFI"
+    else
+        SUMMARY="$SUMMARY
+GRUB: BIOS"
+    fi
+
     SUMMARY="$SUMMARY
 Should installation proceed with these parameters?"
 
-    if confirm "$SUMMARY"; then
-        touch /root/instantARCH/config/confirm
+    echo "summary:
+$SUMMARY"
+
+    if imenu -C <<<"$SUMMARY"; then
+        iroot confirm 1
     else
         unset CITY
         unset REGION
@@ -96,7 +150,11 @@ Should installation proceed with these parameters?"
         unset NEWHOSTNAME
         unset NEWUSER
     fi
+
 done
 
-messagebox "The installation will now begin. this could take a while. "
-clear
\ No newline at end of file
+imenu -M <<<'The installation will now begin.
+This could take a while.
+You can check install progress by clicking on "2" in the top right
+Keep the machine powered and connected to the internet. 
+After the installation, the machine will automatically reboot'