Large update and cleanup, attempted fix for grub-install

This commit is contained in:
natemaia 2018-12-14 14:30:13 -08:00
parent f96435486a
commit a3c3ec6730
10 changed files with 106 additions and 81 deletions

View File

@ -119,10 +119,6 @@ _ExtPartBody1="\nWhere do you want the partition mounted?\n\nEnsure the name beg
_KernelTitle="Choose Kernel" _KernelTitle="Choose Kernel"
_KernelBody="\nSelect which kernel to use for the install." _KernelBody="\nSelect which kernel to use for the install."
# base-devel
_DevelTitle="Install base-devel packages"
_DevelBody="\nDo you want base-devel installed for compiling and building packages?"
# shell # shell
_ShellTitle="Choose Login Shell" _ShellTitle="Choose Login Shell"
_ShellBody="\nSelect which shell to use as the new user's login shell." _ShellBody="\nSelect which shell to use as the new user's login shell."

View File

@ -10,7 +10,7 @@
# immutable globals # immutable globals
readonly VER="1.7.29" # Installer version readonly VER="1.7.30" # Installer version
readonly DIST="ArchLabs" # Linux distributor readonly DIST="ArchLabs" # Linux distributor
readonly MNT="/mnt" # Install mountpoint readonly MNT="/mnt" # Install mountpoint
readonly ERR="/tmp/errlog" # Built-in error log readonly ERR="/tmp/errlog" # Built-in error log

View File

@ -137,7 +137,10 @@ install_bootloader()
# install/setup the bootloader by running the BCMD (boot command) # install/setup the bootloader by running the BCMD (boot command)
printf "\nInstalling and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n\n" printf "\nInstalling and setting up $BOOTLDR in ${BMNTS[$SYS-$BOOTLDR]}\n\n"
chrun "${BCMDS[$BOOTLDR]}"
mkdir -p $MNT/{hostrun,run/udev}
mount --bind /run $MNT/hostrun
chrun "mount --bind /hostrun/lvm /run/lvm; mount --bind /hostrun/udev /run/udev ${BCMDS[$BOOTLDR]}; umount /run/lvm; umount /run/udev"
echeck "${BCMDS[$BOOTLDR]}" echeck "${BCMDS[$BOOTLDR]}"
# copy efi stub to generic catch all # copy efi stub to generic catch all

View File

@ -153,13 +153,10 @@ cfg_menu()
fi fi
select_mirrorcmd || return 1 select_mirrorcmd || return 1
yesno "$_DevelTitle" "$_DevelBody" && BASEDEV=true || BASEDEV=false
select_wm_or_de || return 1 select_wm_or_de || return 1
select_packages || return 1 select_packages || return 1
export CONFIG_DONE=true CONFIG_DONE=true
return 0 return 0
} }
@ -250,9 +247,9 @@ user_creation()
# recursively loop back unless the user cancels # recursively loop back unless the user cancels
user || return 1 user || return 1
else else
export NEWUSER="$user" NEWUSER="$user"
export USER_PASS="$pass" USER_PASS="$pass"
export ROOT_PASS="$rpass" ROOT_PASS="$rpass"
fi fi
return 0 return 0
} }

View File

@ -9,6 +9,7 @@
# shellcheck disable=2153 # shellcheck disable=2153
readonly RUN="/run/archiso/bootmnt/arch/boot" readonly RUN="/run/archiso/bootmnt/arch/boot"
readonly SERVICE="$MNT/etc/systemd/system/getty@tty1.service.d"
readonly VM="$(dmesg | grep -i "hypervisor")" readonly VM="$(dmesg | grep -i "hypervisor")"
install() install()
@ -116,6 +117,7 @@ EOF
# set the locale # set the locale
printf "\n\n"
cat > $MNT/etc/locale.conf << EOF cat > $MNT/etc/locale.conf << EOF
LANG=$LOCALE LANG=$LOCALE
EOF EOF
@ -201,20 +203,76 @@ create_user()
return 0 return 0
} }
login_manager() setup_xinit()
{ {
local service="$MNT/etc/systemd/system/getty@tty1.service.d" if [[ -e $MNT/home/$NEWUSER/.xinitrc ]]; then
sed -i "s/openbox-session/${LOGIN_WM}/g" $MNT/home/$NEWUSER/.xinitrc
else
printf "%s\n" "exec $LOGIN_WM" > $MNT/home/$NEWUSER/.xinitrc
fi
# remove welcome message # automatic startx for login shells
sed -i '/printf/d' $MNT/root/.zshrc local loginrc
case $MYSHELL in
*bash)
loginrc=".bash_profile"
rm -rf $MNT/home/$NEWUSER/.{z,mksh}*
;;
*mksh)
loginrc=".profile"
rm -rf $MNT/home/$NEWUSER/.{z,bash}*
cat >> $MNT/home/$NEWUSER/.mkshrc << EOF
# colors in less (manpager)
export LESS_TERMCAP_mb=$'\e[01;31m'
export LESS_TERMCAP_md=$'\e[01;31m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;44;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[01;32m'
if [[ $LOGIN_TYPE == 'lightdm' ]]; then export EDITOR=vim
export MANWIDTH=100
rm -rf $service # source shell configs
chrun 'systemctl enable lightdm.service && systemctl set-default graphical.target' for f in "\$HOME/.mksh/"*?.sh; do
. "\$f"
done
cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF al-info
EOF
;;
*)
loginrc=".zprofile"
rm -rf $MNT/home/$NEWUSER/.{bash,mksh}*
esac
# add the shell login file to the edit list after install
EDIT_FILES[11]+=" /home/$NEWUSER/$loginrc"
cat >> $MNT/home/$NEWUSER/$loginrc << EOF
# ~/$loginrc
# sourced by $(basename $MYSHELL) when used as a login shell
# automatically run startx when logging in on tty1
if [ -z "\$DISPLAY" ] && [ \$XDG_VTNR -eq 1 ]; then
exec startx -- vt1 >/dev/null 2>&1
fi
EOF
if [[ $AUTOLOGIN == true ]]; then
sed -i "s/root/${NEWUSER}/g" $SERVICE/autologin.conf
else
rm -rf $SERVICE
fi
}
setup_lightdm()
{
rm -rf $SERVICE
chrun 'systemctl set-default graphical.target && systemctl enable lightdm.service'
cat > $MNT/etc/lightdm/lightdm-gtk-greeter.conf << EOF
# LightDM GTK+ Configuration # LightDM GTK+ Configuration
[greeter] [greeter]
@ -226,39 +284,18 @@ icon-theme-name=Adwaita
font-name=DejaVu Sans Mono 11 font-name=DejaVu Sans Mono 11
position=30%,end 50%,end position=30%,end 50%,end
EOF EOF
}
else # xinit login login_manager()
{
if [[ -e $MNT/home/$NEWUSER/.xinitrc ]]; then # remove welcome message
sed -i "s/openbox-session/${LOGIN_WM}/g" $MNT/home/$NEWUSER/.xinitrc sed -i '/printf/d' $MNT/root/.zshrc
else
printf "%s\n" "exec $LOGIN_WM" > $MNT/home/$NEWUSER/.xinitrc
fi
# automatic startx for login shells if [[ $LOGIN_TYPE == 'lightdm' ]]; then
case $MYSHELL in setup_lightdm
*bash) local loginrc=".bash_profile" ;; else
*zsh) local loginrc=".zprofile" ;; setup_shell_xinit
*mksh) local loginrc=".profile" ;;
esac
# add the shell login file to the edit list after install
EDIT_FILES[11]+=" /home/$NEWUSER/$loginrc"
cat >> $MNT/home/$NEWUSER/$loginrc << EOF
# ~/$loginrc
# sourced by $(basename $MYSHELL) when used as a login shell
# automatically run startx when logging in on tty1
if [ -z "\$DISPLAY" ] && [ \$XDG_VTNR -eq 1 ]; then
exec startx -- vt1 >/dev/null 2>&1
fi
EOF
if [[ $AUTOLOGIN == true ]]; then
sed -i "s/root/${NEWUSER}/g" $service/autologin.conf
else
rm -rf $service
fi
fi fi
} }
@ -326,22 +363,9 @@ package_operations()
fi fi
chrun "pacman -Syyu --noconfirm" chrun "pacman -Syyu --noconfirm"
chrun "pacman -S iputils --noconfirm" 2>/dev/null
# base-devel and git are the users choice chrun "pacman -S base-devel git --needed --noconfirm" 2>/dev/null
if [[ $BASEDEV == true ]]; then
chrun "pacman -S iputils --noconfirm" 2>/dev/null
chrun "pacman -S base-devel git --needed --noconfirm" 2>/dev/null
elif [[ $INSTALL_WMS =~ dwm ]]; then
chrun "pacman -S iputils git make --noconfirm" 2>/dev/null
else
# iputils is needed and should always be installed
chrun "pacman -S iputils --noconfirm" 2>/dev/null
fi
# install chosen packages
chrun "pacman -S $inpkg --needed --noconfirm" chrun "pacman -S $inpkg --needed --noconfirm"
# remove packages: installer, linux?, grub?
chrun "pacman -Rs $rmpkg --noconfirm" chrun "pacman -Rs $rmpkg --noconfirm"
return 0 return 0

View File

@ -117,7 +117,7 @@ luks_default()
cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$LUKS_PASS" 2>$ERR
echeck "cryptsetup open $LUKS_PART $LUKS_NAME" echeck "cryptsetup open $LUKS_PART $LUKS_NAME"
export LUKS=' encrypted' LUKS=' encrypted'
luks_show luks_show
return 0 return 0
} }

View File

@ -6,7 +6,7 @@
# this file is not meant to be run directly # this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised # sourcing this file in a non bash shell is not advised
# shellcheck disable=2154 # shellcheck disable=2154,2034
declare -g LVM="" declare -g LVM=""
declare -g VOL_GROUP_MB=0 declare -g VOL_GROUP_MB=0
@ -264,7 +264,7 @@ lvm_del_all()
for i in $PHYSICAL_VOLUMES; do for i in $PHYSICAL_VOLUMES; do
pvremove -f "$i" >/dev/null 2>&1 pvremove -f "$i" >/dev/null 2>&1
done done
export LVM=' logical volume' LVM=' logical volume'
fi fi
return 0 return 0

View File

@ -6,16 +6,21 @@
# this file is not meant to be run directly # this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised # sourcing this file in a non bash shell is not advised
# shellcheck disable=2154,2153,2046 # shellcheck disable=2154,2153,2046,2034
readonly SYS_MEM="$(awk '/MemTotal/ {print int($2 / 1024)"M"}' /proc/meminfo)" readonly SYS_MEM="$(awk '/MemTotal/ {print int($2 / 1024)"M"}' /proc/meminfo)"
readonly LOCALES="$(awk '/\.UTF-8/ { gsub(/# .*|#/, "")
readonly LOCALES="$(awk '/\.UTF-8/ {
gsub(/# .*|#/, "")
if ($1) { if ($1) {
print $1 " -" print $1 " -"
} }
}' /etc/locale.gen)" }' /etc/locale.gen)"
readonly CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' |
awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}')" readonly CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{
gsub(/\.map\.gz|.*\//, "")
print $1 " -"
}')"
mnt_menu() mnt_menu()
{ {
@ -123,11 +128,11 @@ select_boot_setup()
BCMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST" BCMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST"
fi fi
else else
export FILES[9]="/etc/default/grub" FILES[9]="/etc/default/grub"
if [[ $SYS == 'UEFI' ]]; then if [[ $SYS == 'UEFI' ]]; then
local ttype="i386-efi" local ttype="i386-efi"
[[ $IS_64BIT == true ]] && ttype='x86_64-efi' [[ $IS_64BIT == true ]] && ttype='x86_64-efi'
BCMDS[grub]+=" --target=$ttype --efi-directory=${BMNTS[$SYS-$BOOTLDR]} --bootloader-id=$DIST" BCMDS[grub]+=" --target=$ttype --efi-directory=${BMNTS[$SYS-grub]} --bootloader-id=$DIST"
else else
BCMDS[grub]+=" --target=i386-pc $BOOT_DEVICE" BCMDS[grub]+=" --target=i386-pc $BOOT_DEVICE"
fi fi
@ -141,7 +146,7 @@ select_boot_setup()
src /usr/share/archlabs/installer/lib/boot.sh src /usr/share/archlabs/installer/lib/boot.sh
return 1 return 1
fi fi
export SEPERATE_BOOT=true SEPERATE_BOOT=true
fi fi
return 0 return 0

View File

@ -6,7 +6,7 @@
# this file is not meant to be run directly # this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised # sourcing this file in a non bash shell is not advised
# shellcheck disable=2154,2155,2153,2046 # shellcheck disable=2154,2155,2153,2046,2034
declare -Agr FS_CMDS=( declare -Agr FS_CMDS=(
[ext2]="mkfs.ext2 -q" [ext3]="mkfs.ext3 -q" [ext4]="mkfs.ext4 -q" [ext2]="mkfs.ext2 -q" [ext3]="mkfs.ext3 -q" [ext4]="mkfs.ext4 -q"
@ -179,7 +179,7 @@ check_cryptlvm()
done done
elif [[ $(lsblk -lno TYPE "$part") =~ 'lvm' ]]; then elif [[ $(lsblk -lno TYPE "$part") =~ 'lvm' ]]; then
export LVM=' logical volume' LVM=' logical volume'
VOLUME_NAME="${part#/dev/mapper/}" VOLUME_NAME="${part#/dev/mapper/}"
for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do
@ -192,7 +192,7 @@ check_cryptlvm()
if grep -q "$LUKS_NAME" <<< "$(lsblk -lno NAME "$dev")"; then if grep -q "$LUKS_NAME" <<< "$(lsblk -lno NAME "$dev")"; then
LUKS_UUID="$(lsblk -lno UUID,TYPE,FSTYPE "$dev" | awk '/part/ && /crypto_LUKS/ {print $1}')" LUKS_UUID="$(lsblk -lno UUID,TYPE,FSTYPE "$dev" | awk '/part/ && /crypto_LUKS/ {print $1}')"
LUKS_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME" LUKS_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME"
export LUKS=' encrypted' LUKS=' encrypted'
break break
fi fi
done done

View File

@ -142,7 +142,7 @@ system_identify()
if [[ -d $efidir ]]; then if [[ -d $efidir ]]; then
SYS="UEFI" SYS="UEFI"
[[ $(cat $efidir/fw_platform_size) == 64 ]] && export IS_64BIT=true [[ $(cat $efidir/fw_platform_size) == 64 ]] && IS_64BIT=true
if ! grep -q $efidir/efivars <<< "$(mount)"; then if ! grep -q $efidir/efivars <<< "$(mount)"; then
mount -t efivarfs efivarfs $efidir/efivars mount -t efivarfs efivarfs $efidir/efivars
@ -232,7 +232,7 @@ debug()
set -x set -x
exec 3>| $DBG exec 3>| $DBG
BASH_XTRACEFD=3 BASH_XTRACEFD=3
export DEBUG=true DEBUG=true
} }
umount_dir() umount_dir()