diff --git a/src/archlabs-installer b/src/archlabs-installer index 66d6f30..e21ba75 100755 --- a/src/archlabs-installer +++ b/src/archlabs-installer @@ -8,7 +8,7 @@ # Some ideas and code has been taken from other installers # AIF, Cnichi, Calamares, The Arch Wiki.. Credit where credit is due -VER="1.8.12" # version +VER="1.8.13" # version DIST="ArchLabs" # distributor MNT="/mnt" # mountpoint @@ -1212,9 +1212,8 @@ install_base() printf "\n" rm -rf $MNT/etc/mkinitcpio-archiso.conf - find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm '{}' \; + find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm -rf '{}' \; sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf - sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers if [[ $VM ]]; then rm -rfv $MNT/etc/X11/xorg.conf.d/*?.conf @@ -1303,7 +1302,9 @@ create_user() # Create the user, set password, and make sure the ownership of ~/ is correct local groups='audio,autologin,floppy,log,network,rfkill,scanner,storage,optical,power,wheel' chrun "groupadd -r autologin" - chrun "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" 2>$ERR + chrun "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" 2>$ERR || + chrun "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" 2>$ERR + echeck "useradd -m -u 1000 -g users -G $groups -s $MYSHELL $NEWUSER" chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" # for neovim set up ~/.config/nvim @@ -1312,14 +1313,9 @@ create_user() cp -fv $MNT/home/$NEWUSER/.vimrc $MNT/home/$NEWUSER/.config/nvim/init.vim cp -rfv $MNT/home/$NEWUSER/.vim/colors $MNT/home/$NEWUSER/.config/nvim/colors fi - [[ $INSTALL_WMS =~ dwm ]] && suckless_install - - if [[ $INSTALL_WMS == 'plasma' || $LOGIN_WM == 'startkde' ]]; then - # plasma has their own superkey daemon that conflicts with ksuperkey - sed -i '/super/d' $HOME/.xprofile - sed -i '/super/d' /root/.xprofile - fi + [[ $INSTALL_WMS == 'plasma' || $LOGIN_WM == 'startkde' || $INSTALL_WMS == 'gnome' || $LOGIN_WM == 'gnome-session' ]] && + sed -i '/super/d' $HOME/.xprofile /root/.xprofile return 0 } @@ -1433,7 +1429,7 @@ run_mkinitcpio() [[ $LUKS ]] && add="encrypt" [[ $LVM ]] && { [[ $add ]] && add+=" lvm2" || add+="lvm2"; } sed -i "s/block filesystems/block ${add} filesystems ${HOOKS}/g" $MNT/etc/mkinitcpio.conf - chrun "mkinitcpio -p $KERNEL" 2>$ERR + chrun "mkinitcpio -p $KERNEL" 2>$ERR || chrun "mkinitcpio -p $KERNEL" 2>$ERR echeck "mkinitcpio -p $KERNEL" } @@ -1451,30 +1447,49 @@ mirrorlist_sort() package_operations() { - local inpkg="$PACKAGES" # add the packages chosen during setup - local rmpkg="archlabs-installer" # always remove the installer - + # add the packages chosen during setup if [[ $KERNEL == 'linux-lts' ]]; then - rmpkg+=" linux" - inpkg+=" linux-lts" + local inpkg="linux-lts $PACKAGES" + local rmpkg="archlabs-installer linux" + else + local inpkg="$PACKAGES" + local rmpkg="archlabs-installer" fi + + local wmpkgs=( # packages used for window managers + archlabs nitrogen polkit-gnome volumeicon xclip xdotool + compton gnome-keyring arandr dunst feh gsimplecal + xfce4-power-manager xfce4-settings laptop-detect + ) + + local basepkgs=( # packages used in all systems + gtk-engine-murrine gtk3 pavucontrol xdg-user-dirs tumbler + base base-devel sudo git udisks2 gvfs mesa xorg-server + xorg-apps xorg-drivers playerctl ffmpeg gstreamer libmad + libmatroska gst-libav gst-plugins-base gst-plugins-good + ) + + # update first to avoid database access errors + chrun "pacman -Syyu --noconfirm" + if [[ $INSTALL_WMS == 'plasma' || $INSTALL_WMS == 'gnome' || $INSTALL_WMS == 'cinnamon' ]]; then chrun "pacman -Rnsc archlabs-ksuperkey xfce4 --noconfirm" fi if [[ $BOOTLDR != 'grub' ]]; then chrun "pacman -Rns grub --noconfirm" - rm -f $MNT/etc/default/grub 2>dev/null - find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1 fi - if [[ $BOOTLDR != 'syslinux' ]]; then - find $MNT/boot/ -name 'syslinux*' -exec rm -rf '{}' \; >/dev/null 2>&1 + chrun "pacman -Rns $rmpkg --noconfirm" + chrun "pacman -S iputils --noconfirm" + chrun "pacman -S $inpkg --needed --noconfirm" + chrun "pacman -S ${basepkgs[@]} --needed --noconfirm" + if [[ $LOGIN_TYPE == 'xinit' ]]; then + chrun "pacman -S xorg-xinit --needed --noconfirm" + fi + if [[ $inpkg =~ (openbox|dwm|bspwm|i3-gaps) ]]; then + chrun "pacman -S ${wmpkgs[@]} --needed --noconfirm" fi - chrun "pacman -Syyu --noconfirm" - chrun "pacman -S iputils --noconfirm" - chrun "pacman -S base-devel git --needed --noconfirm" - chrun "pacman -S $inpkg --needed --noconfirm" - chrun "pacman -Rns $rmpkg --noconfirm" + sed -i "s/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g" $MNT/etc/sudoers return 0 } @@ -1532,7 +1547,7 @@ setup_grub() if [[ $ROOT_PART == */dev/mapper/* && ! $LVM && ! $LUKS_PASS ]]; then luks_pass "$_LuksOpen" "" || return 1 fi - BCMDS[grub]="${BCMDS[grub]} --removable" + BCMDS[grub]="${BCMDS[grub]} --bootloader-id=$DIST" fi BCMDS[grub]="mkdir -p /run/udev && @@ -1652,11 +1667,9 @@ install_bootloader() if ! [[ $ROOT_PART =~ /dev/mapper ]]; then ROOT_PART_ID="UUID=$(blkid -s PARTUUID -o value $ROOT_PART)" else - # for LVM we just use the partition label ROOT_PART_ID="$ROOT_PART" fi - # remove old UEFI boot entries if [[ $SYS == 'UEFI' ]]; then find ${MNT}${BMNTS[UEFI-$BOOTLDR]}/EFI/ \ -maxdepth 1 -mindepth 1 -name '[aA][rR][cC][hH][lL]abs' -type d -exec rm -rf '{}' \; >/dev/null 2>&1 @@ -1664,18 +1677,32 @@ install_bootloader() -maxdepth 1 -mindepth 1 -name '[Bb][oO][oO][tT]' -type d -exec rm -rf '{}' \; >/dev/null 2>&1 fi + if [[ $BOOTLDR != 'grub' ]]; then + rm -f $MNT/etc/default/grub 2>dev/null + find $MNT/boot/ -name 'grub*' -exec rm -rf '{}' \; >/dev/null 2>&1 + fi + + if [[ $BOOTLDR != 'syslinux' ]]; then + find $MNT/boot/ -name 'syslinux*' -exec rm -rf '{}' \; >/dev/null 2>&1 + fi + prerun_$BOOTLDR printf "\nInstalling and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n\n" chrun "${BCMDS[$BOOTLDR]}" echeck "${BCMDS[$BOOTLDR]}" if [[ -d $MNT/hostrun ]]; then - # remove mounted directories umount $MNT/hostrun/udev >/dev/null 2>&1 umount $MNT/hostrun/lvm >/dev/null 2>&1 rm -rf $MNT/hostrun >/dev/null 2>&1 fi + if [[ $BOOTLDR == 'grub' && $SYS == 'UEFI' ]]; then + local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}" + mkdir -pv $esp/EFI/BOOT + cp -fv $esp/EFI/$DIST/grubx64.efi $esp/EFI/BOOT/BOOTX64.EFI + fi + return 0 } @@ -1751,20 +1778,16 @@ get_lv_size() fi ERR_SIZE=0 - # if the size is empty or 0 (( ${#VOLUME_SIZE} == 0 || ${VOLUME_SIZE:0:1} == 0 )) && ERR_SIZE=1 if (( ERR_SIZE == 0 )); then - # number of characters in VOLUME_SIZE minus the last, which should be a letter local lv="$((${#VOLUME_SIZE} - 1))" - # loop each character (except the last) in VOLUME_SIZE and ensure they are numbers for (( i=0; i= VOL_GROUP_MB )); then @@ -1818,7 +1839,6 @@ lvm_volume_name() return 1 fi - # bad volume name answer or name already in use if [[ ${name:0:1} == "/" || ${#name} -eq 0 || $name =~ \ |\' ]] || grep -q "$name" <<< "$(lsblk)"; then msgbox "$_ErrTitle" "$_LvmLvNameErrBody" lvm_volume_name "$msg" || return 1 @@ -1836,7 +1856,6 @@ lvm_group_name() return 1 fi - # bad answer or group name already taken if [[ ${group:0:1} == "/" || ${#group} -eq 0 || $group =~ \ |\' ]] || grep -q "$group" <<< "$(lsblk)"; then msgbox "$_ErrTitle" "$_LvmNameVgErr" lvm_group_name || return 1 @@ -1849,16 +1868,12 @@ lvm_group_name() lvm_extra_lvs() { while (( VOL_COUNT > 1 )); do - # get the name and size lvm_volume_name "$_LvmLvNameBody1" || { break; return 1; } get_lv_size || { break; return 1; } - - # create it lvcreate -L "$VOLUME_SIZE" "$VOLUME_GROUP" -n "$VOLUME_NAME" >/dev/null 2>$ERR errshow "lvcreate -L $VOLUME_SIZE $VOLUME_GROUP -n $VOLUME_NAME" msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$_Done LV $VOLUME_NAME ($VOLUME_SIZE) $_LvmPvDoneBody2." - - ((VOL_COUNT--)) # decrement the number of volumes chosen after each loop + ((VOL_COUNT--)) done return 0 @@ -1880,29 +1895,23 @@ lvm_partitions() find_partitions 'part|crypt' || return 1 PARTS="$(awk 'NF > 0 {print $0 " off"}' <<< "$PARTS")" - # choose partitions tput civis GROUP_PARTS=($(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ --title " $_LvmCreateVG " --checklist "$_LvmPvSelBody" 0 0 0 $PARTS)) - # return code, when less than 1 part was selected will return non-zero (( ${#GROUP_PARTS[@]} >= 1 )) } lvm_create_group() { - - # get volume group name lvm_group_name || return 1 - # loop while setup is not confirmed by the user local msg="$_LvmPvConfBody1 $VOLUME_GROUP\n\n$_LvmPvConfBody2" while ! yesno "$_LvmCreateVG" "$msg ${GROUP_PARTS[*]}\n"; do lvm_partitions || { break; return 1; } lvm_group_name || { break; return 1; } done - # create it vgcreate -f "$VOLUME_GROUP" "${GROUP_PARTS[@]}" >/dev/null 2>$ERR errshow "vgcreate -f $VOLUME_GROUP ${GROUP_PARTS[*]}" @@ -1921,7 +1930,6 @@ lvm_create_group() VOL_GROUP_MB=$GROUP_SIZE fi - # finished volume group creation local msg="$_LvmPvDoneBody1 $VOLUME_GROUP ($GROUP_SIZE $GROUP_SIZE_TYPE)" msgbox "$_LvmCreateVG" "$msg $_LvmPvDoneBody2\n" return 0 @@ -2062,11 +2070,9 @@ luks_pass() "$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) $COLUMNS 0 1)"; then return 1 fi - name="$(awk -F'~' '{print $1}' <<< "$values")" pass="$(awk -F'~' '{print $2}' <<< "$values")" pass2="$(awk -F'~' '{print $3}' <<< "$values")" - LUKS_NAME="$name" fi @@ -2103,13 +2109,10 @@ luks_default() { luks_setup || return 1 infobox "$_LuksEncrypt" "$_LuksCreateWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0 - cryptsetup -q luksFormat $LUKS_PART <<< "$LUKS_PASS" 2>$ERR errshow "cryptsetup -q luksFormat $LUKS_PART" - cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR errshow "cryptsetup open $LUKS_PART $LUKS_NAME" - LUKS='encrypted' luks_show return 0 @@ -2124,13 +2127,10 @@ luks_keycmd() return 1 fi infobox "$_LuksEncryptAdv" "$_LuksCreateWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0 - cryptsetup -q $cipher luksFormat $LUKS_PART <<< "$LUKS_PASS" 2>$ERR errshow "cryptsetup -q $cipher luksFormat $LUKS_PART" - cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR errshow "cryptsetup open $LUKS_PART $LUKS_NAME" - luks_show return 0 fi @@ -2146,18 +2146,12 @@ luks_show() luks_keyfile() { - # Only used when choosing grub as bootloader. - # Without a keyfile, during boot the user will be asked - # to enter password for decryption twice, this is annoying - if [[ ! -e $MNT/crypto_keyfile.bin && $LUKS_PASS && $LUKS_UUID ]]; then local n n="$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')" - local mkkey="dd bs=512 count=8 if=/dev/urandom of=/crypto_keyfile.bin" mkkey="$mkkey && chmod 000 /crypto_keyfile.bin" mkkey="$mkkey && cryptsetup luksAddKey /dev/$n /crypto_keyfile.bin <<< '$LUKS_PASS'" - chrun "$mkkey" sed -i 's/FILES=()/FILES=(\/crypto_keyfile.bin)/g' $MNT/etc/mkinitcpio.conf 2>$ERR fi @@ -2213,7 +2207,7 @@ select_language() chrun() { - arch-chroot $MNT /bin/bash -c "$1" + arch-chroot $MNT bash -c "$1" || arch-chroot $MNT sh -c "$1" } json() @@ -2246,10 +2240,7 @@ ssd() dev=${dev#/dev/} [[ $dev =~ nvme ]] && dev=${dev%p[0-9]*} || dev=${dev%[0-9]*} - i=$(cat /sys/block/$dev/queue/rotational 2>/dev/null) - - # return value check (( ${i:-1} == 0 )) } @@ -2373,20 +2364,14 @@ load_bcm() net_connect() { chk_connect() { curl -s --head 'https://www.archlinux.org/mirrorlist/all/' | sed '1q' | grep -qw '200'; } - if ! chk_connect; then if [[ $(systemctl is-active NetworkManager) == "active" ]] && hash nmtui >/dev/null 2>&1; then tput civis - - # fix ugly nmtui colours - printf "\e]P1191919" # #191919 - printf "\e]P4191919" # #191919 - + printf "\e]P1191919" + printf "\e]P4191919" nmtui-connect - - # restore - printf "\e]P1D15355" # #D15355 - printf "\e]P4255a9b" # #255a9b + printf "\e]P1D15355" + printf "\e]P4255a9b" chk_connect || return 1 else return 1