Fix: wm/de count error

This commit is contained in:
natemaia 2019-08-20 20:03:12 -07:00
parent cbb298fbaf
commit f87b340059

View File

@ -267,6 +267,7 @@ _timez="\nThe time zone is used to set the system clock.\n\nSelect your country
_timesubz="\nSelect the nearest city to you or one with the same time zone.\n\nTIP: Pressing the first letter of the city name repeatedly will navigate between entries beggining with that letter." _timesubz="\nSelect the nearest city to you or one with the same time zone.\n\nTIP: Pressing the first letter of the city name repeatedly will navigate between entries beggining with that letter."
_sessions="\nUse [Space] to toggle available sessions, use [Enter] to accept the selection and continue.\n\nA basic package set will be installed for compatibility and functionality." _sessions="\nUse [Space] to toggle available sessions, use [Enter] to accept the selection and continue.\n\nA basic package set will be installed for compatibility and functionality."
_login="\nSelect which of your session choices to use for the initial login.\n\nYou can be change this later by editing your ~/.xinitrc" _login="\nSelect which of your session choices to use for the initial login.\n\nYou can be change this later by editing your ~/.xinitrc"
_autologin="\nDo you want autologin enabled for USER?\n\nIf so the following two files will be created (disable autologin by removing them):\n\n - /home/USER/RC (run startx when logging in on tty1)\n - /etc/systemd/system/getty@tty1.service.d/autologin.conf (login USER without password)\n"
_packages="\nUse [Space] to move a package into the selected area and press [Enter] to accept the selection.\n\nPackages may be installed by your DE/WM (if any), or for the packages you select." _packages="\nUse [Space] to move a package into the selected area and press [Enter] to accept the selection.\n\nPackages may be installed by your DE/WM (if any), or for the packages you select."
_edit="\nBefore exiting you can select configuration files to review/change.\n\nIf you need to make other changes with the drives still mounted, use Ctrl-z to pause the installer, when finished type 'fg' and [Enter] or Ctrl-z again to resume the installer, if you want to avoid the automatic reboot using Ctrl-c will cleanly exit." _edit="\nBefore exiting you can select configuration files to review/change.\n\nIf you need to make other changes with the drives still mounted, use Ctrl-z to pause the installer, when finished type 'fg' and [Enter] or Ctrl-z again to resume the installer, if you want to avoid the automatic reboot using Ctrl-c will cleanly exit."
@ -418,6 +419,8 @@ select_show()
select_login() select_login()
{ {
[[ $INSTALL_WMS ]] || return 0
if [[ -z $LOGIN_TYPE ]]; then if [[ -z $LOGIN_TYPE ]]; then
dlg LOGIN_TYPE menu "Login Management" "\nSelect what kind of login management to use." \ dlg LOGIN_TYPE menu "Login Management" "\nSelect what kind of login management to use." \
"xinit" "Console login without a display manager" \ "xinit" "Console login without a display manager" \
@ -428,18 +431,16 @@ select_login()
AUTOLOGIN='' AUTOLOGIN=''
EDIT_FILES[login]="/etc/lightdm/lightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf" EDIT_FILES[login]="/etc/lightdm/lightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf"
else else
if (( WM_NUM == 1 )); then # define what wm/de to use for xinit
LOGIN_WM="${WM_SESSIONS[$INSTALL_WMS]}" if (( $(wc -w <<< "$INSTALL_WMS") > 1 )); then
else
dlg LOGIN_WM menu "Login Management" "$_login" $LOGIN_CHOICES || return 1 dlg LOGIN_WM menu "Login Management" "$_login" $LOGIN_CHOICES || return 1
LOGIN_WM="${WM_SESSIONS[$LOGIN_WM]}" LOGIN_WM="${WM_SESSIONS[$LOGIN_WM]}"
fi fi
[[ -z $LOGIN_WM ]] && LOGIN_WM="${WM_SESSIONS[${INSTALL_WMS%% *}]}"
# autologin
yesno "Autologin" "$(sed "s|USER|$NEWUSER|g; s|RC|$LOGINRC|g" <<< "$_autologin")" && AUTOLOGIN=true || AUTOLOGIN=''
local txt="\nDo you want autologin enabled for $NEWUSER?\n\n"
txt+="If so the following two files will be created (disable autologin by removing them):\n\n"
txt+="- /home/$NEWUSER/$LOGINRC (run startx when logging in on tty1)\n"
txt+="- /etc/systemd/system/getty@tty1.service.d/autologin.conf (login $NEWUSER without password)\n"
yesno "Autologin" "$txt" && AUTOLOGIN=true || AUTOLOGIN=''
EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile" EDIT_FILES[login]="/home/$NEWUSER/.xinitrc /home/$NEWUSER/.xprofile"
fi fi
} }
@ -451,12 +452,10 @@ select_config()
until [[ $CONFIG_DONE ]]; do until [[ $CONFIG_DONE ]]; do
case $i in case $i in
0) 0) dlg MYSHELL menu "Shell" "\nChoose which shell to use." \
dlg MYSHELL menu "Shell" "\nChoose which shell to use." \
/usr/bin/zsh 'A very advanced and programmable command interpreter (shell) for UNIX' \ /usr/bin/zsh 'A very advanced and programmable command interpreter (shell) for UNIX' \
/bin/bash 'The GNU Bourne Again shell, standard in many GNU/Linux distributions' \ /bin/bash 'The GNU Bourne Again shell, standard in many GNU/Linux distributions' \
/usr/bin/mksh 'The MirBSD Korn Shell - an enhanced version of the public domain ksh' || return 1 /usr/bin/mksh 'The MirBSD Korn Shell - an enhanced version of the public domain ksh' || return 1
;; ;;
1) dlg MYHOST input "Hostname" "$_hostname" "${DIST,,}" limit || { i=0; continue; } ;; 1) dlg MYHOST input "Hostname" "$_hostname" "${DIST,,}" limit || { i=0; continue; } ;;
2) dlg MYLOCALE menu "Locale" "$_locale" $LOCALES || { i=1; continue; } ;; 2) dlg MYLOCALE menu "Locale" "$_locale" $LOCALES || { i=1; continue; } ;;
@ -467,13 +466,11 @@ select_config()
yesno "Timezone" "\nConfirm time zone: $ZONE/$SUBZ\n" || unset ZONE yesno "Timezone" "\nConfirm time zone: $ZONE/$SUBZ\n" || unset ZONE
done done
[[ $ZONE && $SUBZ ]] || { i=2; continue; } ;; [[ $ZONE && $SUBZ ]] || { i=2; continue; } ;;
4) 4) dlg KERNEL menu "Kernel" "\nChoose which kernel to use." \
dlg KERNEL menu "Kernel" "\nChoose which kernel to use." \
linux 'Vanilla linux kernel and modules, with a few patches applied' \ linux 'Vanilla linux kernel and modules, with a few patches applied' \
linux-lts 'Long-term support (LTS) linux kernel and modules' \ linux-lts 'Long-term support (LTS) linux kernel and modules' \
linux-zen 'A effort of kernel hackers to provide the best kernel for everyday systems' \ linux-zen 'A effort of kernel hackers to provide the best kernel for everyday systems' \
linux-hardened 'A security-focused linux kernel with hardening patches to mitigate exploits' || { i=3; continue; } linux-hardened 'A security-focused linux kernel with hardening patches to mitigate exploits' || { i=3; continue; }
CONFIG_DONE=true CONFIG_DONE=true
;; ;;
esac esac
@ -506,13 +503,7 @@ select_mkuser()
"Password2:" 9 1 '' 9 12 "$COLUMNS" 0 1 2>"$ANS" || return 1 "Password2:" 9 1 '' 9 12 "$COLUMNS" 0 1 2>"$ANS" || return 1
while read -r line; do while read -r line; do
case $i in case $i in 0) u="$line" ;; 1) p="$line" ;; 2) p2="$line" ;; 3) rp="$line" ;; 4) rp2="$line" ;; esac
0) u="$line" ;;
1) p="$line" ;;
2) p2="$line" ;;
3) rp="$line" ;;
4) rp2="$line" ;;
esac
(( i++ )) (( i++ ))
done < "$ANS" done < "$ANS"
@ -590,13 +581,9 @@ select_sessions()
gnome "A desktop environment that aims to be simple and easy to use" "$(ofn gnome "${INSTALL_WMS[*]}")" \ gnome "A desktop environment that aims to be simple and easy to use" "$(ofn gnome "${INSTALL_WMS[*]}")" \
cinnamon "A desktop environment combining traditional desktop with modern effects" "$(ofn cinnamon "${INSTALL_WMS[*]}")" \ cinnamon "A desktop environment combining traditional desktop with modern effects" "$(ofn cinnamon "${INSTALL_WMS[*]}")" \
plasma "A kde software project currently comprising a full desktop environment" "$(ofn plasma "${INSTALL_WMS[*]}")" \ plasma "A kde software project currently comprising a full desktop environment" "$(ofn plasma "${INSTALL_WMS[*]}")" \
xfce4 "A lightweight and modular desktop environment based on gtk+2/3" "$(ofn xfce4 "${INSTALL_WMS[*]}")" || return 1 xfce4 "A lightweight and modular desktop environment based on gtk+2/3" "$(ofn xfce4 "${INSTALL_WMS[*]}")"
WM_NUM=0
while IFS=' ' read -r i; do
(( WM_NUM++ ))
done <<< "$INSTALL_WMS"
[[ $INSTALL_WMS ]] || return 0
WM_PKGS="${INSTALL_WMS/dwm/}" # remove dwm from package list WM_PKGS="${INSTALL_WMS/dwm/}" # remove dwm from package list
WM_PKGS="${WM_PKGS// / }" # remove double spaces WM_PKGS="${WM_PKGS// / }" # remove double spaces
@ -1002,7 +989,8 @@ part_device()
fi fi
[[ $DEVICE ]] || return 1 [[ $DEVICE ]] || return 1
elif [[ $DEV_COUNT -lt 1 && ! $1 ]]; then elif [[ $DEV_COUNT -lt 1 && ! $1 ]]; then
msg "Device Error" "\nNo available devices.\n\nExiting..\n" 2; die 1 msg "Device Error" "\nNo available devices.\n\nExiting..\n" 2
die 1
fi fi
[[ $1 ]] && BOOT_DEV="$DEVICE" [[ $1 ]] && BOOT_DEV="$DEVICE"
@ -1226,7 +1214,7 @@ select_efi_partition()
done <<< "$PARTS" done <<< "$PARTS"
if (( ptcount == 1 )); then if (( ptcount == 1 )); then
msg "EFI Boot Partition" "\nOnly one partition that meets size requirements available.\n" 1 msg "EFI Boot Partition" "\nOnly one partition available that meets size requirements.\n" 1
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")" BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$pts")"
else else
dlg BOOT_PART menu "EFI Partition" "$_uefi" $pts dlg BOOT_PART menu "EFI Partition" "$_uefi" $pts
@ -1302,7 +1290,7 @@ select_root_partition()
done <<< "$PARTS" done <<< "$PARTS"
if (( ptcount == 1 )); then # only one available device if (( ptcount == 1 )); then # only one available device
msg "Select Root Partition (/)" "\nOnly one partition that meets size requirements available.\n" 1 msg "Select Root Partition (/)" "\nOnly one partition available that meets size requirements.\n" 1
ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$pts")" ROOT_PART="$(awk 'NR==1 {print $1}' <<< "$pts")"
else else
dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $pts dlg ROOT_PART menu "Mount Root" "\nSelect the root (/) partition, this is where $DIST will be installed.\n\nDevices smaller than 8G will not be shown here." $pts
@ -1568,11 +1556,20 @@ install_user()
install_xinit() install_xinit()
{ {
if [[ $INSTALL_WMS ]]; then
if [[ -e $MNT/home/$NEWUSER/.xinitrc ]] && grep -q 'exec' "$MNT/home/$NEWUSER/.xinitrc"; then if [[ -e $MNT/home/$NEWUSER/.xinitrc ]] && grep -q 'exec' "$MNT/home/$NEWUSER/.xinitrc"; then
sed -i "/exec/ c exec ${LOGIN_WM}" "$MNT/home/$NEWUSER/.xinitrc" sed -i "/exec/ c exec ${LOGIN_WM}" "$MNT/home/$NEWUSER/.xinitrc"
elif [[ $INSTALL_WMS ]]; then
printf "exec %s\n" "$LOGIN_WM" >> "$MNT/home/$NEWUSER/.xinitrc"
else else
printf "exec %s\n" "$LOGIN_WM" >> "$MNT/home/$NEWUSER/.xinitrc" printf "exec %s\n" "$LOGIN_WM" >> "$MNT/home/$NEWUSER/.xinitrc"
fi fi
elif [[ -e $MNT/home/$NEWUSER/.xinitrc ]]; then
# no sessions available so remove the exec from ~/.xinitrc and return
sed -i '/exec/d' "$MNT/home/$NEWUSER/.xinitrc"
return 0
fi
[[ ${EDIT_FILES[login]} == *"$LOGINRC"* ]] || EDIT_FILES[login]+=" /home/$NEWUSER/$LOGINRC" [[ ${EDIT_FILES[login]} == *"$LOGINRC"* ]] || EDIT_FILES[login]+=" /home/$NEWUSER/$LOGINRC"
@ -1599,8 +1596,8 @@ install_login()
install_lightdm() install_lightdm()
{ {
rm -rf "$SERVICE" "$MNT/home/$NEWUSER"/.{xinitrc,profile,zprofile,bash_profile} rm -rf "$SERVICE" "$MNT/home/$NEWUSER"/.{xinitrc,profile,zprofile,bash_profile}
chrun 'systemctl set-default graphical.target && systemctl enable lightdm.service' 2>$ERR chrun 'systemctl enable lightdm.service' 2>$ERR
errshow 1 "systemctl set-default graphical.target && systemctl enable lightdm.service" errshow 1 "systemctl enable lightdm.service"
cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf <<- EOF cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf <<- EOF
# LightDM GTK+ Configuration # LightDM GTK+ Configuration
@ -1805,14 +1802,11 @@ setup_grub()
prerun_grub() prerun_grub()
{ {
sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g; sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g; s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $MNT/etc/default/grub
s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $MNT/etc/default/grub
if [[ $LUKS_DEV ]]; then if [[ $LUKS_DEV ]]; then
sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $MNT/etc/default/grub 2>$ERR
s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $MNT/etc/default/grub 2>$ERR errshow 1 "sed -i 's~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g; s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g' $MNT/etc/default/grub"
errshow 1 "sed -i 's~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g;
s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g' $MNT/etc/default/grub"
fi fi
if [[ $SYS == 'BIOS' && $LVM && -z $SEP_BOOT ]]; then if [[ $SYS == 'BIOS' && $LVM && -z $SEP_BOOT ]]; then
@ -1940,27 +1934,23 @@ setup_systemd-boot()
prerun_systemd-boot() prerun_systemd-boot()
{ {
mkdir -p $MNT/boot/loader/entries mkdir -p $MNT/boot/loader/entries
cat > $MNT/boot/loader/loader.conf <<- EOF cat > $MNT/boot/loader/loader.conf <<- EOF
default $DIST default $DIST
timeout 5 timeout 5
editor no editor no
EOF EOF
cat > $MNT/boot/loader/entries/$DIST.conf <<- EOF cat > $MNT/boot/loader/entries/$DIST.conf <<- EOF
title $DIST Linux title $DIST Linux
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE.img") linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE.img")
initrd /initramfs-$KERNEL.img initrd /initramfs-$KERNEL.img
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
EOF EOF
cat > $MNT/boot/loader/entries/$DIST-fallback.conf <<- EOF cat > $MNT/boot/loader/entries/$DIST-fallback.conf <<- EOF
title $DIST Linux Fallback title $DIST Linux Fallback
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE.img") linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE.img")
initrd /initramfs-$KERNEL-fallback.img initrd /initramfs-$KERNEL-fallback.img
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
EOF EOF
mkdir -p $MNT/etc/pacman.d/hooks mkdir -p $MNT/etc/pacman.d/hooks
cat > $MNT/etc/pacman.d/hooks/systemd-boot.hook <<- EOF cat > $MNT/etc/pacman.d/hooks/systemd-boot.hook <<- EOF
[Trigger] [Trigger]
@ -1973,7 +1963,6 @@ prerun_systemd-boot()
When = PostTransaction When = PostTransaction
Exec = /usr/bin/bootctl update Exec = /usr/bin/bootctl update
EOF EOF
systemd-machine-id-setup --root="$MNT" systemd-machine-id-setup --root="$MNT"
return 0 return 0
} }
@ -2360,11 +2349,14 @@ luks_advanced()
ofn() ofn()
{ {
# does $2 contain $1
[[ "$2" == *"$1"* ]] && printf "on" || printf "off" [[ "$2" == *"$1"* ]] && printf "on" || printf "off"
} }
die() die()
{ {
# cleanup and exit the installer cleanly with exit code $1
# when ecode is 127 unmount /run/archiso/bootmnt and reboot
local ecode="$1" local ecode="$1"
trap - INT trap - INT
@ -2383,17 +2375,24 @@ die()
dlg() dlg()
{ {
local var="$1" dialog_type="$2" title="$3" body="$4" n=0 local var="$1" # assign output from dialog to var
shift 4 local dlg_t="$2" # display a dialog of type dlg_t (menu, check, input)
local title="$3" # dialog title
local body="$4" # dialog message
local n=0 # number of items to display
shift 4 # shift off args assigned above
# when passed a large amount of arguments (menu list) adjust menu height
(( ($# / 2) > SHL )) && n=$SHL (( ($# / 2) > SHL )) && n=$SHL
tput civis tput civis
case "$dialog_type" in case "$dlg_t" in
menu) dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --menu "$body" 0 0 $n "$@" 2>"$ANS" || return 1 ;; menu) dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --menu "$body" 0 0 $n "$@" 2>"$ANS" || return 1 ;;
check) dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --checklist "$body" 0 0 $n "$@" 2>"$ANS" || return 1 ;; check) dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --checklist "$body" 0 0 $n "$@" 2>"$ANS" || return 1 ;;
input) input)
tput cnorm tput cnorm
local def="$1" local def="$1" # assign default value for input
shift shift
if [[ $1 == 'limit' ]]; then if [[ $1 == 'limit' ]]; then
dialog --backtitle "$DIST Installer - $SYS - v$VER" --max-input 63 --title " $title " --inputbox "$body" 0 0 "$def" 2>"$ANS" || return 1 dialog --backtitle "$DIST Installer - $SYS - v$VER" --max-input 63 --title " $title " --inputbox "$body" 0 0 "$def" 2>"$ANS" || return 1
@ -2402,15 +2401,20 @@ dlg()
fi fi
;; ;;
esac esac
# if answer file isn't empty read from it into $var
[[ -s "$ANS" ]] && printf -v "$var" "%s" "$(< "$ANS")" [[ -s "$ANS" ]] && printf -v "$var" "%s" "$(< "$ANS")"
} }
msg() msg()
{ {
local title="$1" body="$2" # displays a message dialog
# when more than 2 args the message will disappear after sleep time ($3)
local title="$1"
local body="$2"
shift 2
tput civis tput civis
if (( $# == 3 )); then if (( $# )); then
dialog --backtitle "$DIST Installer - $SYS - v$VER" --sleep "$3" --title " $title " --infobox "$body\n" 0 0 dialog --backtitle "$DIST Installer - $SYS - v$VER" --sleep "$1" --title " $title " --infobox "$body\n" 0 0
else else
dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --msgbox "$body\n" 0 0 dialog --backtitle "$DIST Installer - $SYS - v$VER" --title " $title " --msgbox "$body\n" 0 0
fi fi