diff --git a/src/archlabs-installer b/src/archlabs-installer index 9b503c2..5abd6c9 100755 --- a/src/archlabs-installer +++ b/src/archlabs-installer @@ -19,43 +19,43 @@ readonly DBG="/tmp/debuglog" # Built-in error log main() { if [[ $CURRENT_MENU != "main" ]]; then + SELECTED=1 + CURRENT_MENU="main" if [[ $SAVED ]]; then SELECTED=$((SAVED + 1)) unset SAVED - else - SELECTED=1 fi - CURRENT_MENU="main" - elif (( SELECTED < 9 )); then + elif (( SELECTED < 8 )); then ((SELECTED++)) # increment the highlighted menu item fi tput civis SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $_PrepTitle " --default-item $SELECTED --menu "$_PrepBody" 0 0 0 \ - "1" "$_PrepShowDev" "2" "$_PrepParts" "3" "$_PrepLUKS" "4" "$_PrepLVM" \ - "5" "$_PrepMount" "6" "$_PrepConfig" "7" "Check Choices" "8" "$_PrepInstall" \ - "9" "$_Done") + --title " $_PrepTitle " --default-item $SELECTED \ + --menu "$_PrepBody" 0 0 0 \ + "1" "$_PrepShowDev" "2" "$_PrepParts" \ + "3" "$_PrepLUKS" "4" "$_PrepLVM" \ + "5" "$_PrepMount" "6" "$_PrepConfig" \ + "7" "Check Choices" "8" "$_PrepInstall") - # if trying to install the system, make sure the partitions are mounted - # and that the needed config variables and user variables have been set up if [[ $SELECTED ]]; then - if [[ $SELECTED -eq 8 || $SELECTED -eq 6 ]]; then - { [[ $SELECTED -eq 8 ]] && preinstall_checks 1 || preinstall_checks; } || return 1 - elif [[ ($SELECTED -eq 2 || $SELECTED -eq 5) && $WARN != true ]]; then + if (( SELECTED == 8 )); then + preinstall_checks 1 || return 1 + elif (( SELECTED == 6 )); then + preinstall_checks || return 1 + elif (( SELECTED == 2 || SELECTED == 5 )) && [[ $WARN != true ]]; then msgbox "$_PrepTitle" "$_WarnMount" && WARN=true fi fi - # setting $SELECTED to ($SELECTED - 1) when failing keeps the highlight case $SELECTED in 1) device_tree ;; - 2) partition || SELECTED=1 ;; - 3) luks_menu || SELECTED=2 ;; - 4) lvm_menu || SELECTED=3 ;; - 5) select_partitions || SELECTED=4 ;; - 6) configure_settings || SELECTED=5 ;; - 7) display_settings ;; + 2) partition || SELECTED=$((SELECTED - 1)) ;; + 3) luks_menu || SELECTED=$((SELECTED - 1)) ;; + 4) lvm_menu || SELECTED=$((SELECTED - 1)) ;; + 5) mnt_menu || SELECTED=$((SELECTED - 1)) ;; + 6) cfg_menu || SELECTED=$((SELECTED - 1)) ;; + 7) show_cfg ;; 8) install ;; *) yesno "$_CloseInst" "$_CloseInstBody" "Exit" "Back" && die esac diff --git a/src/lib/dialogs.sh b/src/lib/dialogs.sh index 2aaf690..cd1190e 100644 --- a/src/lib/dialogs.sh +++ b/src/lib/dialogs.sh @@ -39,22 +39,22 @@ declare -g MKINIT_HOOKS="shutdown" # match the wm name with the actual session name used for xinit declare -gA WM_SESSIONS=( -[i3-gaps]='i3' [dwm]='dwm' -[openbox]='openbox-session' +[i3-gaps]='i3' [bspwm]='bspwm' [xfce4]='startxfce4' [gnome]='gnome-session' +[openbox]='openbox-session' [cinnamon]='cinnamon-session' ) # additional packages installed for the given window manager declare -gA WM_EXT=( -[bspwm]="sxhkd libmpdclient archlabs-skel-bspwm jsoncpp archlabs-screenlock archlabs-polybar rofi" [gnome]="gnome-extra" +[bspwm]="sxhkd libmpdclient archlabs-skel-bspwm jsoncpp archlabs-screenlock archlabs-polybar rofi" [i3-gaps]="i3status perl-anyevent-i3 libmpdclient archlabs-skel-i3-gaps jsoncpp archlabs-screenlock archlabs-polybar rofi" [xfce4]="xfce4-goodies xfce4-pulseaudio-plugin archlabs-skel-xfce4" -[openbox]="archlabs-obkey obconf archlabs-kickshaw tint2 archlabs-oblogout jgmenu archlabs-skel-openbox tint2 archlabs-skippy-xd conky thunar termite libmpdclient jsoncpp archlabs-screenlock archlabs-paranoid archlabs-polybar rofi zenity" +[openbox]="archlabs-obkey obconf archlabs-kickshaw archlabs-oblogout jgmenu archlabs-skel-openbox tint2 archlabs-skippy-xd conky libmpdclient jsoncpp archlabs-screenlock archlabs-paranoid archlabs-polybar rofi zenity" ) # files the user can edit during the final stage of install @@ -73,73 +73,94 @@ declare -gA EDIT_FILES=( # } -msgbox() +show_cfg() { - tput civis - dialog --cr-wrap --backtitle "$BT" --title " $1 " --msgbox "$2\n" 0 0 + local cmd mnt pkgs + cmd="${BCMDS[$BOOTLDR]}" + mnt="${BMNTS[$SYS-$BOOTLDR]}" + msgbox "$_PrepTitle" " + +---------- PARTITION CONFIGURATION ------------ + + Root: ${ROOT_PART:-None} + Boot: ${BOOT_PART:-${BOOT_DEVICE:-None}} + + Swap: ${SWAP_PART:-None} + Size: ${SWAP_SIZE:-None} + + Extra: ${EXTRA_MNTS:-${EXTRA_MNT:-None}} + Hooks: ${MKINIT_HOOKS:-None} + + LVM: ${LVM:-None} + LUKS: ${LUKS:-None} + + +---------- BOOTLOADER CONFIGURATION ----------- + + Loader: ${BOOTLDR:-None} + Mount: ${mnt:-None} + Command: ${cmd:-None} + + +------------ SYSTEM CONFIGURATION ------------- + + Locale: ${LOCALE:-None} + Keymap: ${KEYMAP:-None} + Hostname: ${HOSTNAME:-None} + Timezone: ${ZONE:-None}/${SUBZONE:-None} + + +------------ LOGIN CONFIGURATION -------------- + + User: ${NEWUSER:-None} + Shell: ${MYSHELL:-None} + Session: ${LOGIN_WM:-None} + Autologin: ${AUTOLOGIN:-None} + Management: ${LOGIN_TYPE:-None} + + +------------ PACKAGES AND MIRRORS ------------- + + Kernel: ${KERNEL:-None} + Sessions: ${INSTALL_WMS:-None} + Mirrors: ${MIRROR_CMD:-None} + Packages: $(print4 "${PACKAGES:-None}") +" } -menubox() +cfg_menu() { - local title="$1" - local body="$2" - local h=$3 - local w=$4 - local n=$5 - shift 5 - local response - if ! response="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --menu "$body" $h $w $n "$@")"; then + tput cnorm + if ! HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"; then return 1 fi - printf "%s" "$response" -} -checkbox() -{ - local title="$1" - local body="$2" - local h=$3 - local w=$4 - local n=$5 - shift 5 - local response - if ! response="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --checklist "$body" $h $w $n "$@")"; then + tput civis + if ! LOCALE="$(menubox "$_ConfLocale" "$_LocaleBody" 25 70 20 $LOCALES)"; then return 1 fi - printf "%s" "$response" -} -getinput() -{ - local answer - if ! answer="$(dialog --cr-wrap --max-input 63 --stdout --no-cancel --backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")" || [[ $answer == '' ]]; then + select_timezone || return 1 + user_creation || return 1 + + tput civis + if ! MYSHELL="$(menubox "$_ShellTitle" "$_ShellBody" 0 0 0 '/usr/bin/zsh' '-' '/bin/bash' '-' '/usr/bin/mksh' '-')"; then return 1 fi - printf "%s" "$answer" -} -infobox() -{ - local sec="$3" - tput civis - dialog --cr-wrap --backtitle "$BT" --title " $1 " --infobox "$2\n" 0 0 - sleep ${sec:-2} -} - -yesno() -{ - # usage: yesno <text> [<yes_label> <no_label> [<no>]] - # three options: one --default-no and custom labels, one just custom labels, and one basic. - tput civis - if [[ $# -eq 5 && $5 == "no" ]]; then - dialog --cr-wrap --backtitle "$BT" --defaultno --title " $1 " \ - --yes-label "$3" --no-label "$4" --yesno "$2\n" 0 0 - elif [[ $# -eq 4 ]]; then - dialog --cr-wrap --backtitle "$BT" --title " $1 " --yes-label "$3" \ - --no-label "$4" --yesno "$2\n" 0 0 - else - dialog --cr-wrap --backtitle "$BT" --title " $1 " --yesno "$2\n" 0 0 + if ! KERNEL="$(menubox "$_KernelTitle" "$_KernelBody" 0 0 0 'linux' '-' 'linux-lts' '-')"; then + return 1 fi + + select_mirrorcmd || return 1 + + yesno "$_DevelTitle" "$_DevelBody" && BASEDEV=true || BASEDEV=false + + select_wm_or_de || return 1 + select_packages || return 1 + + export CONFIG_DONE=true + return 0 } select_language() @@ -199,13 +220,10 @@ user_creation() return 1 fi - local user + local user pass pass2 rpass rpass2 user="$(awk -F'~' '{print $1}' <<< "$values")" - local pass pass2 pass="$(awk -F'~' '{print $2}' <<< "$values")" pass2="$(awk -F'~' '{print $3}' <<< "$values")" - - local rpass rpass2 rpass="$(awk -F'~' '{print $5}' <<< "$values")" rpass2="$(awk -F'~' '{print $6}' <<< "$values")" @@ -213,7 +231,9 @@ user_creation() [[ $rpass == "" && $rpass2 == "" ]] && { rpass="$pass"; rpass2="$pass2"; } # make sure a username was entered and that the passwords match - if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9] || $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then + if [[ ${#user} -eq 0 || $user =~ \ |\' || $user =~ [^a-z0-9] || + $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]] + then if [[ $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then # password was left empty or doesn't match if [[ $pass == "" ]]; then @@ -330,7 +350,7 @@ select_wm_or_de() done # choose how to log in - select_login_method || return 1 + select_login || return 1 # choose which WM/DE to start at login, only for xinit if [[ $LOGIN_TYPE == 'xinit' ]]; then @@ -352,7 +372,7 @@ select_wm_or_de() declare -g PACKAGES="$WM_PACKAGES" } -select_login_method() +select_login() { if ! LOGIN_TYPE="$(menubox "$_WMLogin" "$_LoginTypeBody" 0 0 0 \ "xinit" "Console login without a display manager" \ @@ -378,11 +398,11 @@ select_packages() fi tput civis - SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $_Packages " --default-item $SELECTED --menu "$_PackageMenu" 0 0 0 \ - "1" "Web Browsers" "2" "Text Editors" "3" "Terminal Emulators" \ - "4" "Music and Video Players" "5" "Mail and Chat" "6" "Office and Editing" \ - "7" "Management and Fonts" "8" "Miscellaneous" "9" "$_Done") + SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_Packages " \ + --default-item $SELECTED --menu "$_PackageMenu" 0 0 0 \ + "1" "Browsers" "2" "Editors" "3" "Terminals" \ + "4" "Multimedia" "5" "Chat/Mail" "6" "Professional" \ + "7" "System" "8" "Miscellaneous" "9" "$_Done") if [[ $SELECTED -lt 9 ]]; then case $SELECTED in @@ -457,96 +477,6 @@ select_mirrorcmd() return 0 } -display_settings() -{ - local cmd mnt pkgs - cmd="${BCMDS[$BOOTLDR]}" - mnt="${BMNTS[$SYS-$BOOTLDR]}" - msgbox "$_PrepTitle" " - ----------- PARTITION CONFIGURATION ------------ - - Root: ${ROOT_PART:-None} - Boot: ${BOOT_PART:-${BOOT_DEVICE:-None}} - - Swap: ${SWAP_PART:-None} - Size: ${SWAP_SIZE:-None} - - Extra: ${EXTRA_MNTS:-${EXTRA_MNT:-None}} - Hooks: ${MKINIT_HOOKS:-None} - - LVM: ${LVM:-None} - LUKS: ${LUKS:-None} - - ----------- BOOTLOADER CONFIGURATION ----------- - - Loader: ${BOOTLDR:-None} - Mount: ${mnt:-None} - Command: ${cmd:-None} - - ------------- SYSTEM CONFIGURATION ------------- - - Locale: ${LOCALE:-None} - Keymap: ${KEYMAP:-None} - Hostname: ${HOSTNAME:-None} - Timezone: ${ZONE:-None}/${SUBZONE:-None} - - ------------- LOGIN CONFIGURATION -------------- - - User: ${NEWUSER:-None} - Shell: ${MYSHELL:-None} - Session: ${LOGIN_WM:-None} - Autologin: ${AUTOLOGIN:-None} - Management: ${LOGIN_TYPE:-None} - - ------------- PACKAGES AND MIRRORS ------------- - - Kernel: ${KERNEL:-None} - Sessions: ${INSTALL_WMS:-None} - Mirrors: ${MIRROR_CMD:-None} - Packages: $(print4 "${PACKAGES:-None}") -" -} - -configure_settings() -{ - tput cnorm - if ! HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"; then - return 1 - fi - - tput civis - if ! LOCALE="$(menubox "$_ConfLocale" "$_LocaleBody" 25 70 20 $LOCALES)"; then - return 1 - fi - - select_timezone || return 1 - user_creation || return 1 - - tput civis - if ! MYSHELL="$(menubox "$_ShellTitle" "$_ShellBody" 0 0 0 '/usr/bin/zsh' '-' '/bin/bash' '-' '/usr/bin/mksh' '-')"; then - return 1 - fi - - if ! KERNEL="$(menubox "$_KernelTitle" "$_KernelBody" 0 0 0 'linux' '-' 'linux-lts' '-')"; then - return 1 - fi - - select_mirrorcmd || return 1 - - yesno "$_DevelTitle" "$_DevelBody" && BASEDEV=true || BASEDEV=false - - select_wm_or_de || return 1 - select_packages || return 1 - - export CONFIG_DONE=true - return 0 -} - edit_configs() { if [[ $CURRENT_MENU != "edit" ]]; then @@ -561,9 +491,10 @@ edit_configs() SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \ --title " $_EditTitle " --default-item $SELECTED --menu "$_EditBody" 0 0 0 \ - "1" "$exitstr" "2" "Keyboard" "3" "Locale" "4" "Hostname" \ - "5" "Sudoers" "6" "Mkinitcpio.conf" "7" "Fstab" "8" "Crypttab" \ - "9" "${BOOTLDR^}" "10" "Pacman.conf" "11" "${LOGIN_TYPE^}") + "1" "$exitstr" "2" "${EDIT_FILES[2]}" "3" "${EDIT_FILES[3]}" \ + "4" "${EDIT_FILES[4]}" "5" "${EDIT_FILES[5]}" "6" "${EDIT_FILES[6]}" \ + "7" "${EDIT_FILES[7]}" "8" "${EDIT_FILES[8]}" "9" "${EDIT_FILES[9]}" \ + "10" "${EDIT_FILES[10]}" "11" "${EDIT_FILES[11]}") if [[ ! $SELECTED || $SELECTED -eq 1 ]]; then [[ $DEBUG == true && -r $DBG ]] && vim $DBG @@ -590,6 +521,78 @@ edit_configs() msgbox "$_ErrTitle" "$_NoFileErr" fi fi - edit_system_configs + edit_configs +} + + +# dialog helper functions + +msgbox() +{ + tput civis + dialog --cr-wrap --backtitle "$BT" --title " $1 " --msgbox "$2\n" 0 0 +} + +menubox() +{ + local title="$1" + local body="$2" + local h=$3 + local w=$4 + local n=$5 + shift 5 + local response + if ! response="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --menu "$body" $h $w $n "$@")"; then + return 1 + fi + printf "%s" "$response" +} + +checkbox() +{ + local title="$1" + local body="$2" + local h=$3 + local w=$4 + local n=$5 + shift 5 + local response + if ! response="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --checklist "$body" $h $w $n "$@")"; then + return 1 + fi + printf "%s" "$response" +} + +getinput() +{ + local answer + if ! answer="$(dialog --cr-wrap --max-input 63 --stdout --no-cancel --backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")" || [[ $answer == '' ]]; then + return 1 + fi + printf "%s" "$answer" +} + +infobox() +{ + local sec="$3" + tput civis + dialog --cr-wrap --backtitle "$BT" --title " $1 " --infobox "$2\n" 0 0 + sleep ${sec:-2} +} + +yesno() +{ + # usage: yesno <title> <text> [<yes_label> <no_label> [<no>]] + # three options: one --default-no and custom labels, one just custom labels, and one basic. + tput civis + if [[ $# -eq 5 && $5 == "no" ]]; then + dialog --cr-wrap --backtitle "$BT" --defaultno --title " $1 " \ + --yes-label "$3" --no-label "$4" --yesno "$2\n" 0 0 + elif [[ $# -eq 4 ]]; then + dialog --cr-wrap --backtitle "$BT" --title " $1 " --yes-label "$3" \ + --no-label "$4" --yesno "$2\n" 0 0 + else + dialog --cr-wrap --backtitle "$BT" --title " $1 " --yesno "$2\n" 0 0 + fi } diff --git a/src/lib/install.sh b/src/lib/install.sh index e18a21b..666e80f 100644 --- a/src/lib/install.sh +++ b/src/lib/install.sh @@ -189,12 +189,6 @@ create_user() chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" chrun "chown -Rf $NEWUSER:users /home/$NEWUSER" - # remove configs for window managers that were never installed - [[ $INSTALL_WMS =~ i3-gaps ]] || rm -rf $MNT/home/$NEWUSER/.config/i3 - [[ $INSTALL_WMS =~ bspwm ]] || rm -rf $MNT/home/$NEWUSER/.config/{bspwm,sxhkd} - [[ $INSTALL_WMS =~ openbox ]] || rm -rf $MNT/home/$NEWUSER/.config/{openbox,skippy-xd,jgmenu,conky,tint2} - [[ $INSTALL_WMS =~ (openbox|i3-gaps|bspwm) ]] || rm -rf $MNT/home/$NEWUSER/.config/polybar - # for neovim set up ~/.config/nvim if [[ $PACKAGES =~ neovim ]]; then mkdir -p $MNT/home/$NEWUSER/.config/nvim @@ -315,15 +309,18 @@ package_operations() fi # for only gnome or cinnamon we don't need the xfce provided stuff - [[ $INSTALL_WMS =~ (gnome|cinnamon) ]] && rmpkg+=" $(pacman -Qssq 'xfce4*' 2>/dev/null)" + [[ $INSTALL_WMS =~ (gnome|cinnamon) ]] && + rmpkg+=" $(pacman -Qssq 'xfce4*' 2>/dev/null)" # when not using grub bootloader remove it's package and configurations if [[ $BOOTLDR != 'grub' ]]; then rmpkg+=" grub" rm -f $MNT/etc/default/grub find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1 - elif [[ $BOOTLDR != 'syslinux' ]]; then - # do the same when not using syslinux as the bootloader + fi + + # do the same when not using syslinux as the bootloader + if [[ $BOOTLDR != 'syslinux' ]]; then find $MNT/boot/ -name 'syslinux*' -exec rm -rf '{}' \; >/dev/null 2>&1 fi @@ -333,7 +330,7 @@ package_operations() if [[ $BASEDEV == true ]]; then chrun "pacman -S iputils --noconfirm" 2>/dev/null chrun "pacman -S base-devel git --needed --noconfirm" 2>/dev/null - elif [[ $BASEDEV == false && $INSTALL_WMS =~ dwm ]]; then + elif [[ $INSTALL_WMS =~ dwm ]]; then chrun "pacman -S iputils git make --noconfirm" 2>/dev/null else # iputils is needed and should always be installed diff --git a/src/lib/mount.sh b/src/lib/mount.sh index 4b349b6..cbfa847 100644 --- a/src/lib/mount.sh +++ b/src/lib/mount.sh @@ -17,7 +17,7 @@ readonly LOCALES="$(awk '/\.UTF-8/ { gsub(/# .*|#/, "") readonly CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}')" -select_partitions() +mnt_menu() { # prepare partition list PARTS for dialog lvm_detect diff --git a/src/lib/package.sh b/src/lib/package.sh index 31e3144..2312dca 100644 --- a/src/lib/package.sh +++ b/src/lib/package.sh @@ -22,7 +22,7 @@ declare -gA PKG_EXT=( [noto-fonts]="noto-fonts-emoji" [kdenlive]="kdebase-runtime dvdauthor frei0r-plugins breeze breeze-gtk" [vlc]="qt5ct qt5-styleplugins" -[kdenlive]="qt5ct qt5-styleplugins" # duplicates are stripped with `uniq` later +[kdenlive]="qt5ct qt5-styleplugins" # duplicates are stripped with `uniq` later [qbittorrent]="qt5ct qt5-styleplugins" [qutebrowser]="qt5ct qt5-styleplugins" )