diff --git a/src/archlabs-installer b/src/archlabs-installer index b88c7ac..110d1e4 100755 --- a/src/archlabs-installer +++ b/src/archlabs-installer @@ -10,7 +10,7 @@ # immutable globals -readonly VER="1.7.28" # Installer version +readonly VER="1.7.29" # Installer version readonly DIST="ArchLabs" # Linux distributor readonly MNT="/mnt" # Install mountpoint readonly ERR="/tmp/errlog" # Built-in error log @@ -43,8 +43,9 @@ main() 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 + elif [[ $WARN != true ]] && (( SELECTED == 2 || SELECTED == 5 )); then + msgbox "$_PrepTitle" "$_WarnMount" + WARN=true fi fi @@ -56,14 +57,17 @@ main() 5) mnt_menu || SELECTED=$((SELECTED - 1)) ;; 6) cfg_menu || SELECTED=$((SELECTED - 1)) ;; 7) show_cfg ;; - 8) install ;; + 8) install ;; *) yesno "$_CloseInst" "$_CloseInstBody" "Exit" "Back" && die esac } # source all the lib files for i in /usr/share/archlabs/installer/lib/?*.sh; do - . "$i" || { printf "\nFailed to source library file %s\n" "$i"; die 1; } + if ! . "$i" 2>/dev/null; then + printf "\nFailed to source library file %s\n" "$i" + die 1 + fi done # trap Ctrl-C to properly exit diff --git a/src/lib/dialogs.sh b/src/lib/dialogs.sh index cd13a31..f8083c0 100644 --- a/src/lib/dialogs.sh +++ b/src/lib/dialogs.sh @@ -48,16 +48,14 @@ declare -gA WM_SESSIONS=( [cinnamon]='cinnamon-session' ) -# additional packages installed for the given window manager -rp="rofi archlabs-polybar" +# additional packages installed for each wm/de declare -gA WM_EXT=( [gnome]="gnome-extra" -[bspwm]="sxhkd archlabs-skel-bspwm $rp" -[i3-gaps]="i3status perl-anyevent-i3 archlabs-skel-i3-gaps $rp" -[openbox]="obconf archlabs-skel-openbox jgmenu tint2 conky $rp" +[bspwm]="sxhkd archlabs-skel-bspwm rofi archlabs-polybar" [xfce4]="xfce4-goodies xfce4-pulseaudio-plugin archlabs-skel-xfce4" +[i3-gaps]="i3status perl-anyevent-i3 archlabs-skel-i3-gaps rofi archlabs-polybar" +[openbox]="obconf archlabs-skel-openbox jgmenu archlabs-polybar tint2 conky rofi" ) -unset rp # files the user can edit during the final stage of install declare -gA EDIT_FILES=( @@ -70,7 +68,7 @@ declare -gA EDIT_FILES=( [8]="/etc/crypttab" [9]="/etc/default/grub" [10]="/etc/pacman.conf" -[11]="" # login files populated later, /home/USER?/FILES? ... lightdm? +[11]="" # login files.. Populated later once login method is chosen ) # } diff --git a/src/lib/install.sh b/src/lib/install.sh index 68b2c52..a0e7a76 100644 --- a/src/lib/install.sh +++ b/src/lib/install.sh @@ -352,11 +352,23 @@ suckless_install() # install and setup dwm printf "\n%s\n\n" "Installing and setting up dwm." mkdir -pv $MNT/home/$NEWUSER/suckless + for i in dwm dmenu st; do p="/home/$NEWUSER/suckless/$i" - chrun "git clone https://bitbucket.org/natemaia/$i $p && { cd $p; rm -f $p/config.h 2>/dev/null; make clean install && make clean; }" + chrun "git clone https://bitbucket.org/natemaia/$i $p" + e=$? + if (( e == 0 )); then + chrun "cd $p; rm -f config.h; make clean install; make clean" + else + printf "\n\nFailed to clone dwm repo\n\n" + fi done - printf "\n\n%s\n\n" "To configure dwm edit /home/$NEWUSER/suckless/dwm/config.h and recompile with 'sudo make clean install'" + + if [[ -d /home/$NEWUSER/suckless/dwm ]]; then + printf "\n\n%s" "To configure dwm edit /home/$NEWUSER/suckless/dwm/config.h" + printf "\n%s\n\n" "You can then recompile it with 'sudo make clean install'" + fi + sleep 2 } diff --git a/src/lib/part.sh b/src/lib/part.sh index 7c47f5f..96726bc 100644 --- a/src/lib/part.sh +++ b/src/lib/part.sh @@ -6,7 +6,7 @@ # this file is not meant to be run directly # sourcing this file in a non bash shell is not advised -# shellcheck disable=2154,2153,2046 +# shellcheck disable=2154,2155,2153,2046 declare -Agr FS_CMDS=( [ext2]="mkfs.ext2 -q" [ext3]="mkfs.ext3 -q" [ext4]="mkfs.ext4 -q" @@ -107,7 +107,11 @@ select_device() { local dev local msg - [[ $1 == 'boot' ]] && msg="$_DevSelTitle for bootloader\n" || umount_dir $MNT + if [[ $1 == 'boot' ]]; then + msg="$_DevSelTitle for bootloader\n" + else + umount_dir $MNT + fi if [[ $DEV_COUNT -eq 1 && $SYS_DEVS ]]; then DEVICE="$(awk '{print $1}' <<< "$SYS_DEVS")" @@ -124,6 +128,7 @@ select_device() # if the device selected was for bootloader, set the BOOT_DEVICE [[ $1 == 'boot' ]] && BOOT_DEVICE="$DEVICE" + return 0 } @@ -131,14 +136,19 @@ confirm_mount() { local part="$1" local mount="$2" - local msg="Partition: $part\n" - [[ $mount == "$MNT" ]] && msg+="Mountpoint: / (root)" || msg+="Mountpoint: ${mount#$MNT}" + + if [[ $mount == "$MNT" ]]; then + local msg="Partition: $part\nMountpoint: / (root)" + else + local msg="Partition: $part\nMountpoint: ${mount#$MNT}" + fi if [[ $(mount) == *"$mount"* ]]; then - infobox "$_MntTitle" "$_MntSucc\n$msg\n" 1 && decr_count "$part" + infobox "$_MntTitle" "$_MntSucc\n$msg\n" 1; decr_count "$part" else - infobox "$_MntTitle" "$_MntFail\n$msg\n" 1 && return 1 + infobox "$_MntTitle" "$_MntFail\n$msg\n" 1; return 1 fi + return 0 } @@ -146,8 +156,7 @@ check_cryptlvm() { local dev="" local part="$1" - local devs - devs="$(lsblk -lno NAME,FSTYPE,TYPE)" + local devs="$(lsblk -lno NAME,FSTYPE,TYPE)" # Identify if $part is "crypt" (LUKS on LVM, or LUKS alone) if [[ $(lsblk -lno TYPE "$part") =~ 'crypt' ]]; then @@ -263,8 +272,7 @@ mount_partition() { local part="$1" local mountp="${MNT}$2" - local fs - fs="$(lsblk -lno FSTYPE $part)" + local fs="$(lsblk -lno FSTYPE $part)" mkdir -p "$mountp" diff --git a/src/lib/utils.sh b/src/lib/utils.sh index 871c59e..892bd8e 100644 --- a/src/lib/utils.sh +++ b/src/lib/utils.sh @@ -6,7 +6,7 @@ # this file is not meant to be run directly # sourcing this file in a non bash shell is not advised -# shellcheck disable=2154 +# shellcheck disable=2154,2034 chrun() { @@ -33,24 +33,36 @@ ssd() # returns 0 (true) when the device passed ($1) is NOT a rotational device local dev=$1 dev=${dev#/dev/} - [[ $dev =~ nvme ]] && dev=${dev%p[0-9]*} || dev=${dev%[0-9]*} + + if [[ $dev =~ nvme ]]; then + dev=${dev%p[0-9]*} + else + dev=${dev%[0-9]*} + fi + [[ $(cat /sys/block/$dev/queue/rotational) -eq 0 ]] || return 1 } die() { - # die peacefully - local exitcode=0 - (( $# == 0 )) || exitcode=$1 + + if (( $# >= 1 )); then + local exitcode=$1 + else + local exitcode=0 + fi + tput cnorm if [[ -d $MNT ]] && command cd /; then umount_dir $MNT if (( exitcode == 127 )); then - # umount -l /run/archiso/bootmnt + umount -l /run/archiso/bootmnt systemctl -i reboot fi fi + rm -fv /tmp/.ai_* + exit $exitcode } @@ -131,33 +143,40 @@ system_identify() if [[ -d $efidir ]]; then SYS="UEFI" [[ $(cat $efidir/fw_platform_size) == 64 ]] && export IS_64BIT=true - grep -q $efidir/efivars <<< "$(mount)" || mount -t efivarfs efivarfs $efidir/efivars + + if ! grep -q $efidir/efivars <<< "$(mount)"; then + mount -t efivarfs efivarfs $efidir/efivars + fi else SYS="BIOS" fi - # shellcheck disable=2034 declare -g BT="$DIST Installer - $SYS (x86_64) - Version $VER" - return 0 } system_checks() { - [[ $(whoami) == "root" ]] || { infobox "$_ErrTitle" "$_NotRoot\n$_Exit" && die 1; } - grep -qw 'lm' /proc/cpuinfo || { infobox "$_ErrTitle" "$_Not64Bit\n$_Exit" && die 1; } + if [[ $(whoami) != "root" ]]; then + infobox "$_ErrTitle" "$_NotRoot\n$_Exit" + die 1 + elif ! grep -qw 'lm' /proc/cpuinfo; then + infobox "$_ErrTitle" "$_Not64Bit\n$_Exit" + die 1 + fi if grep -qw 'BCM4352' <<< "$(lspci -vnn -d 14e4:)"; then rmmod bcma >/dev/null 2>&1 rmmod wl >/dev/null 2>&1 modprobe wl >/dev/null 2>&1 - export BROADCOM_WL=true + BROADCOM_WL=true printf "\nLoading wifi kernel modules please wait...\n" sleep 2 fi if ! curl -s --head 'https://www.archlinux.org/mirrorlist/all/' | sed '1q' | grep -qw '200'; then if [[ $(systemctl is-active NetworkManager) == "active" ]] && hash nmtui >/dev/null 2>&1; then - tput civis; nmtui-connect + tput civis + nmtui-connect if ! curl -s --head 'https://www.archlinux.org/mirrorlist/all/' | sed '1q' | grep -qw '200'; then infobox "$_ErrTitle" "$_NoNetwork" 3 die 1 @@ -170,34 +189,41 @@ system_checks() preinstall_checks() { - [[ $(lsblk -o MOUNTPOINT) =~ $MNT ]] || { msgbox "$_ErrTitle" "$_ErrNoMount"; export SELECTED=4; return 1; } - if [[ $# -eq 1 ]]; then - [[ $CONFIG_DONE == true ]] || { msgbox "$_ErrTitle" "$_ErrNoConfig"; export SELECTED=5; return 1; } + if ! [[ $(lsblk -o MOUNTPOINT) =~ $MNT ]]; then + msgbox "$_ErrTitle" "$_ErrNoMount" + SELECTED=4 + return 1 + elif [[ $# -eq 1 && $CONFIG_DONE != true ]]; then + msgbox "$_ErrTitle" "$_ErrNoConfig" + SELECTED=5 + return 1 fi + return 0 } echeck() { - # return if the last process exited normally local last_exit_code=$? - (( last_exit_code == 0 )) && return 0 - local msg="\nThe command exited abnormally: $1" + if (( last_exit_code == 0 )); then + return 0 + fi - # get error message from logfile and strip any non-printable characters, - # escape sequences, and other messy text local err err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")" - [[ $err != "" ]] && msgbox "$_ErrTitle" "$msg\n\nWith the following error message:\n\n$err" - msg="$([[ $err == "" ]] && printf "%s" "$msg")\n$_ErrChoice" - if [[ -e $DBG && $TERM == 'linux' ]]; then - msg="$([[ $err == "" ]] && printf "%s" "$msg")\n$_ErrChoiceConsole" - yesno "$_ErrTitle" "$msg" "Exit & Open Log" "Ignore & Continue" && { more $DBG; die; } + if [[ $err != "" ]]; then + msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the following error message:\n\n$err" else - yesno "$_ErrTitle" "$msg" "Exit" "Ignore & Continue" && die + msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the no error message.\n" fi + if [[ -e $DBG && $TERM == 'linux' ]]; then + more $DBG + fi + + die 1 + return 0 } @@ -206,13 +232,6 @@ debug() set -x exec 3>| $DBG BASH_XTRACEFD=3 - if [[ $DISPLAY && $TERM != 'linux' ]]; then - if hash 'termite' >/dev/null 2>&1; then - termite -e "tail -f $DBG" & - else - xterm -e "tail -f $DBG" & - fi - fi export DEBUG=true }