#!/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
-if [ -e /usr/share/liveutils ]; then
+source /root/instantARCH/askutils.sh
+
+if [ -e /usr/share/liveutils ] && ! [ -e /tmp/nogui ]; then
echo "GUI Mode active"
export GUIMODE="True"
GUIMODE="True"
fi
-# check if the install session is GUI or cli
-guimode() {
- if [ -e /opt/noguimode ]; then
- return 1
- fi
-
- if [ -n "$GUIMODE" ]; then
- return 0
- else
- return 1
- fi
-}
-
-if guimode; then
- pgrep instantmenu && pkill instantmenu
+# switch imenu to fzf and dialog
+if ! guimode; then
+ touch /tmp/climenu
imenu -m "Welcome to the instantOS installer"
else
- messagebox "Welcome to the instantOS installer"
+ 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
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
- if guimode; then
- feh --bg-scale /usr/share/liveutils/worldmap.jpg &
- NEWKEY="$(ls | imenu -l 'Select keyboard layout')"
- else
- NEWKEY="$(ls | fzf --prompt 'Select keyboard layout> ')"
- fi
-
- # allow directly typing in layout name
- if [ "$NEWKEY" = "other" ]; then
- if guimode; then
- OTHERKEY="$(localectl list-x11-keymap-layouts | instantmenu -l 20 -c -p 'select keyboard layout')"
- else
- OTHERKEY="$(localectl list-x11-keymap-layouts | fzf --prompt 'select keyboard layout')"
- fi
+# this loop wraps the rest of the installer
+while ! iroot confirm; do
- if [ -z "$OTHERKEY" ]; then
- unset NEWKEY
- else
- echo "
-$OTHERKEY" >/root/instantARCH/data/lang/keyboard/other
- fi
- fi
-
- done
+ # warning message for artix
+ artixinfo
- # option to cancel the installer
- if [ "${NEWKEY}" = "forcequit" ]; then
- exit 1
- fi
-
- echo "$NEWKEY" >/root/instantARCH/config/keyboard
-
- if head -1 /root/instantARCH/data/lang/keyboard/"$NEWKEY" | greo -q '[^ ][^ ]'; then
+ # 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")
- cd ../locale
- while [ -z "$NEWLOCALE" ]; do
- if guimode; then
- NEWLOCALE="$(ls | imenu -l 'Select language> ')"
- else
- NEWLOCALE="$(ls | fzf --prompt 'Select language> ')"
- fi
- done
-
- echo "$NEWLOCALE" >/root/instantARCH/config/locale
-
- cd /usr/share/zoneinfo
-
- while [ -z "$REGION" ]; do
- if guimode; then
- REGION=$(ls | imenu -l "select region")
- else
- REGION=$(ls | fzf --prompt "select region> ")
- fi
- done
+ asklocale
- if [ -d "$REGION" ]; then
- cd "$REGION"
- while [ -z "$CITY" ]; do
- if guimode; then
- CITY=$(ls | imenu -l "select the City nearest to you")
- else
- CITY=$(ls | fzf --prompt "select the City nearest to you> ")
- fi
- 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
- if guimode; then
- feh --bg-scale /usr/share/liveutils/install.jpg &
- DISK=$(fdisk -l | grep -i '^Disk /.*:' | imenu -l "select 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
- DISK=$(fdisk -l | grep -i '^Disk /.*:' | fzf --prompt "select disk> ")
- if ! confirm "Install on $DISK ?\n this will delete all existing data"; then
+ 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
-
- # select drivers
- if lspci | grep -iq 'nvidia'; then
- echo "nvidia card detected"
- while [ -z "$DRIVERCHOICE" ]; do
- if guimode; then
- DRIVERCHOICE="$(echo 'nvidia proprietary (recommended)
-nvidia-dkms (try if proprietary does not work)
-nouveau open source
-install without graphics drivers (not recommended)' | imenu -l 'select graphics drivers')"
+ if ! grep -q '^other' <<<"$DISK"; then
- if grep -q "without" <<<"$DRIVERCHOICE"; then
- if ! echo "are you sure you do not want to install graphics drivers?
-This could prevent the system from booting" | imenu -C; then
- unset DRIVERCHOICE
- fi
- fi
- else
+ echo "$DISK" | grep -o '/dev/[^:]*' | iroot i disk
- while [ -z "$DRIVERCHOICE" ]; do
- while [ -z "$DRIVERCHOICE" ]; do
- DRIVERCHOICE="$(echo 'nvidia proprietary (recommended)
-nvidia-dkms (try if proprietary doesn't work)
-nouveau open source
-install without graphics (not recommended)' | fzf --prompt 'select graphics drivers')"
-
- done
-
- if grep -q "without" <<<"$DRIVERCHOICE"; then
- if ! confirm "are you sure you do not want to install graphics drivers?
-This could prevent the system from booting"; then
- unset DRIVERCHOICE
- fi
- fi
- done
-
- fi
- done
-
- if grep -qi "dkms" <<<"$DRIVERCHOICE"; then
- echo "dkms" >/root/instantARCH/config/graphics
- elif grep -qi "nvidia" <<<"$DRIVERCHOICE"; then
- echo "nvidia" >/root/instantARCH/config/graphics
- elif grep -qi "open" <<<"$DRIVERCHOICE"; then
- echo "open" >/root/instantARCH/config/graphics
- elif [ -z "$DRIVERCHOICE" ]; then
- echo "nodriver" >/root/instantARCH/config/graphics
+ if ! efibootmgr; then
+ echo "$DISK" | grep -o '/dev/[^:]*' | iroot i grubdisk
fi
-
- else
- echo "no nvidia card detected"
fi
- while [ -z $NEWUSER ]; do
- if guimode; then
- feh --bg-scale /usr/share/liveutils/user.jpg &
- NEWUSER="$(imenu -i 'set username')"
- else
- NEWUSER="$(textbox 'set username')"
- fi
-
- # validate input as a unix name
- if ! grep -Eq '^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$' <<<"$NEWUSER"; then
- if guimode; then
- imenu -m "invalid username"
- else
- msgbox "invalid username"
- fi
- unset NEWUSER
- fi
- done
-
- while ! [ "$NEWPASS" = "$NEWPASS2" ] || [ -z "$NEWPASS" ]; do
- if guimode; then
- NEWPASS="$(imenu -P 'set password')"
- NEWPASS2="$(imenu -P 'confirm password')"
- else
- NEWPASS="$(passwordbox 'set password')"
- NEWPASS2="$(passwordbox 'confirm password')"
- fi
- done
+ # 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
- if guimode; then
- NEWHOSTNAME=$(imenu -i "enter name of this computer")
- else
- NEWHOSTNAME=$(textbox "enter name of this computer")
- fi
+ NEWHOSTNAME=$(imenu -i "enter name of this computer")
done
- echo "$NEWHOSTNAME" >/root/instantARCH/config/hostname
+ iroot hostname "$NEWHOSTNAME"
- guimode && feh --bg-scale /usr/share/liveutils/install.jpg &
- 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"
SUMMARY="$SUMMARY
Should installation proceed with these parameters?"
- if guimode; then
- if imenu -C <<<"$SUMMARY"; then
- touch /root/instantARCH/config/confirm
- else
- unset CITY
- unset REGION
- unset DISK
- unset NEWKEY
- unset NEWLOCALE
- unset NEWPASS2
- unset NEWPASS
- unset NEWHOSTNAME
- unset NEWUSER
- fi
+ echo "summary:
+$SUMMARY"
+
+ if imenu -C <<<"$SUMMARY"; then
+ iroot confirm 1
else
- if confirm "$SUMMARY"; then
- touch /root/instantARCH/config/confirm
- else
- unset CITY
- unset REGION
- unset DISK
- unset NEWKEY
- unset NEWLOCALE
- unset NEWPASS2
- unset NEWPASS
- unset NEWHOSTNAME
- unset NEWUSER
- fi
+ unset CITY
+ unset REGION
+ unset DISK
+ unset NEWKEY
+ unset NEWLOCALE
+ unset NEWPASS2
+ unset NEWPASS
+ unset NEWHOSTNAME
+ unset NEWUSER
fi
+
done
-if guimode; then
- imenu -M <<<"The installation will now begin.
- This could take a while.
- Keep the machine powered and connected to the internet" &
-else
- messagebox "The installation will now begin. This could take a while. Keep the machine powered and connected to the internet"
- clear
-fi
+imenu -M <<<"The installation will now begin.
+This could take a while.
+Keep the machine powered and connected to the internet.
+After the installation, the machine will automatically reboot"