Show stderr during install when redirecting it to the error log

This commit is contained in:
natemaia 2019-10-17 22:08:13 -07:00
parent 7a69886935
commit faf132abb0

View File

@ -5,7 +5,7 @@
# Some ideas and code reworked from other resources # Some ideas and code reworked from other resources
# AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
VER=2.0.81 VER=2.0.82
# bulk default values { # bulk default values {
@ -619,10 +619,11 @@ part_show()
part_auto() part_auto()
{ {
local device="$1" table="$2" boot_fs="$3" size="$4" dev_info="" local device="$1" table="$2" boot_fs="$3" size="$4" dev_info=""
dev_info="$(parted -s "$device" print)"
msg "Auto Partition" "\nRemoving partitions on $device and setting table to $table\n" 1 msg "Auto Partition" "\nRemoving partitions on $device and setting table to $table\n" 1
dev_info="$(parted -s "$device" print)"
swapoff -a swapoff -a
while read -r PART; do while read -r PART; do
parted -s "$device" rm "$PART" >/dev/null 2>&1 parted -s "$device" rm "$PART" >/dev/null 2>&1
@ -914,7 +915,6 @@ part_mountconf()
mount_menu() mount_menu()
{ {
msg "Info" "\nGathering device info.\n" 0
no_bg_install || return 0 no_bg_install || return 0
lvm_detect lvm_detect
umount_dir $MNT umount_dir $MNT
@ -1172,7 +1172,7 @@ select_extra_partitions()
install_main() install_main()
{ {
install_base install_base
genfstab -U $MNT >$MNT/etc/fstab 2>$ERR genfstab -U $MNT >$MNT/etc/fstab 2>$ERR 2>&1
errshow 1 "genfstab -U $MNT >$MNT/etc/fstab" errshow 1 "genfstab -U $MNT >$MNT/etc/fstab"
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab [[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
install_packages install_packages
@ -1322,10 +1322,11 @@ install_boot()
fi fi
prerun_$BOOTLDR prerun_$BOOTLDR
chrun "${BCMDS[$BOOTLDR]}" 2>$ERR chrun "${BCMDS[$BOOTLDR]}" 2>$ERR 2>&1
errshow 1 "${BCMDS[$BOOTLDR]}" errshow 1 "${BCMDS[$BOOTLDR]}"
if [[ -d $MNT/hostrun ]]; then if [[ -d $MNT/hostrun ]]; then
echo "Unmounting chroot directories"
# cleanup the bind mounts we made earlier for the grub-probe module # cleanup the bind mounts we made earlier for the grub-probe module
umount_dir $MNT/hostrun/{udev,lvm} umount_dir $MNT/hostrun/{udev,lvm}
rm -rf $MNT/hostrun >/dev/null 2>&1 rm -rf $MNT/hostrun >/dev/null 2>&1
@ -1351,19 +1352,19 @@ install_user()
rm -f $MNT/root/.zshrc # remove welcome message from root zshrc rm -f $MNT/root/.zshrc # remove welcome message from root zshrc
chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR chrun "chpasswd <<< 'root:$ROOT_PASS'" 2>$ERR 2>&1
errshow 1 "set root password" errshow 1 "set root password"
if [[ $MYSHELL != 'zsh' ]]; then # root uses zsh by default if [[ $MYSHELL != 'zsh' ]]; then # root uses zsh by default
chrun "usermod -s /bin/$MYSHELL root" 2>$ERR chrun "usermod -s /bin/$MYSHELL root" 2>$ERR 2>&1
errshow 1 "usermod -s /bin/$MYSHELL root" errshow 1 "usermod -s /bin/$MYSHELL root"
# copy the default mkshrc to /root if it was selected # copy the default mkshrc to /root if it was selected
[[ $MYSHELL == 'mksh' ]] && cp -fv "$MNT/etc/skel/.mkshrc" "$MNT/root/.mkshrc" [[ $MYSHELL == 'mksh' ]] && cp -fv "$MNT/etc/skel/.mkshrc" "$MNT/root/.mkshrc"
fi fi
echo "Creating new user $NEWUSER and setting password" echo "Creating new user $NEWUSER and setting password"
chrun "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" 2>$ERR chrun "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" 2>$ERR 2>&1
errshow 1 "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER" errshow 1 "useradd -m -u 1000 -g users -G $groups -s /bin/$MYSHELL $NEWUSER"
chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2>$ERR chrun "chpasswd <<< '$NEWUSER:$USER_PASS'" 2>$ERR 2>&1
errshow 1 "set $NEWUSER password" errshow 1 "set $NEWUSER password"
if [[ $INSTALL_WMS == *dwm* ]];then if [[ $INSTALL_WMS == *dwm* ]];then
@ -1407,7 +1408,7 @@ install_login()
EOF EOF
fi fi
rm -rf "$serv" "$MNT/home/$NEWUSER/.xinitrc" rm -rf "$serv" "$MNT/home/$NEWUSER/.xinitrc"
chrun "systemctl enable $LOGIN_TYPE.service" 2>$ERR chrun "systemctl enable $LOGIN_TYPE.service" 2>$ERR 2>&1
errshow 1 "systemctl enable $LOGIN_TYPE.service" errshow 1 "systemctl enable $LOGIN_TYPE.service"
${LOGIN_TYPE}_config ${LOGIN_TYPE}_config
;; ;;
@ -1451,7 +1452,7 @@ install_packages()
fi fi
# update and install crucial packages first to avoid issues # update and install crucial packages first to avoid issues
chrun "pacman -Syyu $KERNEL $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $MYSHELL --noconfirm --needed" 2>$ERR chrun "pacman -Syyu $KERNEL $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $MYSHELL --noconfirm --needed" 2>$ERR 2>&1
errshow 1 "pacman -Syyu $KERNEL $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $MYSHELL --noconfirm --needed" errshow 1 "pacman -Syyu $KERNEL $BASE_PKGS ${LOGIN_PKGS[$LOGIN_TYPE]} $MYSHELL --noconfirm --needed"
# remove the packages we don't want on the installed system # remove the packages we don't want on the installed system
@ -1461,19 +1462,19 @@ install_packages()
chrun "pacman -S iputils $UCODE --noconfirm" chrun "pacman -S iputils $UCODE --noconfirm"
# install the packages chosen throughout the install # install the packages chosen throughout the install
chrun "pacman -S $inpkg --needed --noconfirm" 2>$ERR chrun "pacman -S $inpkg --needed --noconfirm" 2>$ERR 2>&1
errshow 1 "pacman -S $inpkg --needed --noconfirm" errshow 1 "pacman -S $inpkg --needed --noconfirm"
# bootloader packages # bootloader packages
if [[ $BOOTLDR == 'grub' ]]; then if [[ $BOOTLDR == 'grub' ]]; then
[[ $SYS == 'UEFI' ]] && local efib="efibootmgr" [[ $SYS == 'UEFI' ]] && local efib="efibootmgr"
chrun "pacman -S os-prober grub $efib --needed --noconfirm" 2>$ERR chrun "pacman -S os-prober grub $efib --needed --noconfirm" 2>$ERR 2>&1
errshow 1 "pacman -S os-prober grub $efib --needed --noconfirm" errshow 1 "pacman -S os-prober grub $efib --needed --noconfirm"
elif [[ $BOOTLDR == 'refind-efi' ]]; then elif [[ $BOOTLDR == 'refind-efi' ]]; then
chrun "pacman -S refind-efi efibootmgr --needed --noconfirm" 2>$ERR chrun "pacman -S refind-efi efibootmgr --needed --noconfirm" 2>$ERR 2>&1
errshow 1 "pacman -S refind-efi efibootmgr --needed --noconfirm" errshow 1 "pacman -S refind-efi efibootmgr --needed --noconfirm"
elif [[ $SYS == 'UEFI' ]]; then elif [[ $SYS == 'UEFI' ]]; then
chrun "pacman -S efibootmgr --needed --noconfirm" 2>$ERR chrun "pacman -S efibootmgr --needed --noconfirm" 2>$ERR 2>&1
errshow 1 "pacman -S efibootmgr --needed --noconfirm" errshow 1 "pacman -S efibootmgr --needed --noconfirm"
fi fi
@ -1489,7 +1490,7 @@ install_mkinitcpio()
[[ $LUKS ]] && add="encrypt" [[ $LUKS ]] && add="encrypt"
[[ $LVM ]] && { [[ $add ]] && add+=" lvm2" || add+="lvm2"; } [[ $LVM ]] && { [[ $add ]] && add+=" lvm2" || add+="lvm2"; }
sed -i "s/block filesystems/block ${add} filesystems ${HOOKS}/g" $MNT/etc/mkinitcpio.conf 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 2>&1
errshow 1 "mkinitcpio -p $KERNEL" errshow 1 "mkinitcpio -p $KERNEL"
} }
@ -1621,12 +1622,12 @@ prerun_grub()
sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g; s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $MNT/etc/default/grub sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g; 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; s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $MNT/etc/default/grub 2>$ERR 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 2>&1
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
sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $MNT/etc/default/grub 2>$ERR sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $MNT/etc/default/grub 2>$ERR 2>&1
errshow 1 "sed -i 's/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g' $MNT/etc/default/grub" errshow 1 "sed -i 's/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g' $MNT/etc/default/grub"
fi fi
@ -1767,7 +1768,6 @@ prerun_systemd-boot()
lvm_menu() lvm_menu()
{ {
msg "Info" "\nGathering device info.\n" 0
no_bg_install || return 1 no_bg_install || return 1
lvm_detect lvm_detect
local choice local choice