Combine mount and partition lib files, and other minor changes
This commit is contained in:
parent
a48143063a
commit
e948933780
@ -61,32 +61,15 @@ _OnlyOne="\nOnly one partition available"
|
||||
# finished
|
||||
_InstFinBody="\nThe installation is now finished.\n\nWould you like to close the installer and reboot?\n"
|
||||
|
||||
# locale
|
||||
_GenLocale="\nGenerating locale:"
|
||||
|
||||
# error message
|
||||
_ErrChoice="\nUnmount the partitions and shutdown or keep them mounted and continue?\n"
|
||||
_ErrChoiceConsole="\nUnmount the partitions and exit to view the error log or keep them mounted and continue?\n"
|
||||
|
||||
# keyfile creation
|
||||
_LuksKeyFileTitle="Create Encryption Keyfile"
|
||||
_LuksKeyFileCreate="\nCreating: /crypto_keyfile.bin\n"
|
||||
|
||||
# timezone
|
||||
_TimeZTitle="Set Timezone"
|
||||
|
||||
# mkinit
|
||||
_RunMkinit="Update Initramfs"
|
||||
_RunMkinitBody="\nUpdating initramfs with added hooks\n\nCommand: mkinitcpio -p linux"
|
||||
|
||||
# update
|
||||
_UpdSysTitle="System Update"
|
||||
_UpdSysBody="\nSystem package operation\n\nUpdate: pacman -Syyu\nInstall: iputils base-devel git\nRemove: archlabs-installer\n"
|
||||
|
||||
# bootloader
|
||||
_InstBootTitle="Install Bootloader"
|
||||
_InstBootloader="\nInstalling bootloader:"
|
||||
_InstBootDev="Device or partition used:"
|
||||
_MntBootBody="\nSelect bootloader and boot partition mountpoint.\n\nGrub is recommended, especially for multiboot."
|
||||
_InstSysTitle="Install Syslinux"
|
||||
_InstSysBody="\nInstall syslinux to the master boot record (MBR) or to root (/)?"
|
||||
@ -164,7 +147,7 @@ _DevSelTitle="Select Device"
|
||||
_DevSelBody="\nSelect which device to use.\n\nDevices (/dev/) are the available drives on the system. /sda, /sdb, and so on."
|
||||
|
||||
# Extra Partitions
|
||||
_ExtPartBody="\nSelect additional partitions to mount, you will be asked to enter a mountpoint after. Select 'Done' to finish mounting and continue install."
|
||||
_ExtPartBody="\nSelect additional partitions to mount, otherwise select '$_Done' to exit mounting.\n\nAfter choosing a partition you will be asked to enter the mountpoint."
|
||||
_ExtPartBody1="\nWhere do you want the partition mounted?\n\nEnsure the name begins with a forward slash (/).\nSome examples include:"
|
||||
|
||||
# Auto partition
|
||||
|
@ -12,13 +12,14 @@
|
||||
# immutable variables {
|
||||
|
||||
readonly DIST="ArchLabs" # Linux distributor
|
||||
readonly VER="1.6.64" # Installer version
|
||||
readonly VER="1.6.67" # Installer version
|
||||
readonly LIVE="liveuser" # Live session user
|
||||
readonly MNT="/mnt/install" # Install mountpoint
|
||||
readonly ERR="/tmp/errlog" # Built-in error log
|
||||
readonly EFI="/sys/firmware/efi/efivars"
|
||||
readonly LIB="/usr/share/archlabs/installer/lib"
|
||||
readonly TRN="/usr/share/archlabs/installer/lang"
|
||||
readonly RUN="/run/archiso/bootmnt/arch/boot"
|
||||
|
||||
readonly VM="$(dmesg | grep -i "hypervisor")"
|
||||
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
|
||||
@ -37,9 +38,9 @@ fi
|
||||
readonly DEV_COUNT="$(wc -l <<< "$SYS_DEVS")"
|
||||
|
||||
if [[ $(grep 'GenuineIntel' /proc/cpuinfo) ]]; then
|
||||
readonly UCODE="/intel-ucode.img"
|
||||
readonly UCODE="intel-ucode.img"
|
||||
elif [[ $(grep 'AuthenticAMD' /proc/cpuinfo) ]]; then
|
||||
readonly UCODE="/amd-ucode.img"
|
||||
readonly UCODE="amd-ucode.img"
|
||||
fi
|
||||
|
||||
# create associative array for SUBZONES[zone], value is: 'sub-zone country_code'
|
||||
@ -211,7 +212,7 @@ select_language() {
|
||||
"9" "Magyar (hu_HU)" "10" "Chinese (zh_CN)")
|
||||
|
||||
source_file $TRN/english.trans
|
||||
declare -g FONT="ter-i18n"
|
||||
declare -g FONT="ter-i16n"
|
||||
|
||||
case $lang in
|
||||
1) LOC="en_US.UTF-8" ;;
|
||||
@ -219,7 +220,7 @@ select_language() {
|
||||
3) source_file $TRN/p_brasil.trans && LOC="pt_BR.UTF-8" ;;
|
||||
4) source_file $TRN/portuguese.trans && LOC="pt_PT.UTF-8" ;;
|
||||
5) source_file $TRN/french.trans && LOC="fr_FR.UTF-8" ;;
|
||||
6) source_file $TRN/russian.trans && LOC="ru_RU.UTF-8" FONT="LatKaCyrHeb-14" ;;
|
||||
6) source_file $TRN/russian.trans && LOC="ru_RU.UTF-8" FONT="LatKaCyrHeb-16" ;;
|
||||
7) source_file $TRN/italian.trans && LOC="it_IT.UTF-8" ;;
|
||||
8) source_file $TRN/dutch.trans && LOC="nl_NL.UTF-8" ;;
|
||||
9) source_file $TRN/hungarian.trans && LOC="hu_HU.UTF-8" FONT="lat2-16" ;;
|
||||
@ -241,14 +242,14 @@ select_language() {
|
||||
setup_keymap() {
|
||||
tput civis
|
||||
declare -g KEYMAP
|
||||
KEYMAP="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
||||
KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PrepLayout " --menu "$_XMapBody" 20 70 12 $KEYMAPS)"
|
||||
[[ $? != 0 || $KEYMAP == "" ]] && return 1
|
||||
|
||||
# when a matching console map is not available open a selection dialog
|
||||
if ! [[ $CONSOLE_MAPS =~ "$KEYMAP -" ]]; then
|
||||
tput civis
|
||||
CONSOLE_MAP="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
||||
CONSOLE_MAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CONSOLE_MAPS)"
|
||||
[[ $? != 0 || $CONSOLE_MAP == "" ]] && return 1
|
||||
else
|
||||
@ -266,18 +267,21 @@ setup_keymap() {
|
||||
setup_timezone() {
|
||||
tput civis
|
||||
declare -g ZONE
|
||||
ZONE="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
||||
ZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_TimeZTitle " --menu "$_TimeZBody" 20 70 10 America - Australia - \
|
||||
Asia - Atlantic - Africa - Europe - Indian - Pacific - Arctic - Antarctica -)"
|
||||
[[ $? != 0 || $ZONE == "" ]] && return 1
|
||||
|
||||
declare -g SUBZONE
|
||||
SUBZONE="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
||||
SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 20 70 12 ${SUBZONES[$ZONE]})"
|
||||
[[ $? != 0 || $SUBZONE == "" ]] && return 1
|
||||
|
||||
yesno "$_TimeZTitle" "$_TimeZQ $ZONE/$SUBZONE?\n" && return 0 || setup_timezone
|
||||
}
|
||||
|
||||
window_manager() {
|
||||
INSTALL_WMS="$(dialog --cr-wrap --stdout --backtitle "$BT" --no-cancel \
|
||||
INSTALL_WMS="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_WMChoice " --checklist "$_WMChoiceBody\n" 0 0 0 \
|
||||
"openbox" "A lightweight, powerful, and highly configurable stacking window manager" off \
|
||||
"bspwm" "A tiling window manager that represents windows as the leaves of a binary tree" off \
|
||||
@ -286,6 +290,7 @@ window_manager() {
|
||||
"gnome" "A desktop environment that aims to be simple and easy to use" off \
|
||||
"cinnamon" "A desktop environment combining a traditional desktop layout with modern graphical effects" off \
|
||||
"xfce4" "A lightweight and modular desktop environment based on GTK+ 2 and 3" off)"
|
||||
[[ $? != 0 || $INSTALL_WMS == "" ]] && return 1
|
||||
WM_NUM=$(awk '{print NF}' <<< "$INSTALL_WMS")
|
||||
|
||||
# packages needed for the selected window manager
|
||||
@ -344,8 +349,8 @@ window_manager() {
|
||||
|
||||
extra_packages() {
|
||||
local pkgs
|
||||
pkgs="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
||||
--title " $_WMChoice " --checklist "$_WMChoiceBody\n" 0 0 25 \
|
||||
pkgs="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_WMChoice " --checklist "$_WMChoiceBody\n" 0 0 30 \
|
||||
"firefox" "A popular open-source graphical web browser from Mozilla" off \
|
||||
"chromium" "an open-source graphical web browser based on the Blink rendering engine" off \
|
||||
"opera" "Fast and secure, free of charge web browser from Opera Software" off \
|
||||
@ -394,7 +399,7 @@ extra_packages() {
|
||||
"evince" "A document viewer" off \
|
||||
"zathura" "Minimalistic document viewer" off \
|
||||
"qpdfview" "A tabbed PDF viewer" off \
|
||||
"mupdf mupdf-tools" "Lightweight PDF and XPS viewer" off \
|
||||
"mupdf" "Lightweight PDF and XPS viewer" off \
|
||||
"gpicview" "Lightweight image viewer" off \
|
||||
"gimp" "GNU Image Manipulation Program" off \
|
||||
"inkscape" "Professional vector graphics editor" off \
|
||||
@ -419,12 +424,17 @@ extra_packages() {
|
||||
"noto-fonts-cjk" "Google Noto CJK fonts (Chinese, Japanese, Korean)" off)"
|
||||
[[ $pkgs =~ vlc ]] && pkgs="$pkgs qt4"
|
||||
[[ $pkgs =~ mpd ]] && pkgs="$pkgs mpc"
|
||||
[[ $pkgs =~ mpd ]] && pkgs="$pkgs zathura-pdf-poppler"
|
||||
[[ $pkgs =~ mupdf ]] && pkgs="$pkgs mupdf-tools"
|
||||
[[ $pkgs =~ qt5ct ]] && pkgs="$pkgs qt5-styleplugins"
|
||||
[[ $pkgs =~ cairo-dock ]] && pkgs="$pkgs cairo-dock-plug-ins"
|
||||
[[ $pkgs =~ zathura ]] && pkgs="$pkgs zathura-pdf-poppler"
|
||||
[[ $pkgs =~ noto-fonts ]] && pkgs="$pkgs noto-fonts-emoji"
|
||||
[[ $pkgs =~ cairo-dock ]] && pkgs="$pkgs cairo-dock-plug-ins"
|
||||
[[ $pkgs =~ kdenlive ]] && pkgs="$pkgs kdebase-runtime dvdauthor frei0r-plugins breeze breeze-gtk"
|
||||
EXTRA_PACKAGES="$pkgs $EXTRA_PACKAGES"
|
||||
if [[ $pkgs =~ (qutebrowser|qbittorrent|kdenlive|vlc) ]] && ! [[ $pkgs =~ qt5ct ]]; then
|
||||
pkgs="$pkgs qt5ct qt5-styleplugins"
|
||||
fi
|
||||
|
||||
EXTRA_PACKAGES="$EXTRA_PACKAGES$([[ $pkgs ]] && echo -n " $pkgs")"
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -506,7 +516,7 @@ configure_install() {
|
||||
|
||||
tput civis
|
||||
declare -g LOCALE
|
||||
LOCALE="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
||||
LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_ConfLocale " --menu "$_LocaleBody" 25 70 20 $LOCALES)"
|
||||
[[ $? != 0 || $LOCALE == "" ]] && return 1
|
||||
|
||||
@ -521,7 +531,7 @@ configure_install() {
|
||||
KERNEL='linux-lts'
|
||||
fi
|
||||
|
||||
extra_packages
|
||||
extra_packages || return 1
|
||||
CONFIG_DONE=true
|
||||
return 0
|
||||
}
|
||||
@ -544,7 +554,6 @@ edit_configs() {
|
||||
wrap_up "$_InstFinBody" 'Exit & Reboot' 'Go Back' 'reboot'
|
||||
else
|
||||
local existing_files=""
|
||||
|
||||
for f in $(echo "${FILES[$MENU_HIGHLIGHT]}"); do
|
||||
[[ -e ${MNT}$f ]] && existing_files="$existing_files ${MNT}$f"
|
||||
done
|
||||
@ -581,9 +590,7 @@ main() {
|
||||
# if trying to install the system, make sure the partitions are mounted
|
||||
# and that the needed config variables and user variables have been set up
|
||||
if [[ $MENU_HIGHLIGHT && $MENU_HIGHLIGHT -eq 8 ]]; then
|
||||
check_install_ready
|
||||
local retval=$?
|
||||
[[ $retval -gt 0 ]] && { MENU_HIGHLIGHT=$retval; return 1; }
|
||||
check_install_ready || return 1
|
||||
fi
|
||||
|
||||
case $MENU_HIGHLIGHT in
|
||||
@ -599,7 +606,7 @@ main() {
|
||||
esac
|
||||
}
|
||||
|
||||
for file in utils mount partition bootloader lvm luks install; do
|
||||
for file in utils mount boot lvm luks install; do
|
||||
source_file $LIB/$file.sh
|
||||
done
|
||||
|
||||
|
@ -35,7 +35,6 @@ select_boot_setup() {
|
||||
|
||||
shim_secure_boot() {
|
||||
# still a W.I.P
|
||||
|
||||
local shim_file="shim64.efi"
|
||||
[[ $IS_64BIT != true ]] && shim_file="shim.efi"
|
||||
efibootmgr -c -w -L $DIST -d $BOOT_DEVICE -p $BOOT_PART_NUM -l ${MNT}${BMNTS[$SYS-$BOOTLDR]}/$shim_file
|
||||
@ -47,21 +46,20 @@ uefi_boot_fallback() {
|
||||
# /boot/efi/EFI/ and named 'boot', 'Boot', or 'BOOT'
|
||||
# copy the bootloaders efi stub to that directory as bootx64.efi
|
||||
|
||||
local boot_dir="$DIST"
|
||||
[[ $BOOTLDR == 'syslinux' ]] && boot_dir="syslinux"
|
||||
|
||||
local default="boot"
|
||||
local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}"
|
||||
for i in $(find "$esp/EFI/" -maxdepth 1 -mindepth 1 -type d 2>/dev/null); do
|
||||
grep -qi "boot" <<< "$(basename $i)" && { default="$(basename $i)"; break; }
|
||||
done
|
||||
|
||||
if [[ -d $esp/EFI/$default ]]; then
|
||||
rm -f $esp/EFI/$default/*
|
||||
else
|
||||
mkdir -p $esp/EFI/$default
|
||||
fi
|
||||
[[ -d $esp/EFI/$default ]] && rm -f $esp/EFI/$default/* || mkdir -p $esp/EFI/$default
|
||||
|
||||
if [[ $1 == 'syslinux' ]]; then
|
||||
cp -rf $esp/EFI/$1/* $esp/EFI/$default/
|
||||
cp -f $esp/EFI/$1/syslinux.efi $esp/EFI/$default/bootx64.efi
|
||||
cp -rf $esp/EFI/$boot_dir/* $esp/EFI/$default/
|
||||
cp -f $esp/EFI/$boot_dir/syslinux.efi $esp/EFI/$default/bootx64.efi
|
||||
else
|
||||
local grub_file="grubx64.efi"
|
||||
local boot_file="bootx64.efi"
|
||||
@ -69,7 +67,7 @@ uefi_boot_fallback() {
|
||||
local grub_file="grubia32.efi"
|
||||
local boot_file="bootia32.efi"
|
||||
fi
|
||||
cp -f $esp/EFI/$1/$grub_file $esp/EFI/$default/$boot_file
|
||||
cp -f $esp/EFI/$boot_dir/$grub_file $esp/EFI/$default/$boot_file
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -105,6 +103,11 @@ prep_for_grub() {
|
||||
prep_for_systemd-boot() {
|
||||
local ucode="$1"
|
||||
|
||||
# no LVM then systemd-boot uses PARTUUID
|
||||
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
|
||||
ROOT_PART_ID="PART$ROOT_PART_ID"
|
||||
fi
|
||||
|
||||
# create the boot entry configs
|
||||
mkdir -p $MNT/boot/loader/entries
|
||||
cat > $MNT/boot/loader/loader.conf << EOF
|
||||
@ -112,9 +115,10 @@ default $DIST
|
||||
timeout 5
|
||||
editor no
|
||||
EOF
|
||||
cat > $MNT/boot/loader/entries/${DIST}.conf << EOF
|
||||
|
||||
cat > $MNT/boot/loader/entries/${DIST}.conf << EOF
|
||||
title $DIST Linux
|
||||
linux /vmlinuz-${KERNEL}$([[ $ucode ]] && echo -en "\ninitrd $ucode")
|
||||
linux /vmlinuz-${KERNEL}$([[ $ucode ]] && echo -en "\ninitrd /$ucode")
|
||||
initrd /initramfs-$KERNEL.img
|
||||
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV")rw
|
||||
EOF
|
||||
@ -165,14 +169,14 @@ MENU LABEL $DIST Linux
|
||||
LINUX ../vmlinuz-$KERNEL
|
||||
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
|
||||
INITRD ../initramfs-$KERNEL.img
|
||||
$([[ $ucode ]] && echo -en "\nINITRD ..$ucode")
|
||||
$([[ $ucode ]] && echo -en "\nINITRD ../$ucode")
|
||||
|
||||
LABEL ${DIST}fallback
|
||||
MENU LABEL $DIST Linux Fallback
|
||||
LINUX ../vmlinuz-$KERNEL
|
||||
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
|
||||
INITRD ../initramfs-$KERNEL-fallback.img
|
||||
$([[ $ucode ]] && echo -en "\nINITRD ..$ucode")
|
||||
$([[ $ucode ]] && echo -en "\nINITRD ../$ucode")
|
||||
EOF
|
||||
return 0
|
||||
}
|
||||
@ -180,50 +184,34 @@ EOF
|
||||
install_bootloader() {
|
||||
chroot_cmd "export PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/core_perl"
|
||||
|
||||
# if not on an LVM we can use the UUID for booting
|
||||
# not an LVM we can use the UUID for booting otherwise use the partition label
|
||||
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
|
||||
ROOT_PART_ID="UUID=$(blkid -s PARTUUID $ROOT_PART | sed 's/.*=//g; s/"//g')"
|
||||
[[ $BOOTLDR == 'systemd-boot' ]] && ROOT_PART_ID="PART$ROOT_PART_ID"
|
||||
else
|
||||
# for LVM use the partition name eg. /dev/mapper/cryptroot
|
||||
ROOT_PART_ID="$ROOT_PART"
|
||||
fi
|
||||
|
||||
# needed for os-prober module to work properly in the chroot
|
||||
mkdir -p $MNT/{dev,sys,proc,run/udev}
|
||||
mount remount,rw -t proc proc $MNT/proc
|
||||
mount remount,rw -t sysfs sys $MNT/sys
|
||||
mount --bind /dev $MNT/dev
|
||||
mount remount,rw -t tmpfs tmpfs $MNT/run
|
||||
mount --bind /run/udev $MNT/run/udev
|
||||
# BCMDS[$BOOTLDR]="mkdir -p /run/udev && mount --bind /run/udev /run/udev ; ${BCMDS[$BOOTLDR]}"
|
||||
mkdir -p $MNT/run && mount --rbind /run $MNT/run/
|
||||
|
||||
# make sure efivarfs has been mounted and remove old boot entries
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
# make sure efivarfs has been mounted
|
||||
mount -o remount,rw -t efivarfs efivarfs $EFI >/dev/null 2>&1
|
||||
BCMDS[$BOOTLDR]="mount -o remount,rw -t efivarfs efivarfs $EFI; ${BCMDS[$BOOTLDR]}"
|
||||
|
||||
# remove old boot entries
|
||||
local esp="$MNT/boot/efi/EFI/"
|
||||
[[ ! -d $MNT/boot/efi/EFI && -d $MNT/boot/EFI ]] && esp="$MNT/boot/EFI/"
|
||||
find $esp -maxdepth 1 -mindepth 1 \
|
||||
\( -name '[aA][rR][cC][hH][lL]abs' -o -name '[Bb][oO][oO][tT]' \) \
|
||||
-type d -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||
find $esp -maxdepth 1 -mindepth 1 \( -name '[aA][rR][cC][hH][lL]abs' -o -name '[Bb][oO][oO][tT]' \) -type d -exec rm -rf '{}' \; >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# sets up the bootloader config(s) and ${BCMDS[$BOOTLDR]}
|
||||
prep_for_$BOOTLDR "$UCODE"
|
||||
|
||||
# run the bootloader command
|
||||
chroot_cmd "${BCMDS[$BOOTLDR]}"
|
||||
chroot_cmd "${BCMDS[$BOOTLDR]}" 2>$ERR
|
||||
check_for_errors "${BCMDS[$BOOTLDR]}"
|
||||
|
||||
if [[ $SYS == 'UEFI' && $BOOTLDR =~ (grub|syslinux) ]]; then
|
||||
local boot_dir="$DIST"
|
||||
[[ $BOOTLDR == 'syslinux' ]] && boot_dir="syslinux"
|
||||
|
||||
# copy efi stub to generic catch all
|
||||
uefi_boot_fallback "$boot_dir"
|
||||
fi
|
||||
# copy efi stub to generic catch all
|
||||
[[ $SYS == 'UEFI' && $BOOTLDR =~ (grub|syslinux) ]] && uefi_boot_fallback
|
||||
return 0
|
||||
}
|
@ -42,10 +42,10 @@ install_base() {
|
||||
rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/
|
||||
|
||||
# remove archiso init files and clean up install files
|
||||
find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm '{}' \;
|
||||
rm -f $MNT/etc/mkinitcpio-archiso.conf
|
||||
rm -rf $MNT/etc/sudoers.d/g_wheel
|
||||
rm -f $MNT/etc/mkinitcpio-archiso.conf
|
||||
rm -f $MNT/etc/polkit-1/rules.d/49-nopasswd_global.rules
|
||||
find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm '{}' \;
|
||||
|
||||
# cleanup system permissions
|
||||
sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf
|
||||
@ -65,17 +65,11 @@ EndSection
|
||||
EOF
|
||||
fi
|
||||
|
||||
# if not installing the lts kernel, copy the kernel image
|
||||
if [[ $KERNEL != 'linux-lts' ]]; then
|
||||
cp -f /run/archiso/bootmnt/arch/boot/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
|
||||
fi
|
||||
# copy the kernel image fofr the regular kernel
|
||||
[[ $KERNEL != 'linux-lts' ]] && cp -f $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
|
||||
|
||||
# CPU micro-code
|
||||
if [[ $UCODE == "/intel-ucode.img" ]]; then
|
||||
cp -f /run/archiso/bootmnt/arch/boot/intel_ucode.img $MNT/boot/intel_ucode.img
|
||||
else
|
||||
cp -f /run/archiso/bootmnt/arch/boot/amd_ucode.img $MNT/boot/amd_ucode.img
|
||||
fi
|
||||
# copy CPU micro-code if set. manufacturer_ucode.img -> manufacturer-ucode.img
|
||||
[[ $UCODE ]] && cp -f $RUN/${UCODE/-/_} $MNT/boot/$UCODE
|
||||
|
||||
setup_configs
|
||||
return 0
|
||||
@ -182,10 +176,10 @@ run_mkinitcpio() {
|
||||
luks_keyfile
|
||||
fi
|
||||
|
||||
# new HOOKS needed in /etc/mkinitcpio.conf if we used LUKS and/or LVM
|
||||
# new hooks needed in /etc/mkinitcpio.conf if we used LUKS and/or LVM
|
||||
local add
|
||||
(( LVM == 1 )) && add="lvm2"
|
||||
(( LUKS == 1 )) && add="encrypt$([[ $add != "" ]] && echo -n " $add")"
|
||||
(( LUKS == 1 )) && add="encrypt$([[ $add ]] && echo -n " $add")"
|
||||
|
||||
local conf="$MNT/etc/mkinitcpio.conf"
|
||||
sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $conf
|
||||
@ -231,7 +225,7 @@ update_system() {
|
||||
local install="pacman -S $inpkg $EXTRA_PACKAGES --needed --noconfirm"
|
||||
local remove="pacman -Rs $rmpkg --noconfirm"
|
||||
|
||||
chroot_cmd "$update; $network; $install; $remove"
|
||||
chroot_cmd "$update; $network; $install; $remove" 2>/dev/null
|
||||
|
||||
if [[ $EXTRA_PACKAGES =~ neovim ]]; then
|
||||
mkdir -p $MNT/home$LIVE/.config/nvim
|
||||
|
305
src/lib/mount.sh
305
src/lib/mount.sh
@ -6,6 +6,311 @@
|
||||
# this file is not meant to be run directly
|
||||
# sourcing this file in a non bash shell is not advised
|
||||
|
||||
########################################################
|
||||
## Partition functions ##
|
||||
########################################################
|
||||
|
||||
format() {
|
||||
infobox "$_FSTitle" "\nFormatting: $1\n\nCommand: ${FS_CMDS[$2]}\n" 0
|
||||
${FS_CMDS[$2]} $1 >/dev/null 2>$ERR
|
||||
check_for_errors "${FS_CMDS[$2]} $1"
|
||||
}
|
||||
|
||||
decr_count() {
|
||||
# remove a partition from the dialog list and decrement the number partitions left
|
||||
local p="$1"
|
||||
PARTS="$(sed "s~${p} [0-9]*[G-M]~~; s~${p} [0-9]*\.[0-9]*[G-M]~~" <<< "$PARTS")"
|
||||
(( COUNT > 0 )) && (( COUNT-- ))
|
||||
return 0
|
||||
}
|
||||
|
||||
enable_swap() {
|
||||
if [[ $1 == "$MNT/swapfile" ]]; then
|
||||
fallocate -l $SWAP_SIZE $1 2>$ERR
|
||||
check_for_errors "fallocate -l $SWAP_SIZE $1"
|
||||
chmod 600 $1 2>$ERR
|
||||
check_for_errors "chmod 600 $1"
|
||||
fi
|
||||
mkswap $1 >/dev/null 2>$ERR
|
||||
check_for_errors "mkswap $1"
|
||||
swapon $1 >/dev/null 2>$ERR
|
||||
check_for_errors "swapon $1"
|
||||
return 0
|
||||
}
|
||||
|
||||
mount_partition() {
|
||||
local part="$1"
|
||||
local mount="${MNT}$2"
|
||||
local fs="$(lsblk -lno FSTYPE $part)"
|
||||
|
||||
mkdir -p "$mount"
|
||||
|
||||
if [[ ${FS_OPTS[$fs]} != "" && $part != "$BOOT_PART" ]] && select_mount_opts "$part" "$fs"; then
|
||||
mount -o $MNT_OPTS $part "$mount" 2>$ERR
|
||||
check_for_errors "mount -o $MNT_OPTS $part $mount"
|
||||
else
|
||||
mount $part "$mount" 2>$ERR
|
||||
check_for_errors "mount $part $mount"
|
||||
fi
|
||||
|
||||
confirm_mount $part "$mount" || return 1
|
||||
check_cryptlvm "$part"
|
||||
return 0
|
||||
}
|
||||
|
||||
confirm_mount() {
|
||||
local part="$1"
|
||||
local mount="$2"
|
||||
|
||||
if [[ $mount == "$MNT" ]]; then
|
||||
local msg="Partition: $part\nMountpoint: / (root)"
|
||||
else
|
||||
local msg="Partition: $part\nMountpoint: ${mount#$MNT}"
|
||||
fi
|
||||
|
||||
# partition failed to mount properly
|
||||
if ! [[ $(mount) =~ "$mount" ]]; then
|
||||
infobox "$_MntTitle" "$_MntFail\n$msg\n" 1
|
||||
return 1
|
||||
else
|
||||
# mount was successful
|
||||
infobox "$_MntTitle" "$_MntSucc\n$msg\n" 1
|
||||
decr_count "$part"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
find_partitions() {
|
||||
local str="$1"
|
||||
local err='NONE'
|
||||
|
||||
# string of partitions as /TYPE/PART SIZE
|
||||
if [[ $IGNORE_DEV != "" ]]; then
|
||||
PARTS="$(lsblk -lno TYPE,NAME,SIZE |
|
||||
awk "/$str/"' && !'"/$IGNORE_DEV/"' {sub(/^part/, "/dev/");
|
||||
sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')"
|
||||
else
|
||||
PARTS="$(lsblk -lno TYPE,NAME,SIZE |
|
||||
awk "/$str/"' {sub(/^part/, "/dev/") sub(/^lvm|^crypt/, "/dev/mapper/")
|
||||
print $1$2 " " $3}')"
|
||||
fi
|
||||
|
||||
# number of partitions total
|
||||
COUNT=$(wc -l <<< "$PARTS")
|
||||
|
||||
# ensure we have enough partitions for the system and action type
|
||||
case $str in
|
||||
'part|lvm|crypt') [[ $COUNT -eq 0 || ($SYS == 'UEFI' && $COUNT -lt 2) ]] && err="$_PartErrBody" ;;
|
||||
'part|crypt') (( COUNT == 0 )) && err="$_LvmPartErrBody" ;;
|
||||
'part|lvm') (( COUNT < 2 )) && err="$_LuksPartErrBody" ;;
|
||||
esac
|
||||
|
||||
# if there aren't enough partitions show the error message
|
||||
if [[ $err != 'NONE' ]]; then
|
||||
msgbox "$_ErrTitle" "$err"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_cryptlvm() {
|
||||
local part="$1"
|
||||
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
|
||||
LUKS=1
|
||||
LUKS_NAME="${part#/dev/mapper/}"
|
||||
|
||||
for dev in $(awk '/lvm/ && /crypto_LUKS/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do
|
||||
if grep -q "$LUKS_NAME" <<< "$(lsblk -lno NAME "$dev")"; then
|
||||
LUKS_DEV="$LUKS_DEV cryptdevice=$dev:$LUKS_NAME"
|
||||
LVM=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
for dev in $(awk '/part/ && /crypto_LUKS/ {print "/dev/"$1}' <<< "$devs" | uniq); do
|
||||
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_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
elif [[ $(lsblk -lno TYPE "$part") =~ 'lvm' ]]; then
|
||||
LVM=1
|
||||
VOLUME_NAME="${part#/dev/mapper/}"
|
||||
|
||||
for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do
|
||||
if grep -q "$VOLUME_NAME" <<< "$(lsblk -lno NAME "$dev")"; then
|
||||
LUKS_NAME="$(sed 's~/dev/mapper/~~g' <<< "$dev")"
|
||||
break
|
||||
fi
|
||||
done
|
||||
for dev in $(awk '/part/ && /crypto_LUKS/ {print "/dev/"$1}' <<< "$devs" | uniq); do
|
||||
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_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME"
|
||||
LUKS=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
auto_partition() {
|
||||
local device="$1"
|
||||
|
||||
# confirm or bail
|
||||
yesno "$_PrepParts" "$_PartBody1 $device $_PartBody2" || return 0
|
||||
infobox "$_PrepParts" "\nAuto partitioning device: $device\n" 0
|
||||
|
||||
swapoff -a # make sure swap is disabled in case the device was used for swap
|
||||
|
||||
local dev_info="$(parted -s $device print)"
|
||||
|
||||
# walk the partitions on the device in reverse order and delete them
|
||||
for i in $(awk '/^ [1-9][0-9]?/ {print $1}' <<< "$dev_info" | sort -r); do
|
||||
parted -s $device rm $i >/dev/null 2>&1
|
||||
done
|
||||
|
||||
# make sure we have the correct device table for the system type, gpt or msdos
|
||||
local newtable="gpt"
|
||||
local table="$(awk '/Table:/ {print $3}' <<< "$dev_info")"
|
||||
[[ $SYS == BIOS ]] && newtable="msdos"
|
||||
|
||||
# if the current device table isn't correct run mklabel
|
||||
if [[ $table != "$newtable" ]]; then
|
||||
parted -s $device mklabel $newtable >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# when device contains the string 'nvme' then add 'p' before the part number
|
||||
local nvme=""
|
||||
[[ $device =~ nvme ]] && nvme="p"
|
||||
|
||||
local part_num=1
|
||||
BOOT_PART="$device${nvme}$part_num" # set the boot partition label to the first partition
|
||||
|
||||
if [[ $SYS == "BIOS" ]]; then
|
||||
parted -s $device mkpart primary ext4 1MiB 513MiB >/dev/null 2>&1
|
||||
mkfs.ext4 -q $BOOT_PART >/dev/null 2>&1
|
||||
else
|
||||
parted -s $device mkpart ESP fat32 1MiB 513MiB >/dev/null 2>&1
|
||||
mkfs.vfat -F32 $BOOT_PART >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
(( part_num++ )) # increment the partition number
|
||||
BOOT_DEVICE="$device" # only grub on BIOS systems uses this
|
||||
ROOT_PART="${device}${nvme}$part_num" # set root partition label to the second partition
|
||||
|
||||
parted -s $device mkpart primary ext4 513MiB 100% >/dev/null 2>&1
|
||||
mkfs.ext4 -q $ROOT_PART >/dev/null 2>&1
|
||||
|
||||
tput civis
|
||||
sleep 0.5 # slow the process down, otherwise lsblk output can be wrong for some things
|
||||
|
||||
echo -e "\nAuto partitioning complete.\n" > /tmp/.devlist
|
||||
lsblk $device -o NAME,MODEL,TYPE,FSTYPE,SIZE >> /tmp/.devlist
|
||||
dialog --cr-wrap --backtitle "$BT" --title " $_PrepParts " --textbox /tmp/.devlist 0 0
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_boot_device() {
|
||||
# set BOOT_DEVICE for syslinux on UEFI and grub on BIOS
|
||||
if [[ $BOOT_PART =~ nvme ]]; then
|
||||
BOOT_DEVICE="${BOOT_PART%p[1-9]}"
|
||||
else
|
||||
BOOT_DEVICE="${BOOT_PART%[1-9]}"
|
||||
fi
|
||||
|
||||
BOOT_PART_NUM="${BOOT_PART: -1}"
|
||||
|
||||
# setup the needed partition flags for boot on both system types
|
||||
parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on >/dev/null 2>&1
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
parted -s $BOOT_DEVICE set $BOOT_PART_NUM esp on >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
show_devices() {
|
||||
tput civis
|
||||
if [[ $IGNORE_DEV != "" ]]; then
|
||||
lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT |
|
||||
awk "!/$IGNORE_DEV/"' && /disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist
|
||||
else
|
||||
lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT |
|
||||
awk '/disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist
|
||||
fi
|
||||
dialog --cr-wrap --backtitle "$BT" --title " $_PrepShowDev " --textbox /tmp/.devlist 0 0
|
||||
}
|
||||
|
||||
select_device() {
|
||||
local dev
|
||||
local msg
|
||||
if [[ $1 == 'boot' ]]; then
|
||||
msg="$_DevSelTitle for bootloader\n"
|
||||
else
|
||||
unmount_partitions
|
||||
fi
|
||||
|
||||
if (( DEV_COUNT == 1 )) && [[ $SYS_DEVS ]]; then
|
||||
DEVICE="$(awk '{print $1}' <<< "$SYS_DEVS")"
|
||||
msg="\nOnly one device available$([[ $1 == 'boot' ]] && echo -n " for grub bootloader"):"
|
||||
infobox "$_DevSelTitle" "$msg $DEVICE\n" 1
|
||||
elif (( DEV_COUNT > 1 )); then
|
||||
tput civis
|
||||
DEVICE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_DevSelTitle " \
|
||||
--menu "${msg}$_DevSelBody" 0 0 0 $SYS_DEVS)"
|
||||
[[ $? != 0 || $DEVICE == "" ]] && return 1
|
||||
else
|
||||
msg="\nNo available devices for installation to use$([[ $1 == 'boot' ]] && echo -n " for grub bootloader")."
|
||||
msgbox "$_ErrTitle" "$msg\n$_Exit"
|
||||
die 1
|
||||
fi
|
||||
|
||||
# if the device selected was for grub bootloader, set the BOOT_DEVICE
|
||||
# this is needed because grub uses the base device for BIOS, not the partition
|
||||
[[ $1 == 'boot' ]] && BOOT_DEVICE="$DEVICE"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
edit_partitions() {
|
||||
local device="$1"
|
||||
if [[ $device == "" ]]; then
|
||||
select_device 'root' || return 1
|
||||
device="$DEVICE"
|
||||
fi
|
||||
|
||||
tput civis
|
||||
local choice
|
||||
choice="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PartTitle " --menu "$_PartBody" 0 0 0 "$_PartAuto" "-" \
|
||||
$( ([[ $DISPLAY ]] && hash gparted >/dev/null 2>&1) && echo -n "gparted -") "cfdisk" "-"\
|
||||
"parted" "-" "$_PartWipe" "-")"
|
||||
[[ $? != 0 || $choice == "" ]] && return 1
|
||||
|
||||
clear
|
||||
tput cnorm
|
||||
|
||||
if [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" ]]; then
|
||||
$choice $device
|
||||
elif [[ $choice == "$_PartWipe" ]]; then
|
||||
yesno "$_PartWipe" "$_PartBody1 $device $_PartWipeBody2" && { clear; wipe -Ifrev $device; }
|
||||
edit_partitions $device
|
||||
else
|
||||
# if auto_partition fails we need to re-initialize the variables, just to be sure
|
||||
auto_partition $device || { initialize_variables; return 1; }
|
||||
fi
|
||||
}
|
||||
|
||||
########################################################
|
||||
## Mount functions ##
|
||||
########################################################
|
||||
|
||||
mount_main() {
|
||||
msgbox "$_PrepMount" "$_WarnMount"
|
||||
lvm_detect
|
||||
|
@ -1,293 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# vim:ft=sh:fdm=marker:fmr={,}
|
||||
|
||||
# archlabs installer library script file
|
||||
# this file is not meant to be run directly
|
||||
# sourcing this file in a non bash shell is not advised
|
||||
|
||||
format() {
|
||||
infobox "$_FSTitle" "\nFormatting: $1\n\nCommand: ${FS_CMDS[$2]}\n" 0
|
||||
${FS_CMDS[$2]} $1 >/dev/null 2>$ERR
|
||||
check_for_errors "${FS_CMDS[$2]} $1"
|
||||
}
|
||||
|
||||
decr_count() {
|
||||
# remove a partition from the dialog list and decrement the number partitions left
|
||||
local p="$1"
|
||||
PARTS="$(sed "s~${p} [0-9]*[G-M]~~; s~${p} [0-9]*\.[0-9]*[G-M]~~" <<< "$PARTS")"
|
||||
(( COUNT > 0 )) && (( COUNT-- ))
|
||||
return 0
|
||||
}
|
||||
|
||||
enable_swap() {
|
||||
[[ $1 == "$MNT/swapfile" ]] && { fallocate -l $SWAP_SIZE $1; chmod 600 $1; }
|
||||
mkswap $1 >/dev/null 2>&1
|
||||
swapon $1 >/dev/null 2>&1
|
||||
return 0
|
||||
}
|
||||
|
||||
mount_partition() {
|
||||
local part="$1"
|
||||
local mount="${MNT}$2"
|
||||
local fs="$(lsblk -lno FSTYPE $part)"
|
||||
|
||||
mkdir -p "$mount"
|
||||
|
||||
if [[ ${FS_OPTS[$fs]} != "" && $part != "$BOOT_PART" ]] && select_mount_opts "$part" "$fs"; then
|
||||
mount -o $MNT_OPTS $part "$mount" 2>$ERR
|
||||
check_for_errors "mount -o $MNT_OPTS $part $mount"
|
||||
else
|
||||
mount $part "$mount" 2>$ERR
|
||||
check_for_errors "mount $part $mount"
|
||||
fi
|
||||
|
||||
confirm_mount $part "$mount" || return 1
|
||||
check_cryptlvm "$part"
|
||||
return 0
|
||||
}
|
||||
|
||||
confirm_mount() {
|
||||
local part="$1"
|
||||
local mount="$2"
|
||||
|
||||
if [[ "$mount" == "$MNT" ]]; then
|
||||
local msg="Partition: $part\nMountpoint: / (root)"
|
||||
else
|
||||
local msg="Partition: $part\nMountpoint: ${mount#$MNT}"
|
||||
fi
|
||||
|
||||
# partition failed to mount properly
|
||||
if ! grep -q "$mount" <<< "$(mount)"; then
|
||||
infobox "$_MntTitle" "$_MntFail\n$msg\n" 1
|
||||
return 1
|
||||
else
|
||||
# mount was successful
|
||||
infobox "$_MntTitle" "$_MntSucc\n$msg\n" 1
|
||||
decr_count "$part"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
find_partitions() {
|
||||
local str="$1"
|
||||
local err='NONE'
|
||||
|
||||
# string of partitions as /TYPE/PART SIZE
|
||||
if [[ $IGNORE_DEV != "" ]]; then
|
||||
PARTS="$(lsblk -lno TYPE,NAME,SIZE | awk "/$str/"' && !'"/$IGNORE_DEV/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')"
|
||||
else
|
||||
PARTS="$(lsblk -lno TYPE,NAME,SIZE | awk "/$str/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')"
|
||||
fi
|
||||
|
||||
# number of partitions total
|
||||
COUNT=$(wc -l <<< "$PARTS")
|
||||
|
||||
# ensure we have enough partitions for the system and action type
|
||||
case $str in
|
||||
'part|lvm|crypt') [[ $COUNT -eq 0 || ($SYS == 'UEFI' && $COUNT -lt 2) ]] && err="$_PartErrBody" ;;
|
||||
'part|crypt') (( COUNT == 0 )) && err="$_LvmPartErrBody" ;;
|
||||
'part|lvm') (( COUNT < 2 )) && err="$_LuksPartErrBody" ;;
|
||||
esac
|
||||
|
||||
# if there aren't enough partitions show the error message
|
||||
if [[ $err != 'NONE' ]]; then
|
||||
msgbox "$_ErrTitle" "$err"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_cryptlvm() {
|
||||
local part="$1"
|
||||
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
|
||||
LUKS=1
|
||||
LUKS_NAME="${part#/dev/mapper/}"
|
||||
|
||||
for dev in $(awk '/lvm/ && /crypto_LUKS/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do
|
||||
if grep -q "$LUKS_NAME" <<< "$(lsblk -lno NAME "$dev")"; then
|
||||
LUKS_DEV="$LUKS_DEV cryptdevice=$dev:$LUKS_NAME"
|
||||
LVM=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
for dev in $(awk '/part/ && /crypto_LUKS/ {print "/dev/"$1}' <<< "$devs" | uniq); do
|
||||
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_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
elif [[ $(lsblk -lno TYPE "$part") =~ 'lvm' ]]; then
|
||||
LVM=1
|
||||
VOLUME_NAME="${part#/dev/mapper/}"
|
||||
|
||||
for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do
|
||||
if grep -q "$VOLUME_NAME" <<< "$(lsblk -lno NAME "$dev")"; then
|
||||
LUKS_NAME="$(sed 's~/dev/mapper/~~g' <<< "$dev")"
|
||||
break
|
||||
fi
|
||||
done
|
||||
for dev in $(awk '/part/ && /crypto_LUKS/ {print "/dev/"$1}' <<< "$devs" | uniq); do
|
||||
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_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME"
|
||||
LUKS=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
auto_partition() {
|
||||
local device="$1"
|
||||
|
||||
# confirm or bail
|
||||
yesno "$_PrepParts" "$_PartBody1 $device $_PartBody2" || return 0
|
||||
infobox "$_PrepParts" "\nAuto partitioning device: $device\n" 0
|
||||
|
||||
swapoff -a # make sure swap is disabled in case the device was used for swap
|
||||
|
||||
local dev_info="$(parted -s $device print)"
|
||||
|
||||
# walk the partitions on the device in reverse order and delete them
|
||||
for i in $(awk '/^ [1-9][0-9]?/ {print $1}' <<< "$dev_info" | sort -r); do
|
||||
parted -s $device rm $i >/dev/null 2>&1
|
||||
done
|
||||
|
||||
# make sure we have the correct device table for the system type, gpt or msdos
|
||||
local newtable="gpt"
|
||||
local table="$(awk '/Table:/ {print $3}' <<< "$dev_info")"
|
||||
[[ $SYS == BIOS ]] && newtable="msdos"
|
||||
|
||||
# if the current device table isn't correct run mklabel
|
||||
if [[ $table != "$newtable" ]]; then
|
||||
parted -s $device mklabel $newtable >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
# when device contains the string 'nvme' then add 'p' before the part number
|
||||
local nvme=""
|
||||
[[ $device =~ nvme ]] && nvme="p"
|
||||
|
||||
local part_num=1
|
||||
BOOT_PART="$device${nvme}$part_num" # set the boot partition label to the first partition
|
||||
|
||||
if [[ $SYS == "BIOS" ]]; then
|
||||
parted -s $device mkpart primary ext4 1MiB 513MiB >/dev/null 2>&1
|
||||
mkfs.ext4 -q $BOOT_PART >/dev/null 2>&1
|
||||
else
|
||||
parted -s $device mkpart ESP fat32 1MiB 513MiB >/dev/null 2>&1
|
||||
mkfs.vfat -F32 $BOOT_PART >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
(( part_num++ )) # increment the partition number
|
||||
BOOT_DEVICE="$device" # only grub on BIOS systems uses this
|
||||
ROOT_PART="${device}${nvme}$part_num" # set root partition label to the second partition
|
||||
|
||||
parted -s $device mkpart primary ext4 514MiB 100% >/dev/null 2>&1
|
||||
mkfs.ext4 -q $ROOT_PART >/dev/null 2>&1
|
||||
|
||||
tput civis
|
||||
sleep 0.5 # slow the process down, otherwise lsblk output can be wrong for some things
|
||||
|
||||
echo -e "\nAuto partitioning complete.\n" > /tmp/.devlist
|
||||
lsblk $device -o NAME,MODEL,TYPE,FSTYPE,SIZE >> /tmp/.devlist
|
||||
dialog --cr-wrap --backtitle "$BT" --title " $_PrepParts " --textbox /tmp/.devlist 0 0
|
||||
return 0
|
||||
}
|
||||
|
||||
setup_boot_device() {
|
||||
# set BOOT_DEVICE for syslinux on UEFI and grub on BIOS
|
||||
if [[ $BOOT_PART =~ nvme ]]; then
|
||||
BOOT_DEVICE="${BOOT_PART%p[1-9]}"
|
||||
else
|
||||
BOOT_DEVICE="${BOOT_PART%[1-9]}"
|
||||
fi
|
||||
|
||||
BOOT_PART_NUM="${BOOT_PART: -1}"
|
||||
|
||||
# setup the needed partition flags for boot on both system types
|
||||
parted -s $BOOT_DEVICE set $BOOT_PART_NUM boot on >/dev/null 2>&1
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
parted -s $BOOT_DEVICE set $BOOT_PART_NUM esp on >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
show_devices() {
|
||||
tput civis
|
||||
if [[ $IGNORE_DEV != "" ]]; then
|
||||
lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT |
|
||||
awk "!/$IGNORE_DEV/"' && /disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist
|
||||
else
|
||||
lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT |
|
||||
awk '/disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist
|
||||
fi
|
||||
dialog --cr-wrap --backtitle "$BT" --title " $_PrepShowDev " --textbox /tmp/.devlist 0 0
|
||||
}
|
||||
|
||||
select_device() {
|
||||
local dev
|
||||
local msg
|
||||
if [[ $1 == 'boot' ]]; then
|
||||
msg="$_DevSelTitle for bootloader\n"
|
||||
else
|
||||
unmount_partitions
|
||||
fi
|
||||
|
||||
if (( DEV_COUNT == 1 )) && [[ $SYS_DEVS ]]; then
|
||||
DEVICE="$(awk '{print $1}' <<< "$SYS_DEVS")"
|
||||
msg="\nOnly one device available$([[ $1 == 'boot' ]] && echo -n " for grub bootloader"):"
|
||||
infobox "$_DevSelTitle" "$msg $DEVICE\n" 1
|
||||
elif (( DEV_COUNT > 1 )); then
|
||||
tput civis
|
||||
DEVICE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_DevSelTitle " \
|
||||
--menu "${msg}$_DevSelBody" 0 0 0 $SYS_DEVS)"
|
||||
[[ $? != 0 || $DEVICE == "" ]] && return 1
|
||||
else
|
||||
msg="\nNo available devices for installation to use$([[ $1 == 'boot' ]] && echo -n " for grub bootloader")."
|
||||
msgbox "$_ErrTitle" "$msg\n$_Exit"
|
||||
die 1
|
||||
fi
|
||||
|
||||
# if the device selected was for grub bootloader, set the BOOT_DEVICE
|
||||
# this is needed because grub uses the base device for BIOS, not the partition
|
||||
[[ $1 == 'boot' ]] && BOOT_DEVICE="$DEVICE"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
edit_partitions() {
|
||||
local device="$1"
|
||||
if [[ $device == "" ]]; then
|
||||
select_device 'root' || return 1
|
||||
device="$DEVICE"
|
||||
fi
|
||||
|
||||
tput civis
|
||||
local choice
|
||||
choice="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PartTitle " --menu "$_PartBody" 0 0 0 "$_PartAuto" "-" \
|
||||
$( ([[ $DISPLAY ]] && hash gparted >/dev/null 2>&1) && echo -n "gparted -") "cfdisk" "-"\
|
||||
"parted" "-" "$_PartWipe" "-")"
|
||||
[[ $? != 0 || $choice == "" ]] && return 1
|
||||
|
||||
clear
|
||||
tput cnorm
|
||||
|
||||
if [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" ]]; then
|
||||
$choice $device
|
||||
elif [[ $choice == "$_PartWipe" ]]; then
|
||||
yesno "$_PartWipe" "$_PartBody1 $device $_PartWipeBody2" && { clear; wipe -Ifrev $device; }
|
||||
edit_partitions $device
|
||||
else
|
||||
# if auto_partition fails we need to re-initialize the variables, just to be sure
|
||||
auto_partition $device || { initialize_variables; return 1; }
|
||||
fi
|
||||
}
|
@ -60,17 +60,16 @@ check_for_errors() {
|
||||
|
||||
local msg="\nThe command exited abnormally: $1"
|
||||
|
||||
# get error message from logfile and attempt to format slightly better for humans
|
||||
# strip any non-printable characters, escape sequences, and other known messy text
|
||||
# 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 == "" ]] && echo -n "$msg")\n$_ErrChoice"
|
||||
if [[ -e /tmp/debug-log && $TERM == 'linux' ]]; then
|
||||
msg="$([[ $err == "" ]] && echo -n "$msg")\n$_ErrChoiceConsole"
|
||||
yesno "$_ErrTitle" "$msg" "View Log" "Continue" && { less /tmp/debug-log; die 0; }
|
||||
yesno "$_ErrTitle" "$msg" "Exit & Open Log" "Ignore & Continue" && { less /tmp/debug-log; die 0; }
|
||||
else
|
||||
yesno "$_ErrTitle" "$msg" "Exit & Shutdown" "Ignore & Continue" && die 'shutdown'
|
||||
fi
|
||||
@ -80,9 +79,13 @@ check_for_errors() {
|
||||
|
||||
check_install_ready() {
|
||||
if ! [[ $(lsblk -o MOUNTPOINT) =~ $MNT ]]; then
|
||||
msgbox "$_ErrTitle" "$_ErrNoMount"; return 4
|
||||
msgbox "$_ErrTitle" "$_ErrNoMount"
|
||||
MENU_HIGHLIGHT=4
|
||||
return 1
|
||||
elif [[ $CONFIG_DONE != true ]]; then
|
||||
msgbox "$_ErrTitle" "$_ErrNoConfig"; return 5
|
||||
msgbox "$_ErrTitle" "$_ErrNoConfig"
|
||||
MENU_HIGHLIGHT=5
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -139,7 +142,7 @@ die() {
|
||||
tput cnorm
|
||||
unmount_partitions
|
||||
pgrep -f "$TERM_CMD -e tail" && pkill -f "$TERM_CMD -e tail"
|
||||
[[ $1 =~ [0-9] ]] && exit $1 || systemctl $1
|
||||
[[ $1 =~ [0-9] ]] && exit $1 || $1
|
||||
}
|
||||
|
||||
sigint() {
|
||||
|
Reference in New Issue
Block a user