Improve background install process
This commit is contained in:
parent
ba67414f18
commit
1619daa362
@ -5,7 +5,7 @@
|
||||
# Some ideas and code reworked from other resources
|
||||
# AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
|
||||
|
||||
VER="2.0.17" # version
|
||||
VER="2.0.21" # version
|
||||
DIST="ArchLabs" # distributor
|
||||
MNT="/mnt" # mountpoint
|
||||
ANS="/tmp/ans"
|
||||
@ -264,7 +264,7 @@ _bios="\nDo you want to use a separate boot partition? (optional)\n\nIt's usuall
|
||||
_biosluks="\nSelect the boot partition (/boot), required for LUKS.\n\nIt's usually the first partition on the device, 100-512M, and will be formatted as ext3/4 if not already."
|
||||
_format="is already formatted correctly.\n\nFor a clean install, previously existing partitions should be reformatted, however this removes ALL data (bootloaders) on the partition so choose carefully.\n\nDo you want to reformat the partition?\n"
|
||||
_swapsize="\nEnter the size of the swapfile in megabytes (M) or gigabytes (G).\n\neg. 100M will create a 100 megabyte swapfile, while 10G will create a 10 gigabyte swapfile.\n\nFor ease of use and as an example it is filled in to match the size of your system memory (RAM).\n\nMust be greater than 1, contain only whole numbers, and end with either M or G."
|
||||
_expart="\nYou can now select additional partitions you want mounted, once choosen you will be asked to enter a mountpoint.\n\nSelect 'done' to finish the mounting step and begin unpacking the base system in the background."
|
||||
_expart="\nYou can now choose any additional partitions you want mounted, you'll be asked for a mountpoint after.\n\nSelect 'done' to finish the mounting step and begin unpacking the base system in the background."
|
||||
_exmnt="\nWhere do you want the partition mounted?\n\nEnsure the name begins with a slash (/).\nExamples include: /usr, /home, /var, etc."
|
||||
_edit="\nBefore exiting you can select configuration files to review/change.\n\nIf you need to make other changes with the drives still mounted, use Ctrl-z to pause the installer, when finished type 'fg' and [Enter] or Ctrl-z again to resume the installer, if you want to avoid the automatic reboot using Ctrl-c will cleanly exit."
|
||||
|
||||
@ -370,15 +370,8 @@ select_show()
|
||||
local cmd="${BCMDS[$BOOTLDR]}"
|
||||
[[ $BOOT_PART ]] && local mnt="/$BOOTDIR" || local mnt="none"
|
||||
|
||||
local pkgs="${USER_PKGS# }"
|
||||
pkgs="${pkgs% }"
|
||||
pkgs="${pkgs% } ${PACKAGES# }"
|
||||
pkgs="${pkgs// / }"
|
||||
pkgs="${pkgs// / }"
|
||||
[[ $INSTALL_WMS == *dwm* ]] && pkgs="dwm st dmenu ${pkgs# }"
|
||||
pkgs="${pkgs# }"
|
||||
pkgs="${pkgs% }"
|
||||
pkgs="${pkgs// / }"
|
||||
local pkgs="$USER_PKGS $PACKAGES"
|
||||
[[ $INSTALL_WMS == *dwm* ]] && pkgs="dwm st dmenu $pkgs"
|
||||
msg "Show Configuration" "
|
||||
|
||||
---------- PARTITION CONFIGURATION ------------
|
||||
@ -424,7 +417,6 @@ select_show()
|
||||
|
||||
Kernel: ${KERNEL:-none}
|
||||
Sessions: ${INSTALL_WMS:-none}
|
||||
Mirrors: ${MIRROR_CMD:-none}
|
||||
Packages: $(print4 "${pkgs:-none}")
|
||||
"
|
||||
}
|
||||
@ -449,7 +441,7 @@ select_login()
|
||||
LOGIN_WM="${WM_SESSIONS[$LOGIN_WM]}"
|
||||
fi
|
||||
|
||||
local txt="\nDo you want autologin enabled for $NEWUSER?\n\nPicking yes will create the following files:\n\n - /home/$NEWUSER/$LOGINRC (run startx when logging in on tty1)\n - /etc/systemd/system/getty@tty1.service.d/autologin.conf (login $NEWUSER without password)\n\nTo disable autologin remove these files.\n"
|
||||
local txt="\nDo you want autologin enabled for $NEWUSER?\n\nIf so the following two files will be created (disable autologin by remove them):\n\n - /home/$NEWUSER/$LOGINRC (this runs startx when logging in on tty1)\n - /etc/systemd/system/getty@tty1.service.d/autologin.conf (this logs in $NEWUSER without a password)\n"
|
||||
|
||||
yesno "Autologin" "$txt" && AUTOLOGIN=true || AUTOLOGIN=''
|
||||
WM_PKGS+=" xorg-xinit"
|
||||
@ -488,8 +480,6 @@ select_config()
|
||||
linux-zen 'A effort of kernel hackers to provide the best kernel for everyday systems' \
|
||||
linux-hardened 'A security-focused linux kernel with hardening patches to mitigate exploits' || continue
|
||||
|
||||
;;
|
||||
5) select_mirrorcmd || continue
|
||||
CONFIG_DONE=true
|
||||
;;
|
||||
esac
|
||||
@ -576,15 +566,12 @@ select_keymap()
|
||||
ke Swahili bw Tswana ph Filipino my Malay tm Turkmen \
|
||||
id Indonesian bt Dzongkha lv Latvian md Moldavian mao Maori \
|
||||
by Belarusian az Azerbaijani mk Macedonian kh Khmer epo Esperanto \
|
||||
me Montenegrin
|
||||
|
||||
[[ $KEYMAP ]] || return 1
|
||||
me Montenegrin || return 1
|
||||
|
||||
if [[ $CMAPS == *"$KEYMAP"* ]]; then
|
||||
CMAP="$KEYMAP"
|
||||
else
|
||||
dlg CMAP menu "Console Keymap" "$_vconsole" $CMAPS
|
||||
[[ $CMAP ]] || return 1
|
||||
dlg CMAP menu "Console Keymap" "$_vconsole" $CMAPS || return 1
|
||||
fi
|
||||
|
||||
if [[ $DISPLAY && $TERM != 'linux' ]]; then
|
||||
@ -725,52 +712,8 @@ select_packages()
|
||||
|
||||
if [[ $USER_PKGS ]]; then
|
||||
for i in $USER_PKGS; do
|
||||
[[ ${PKG_EXT[$i]} && $USER_PKGS != *"${PKG_EXT[$i]}"* ]] && USER_PKGS="${USER_PKGS% } ${PKG_EXT[$i]}"
|
||||
[[ ${PKG_EXT[$i]} && $USER_PKGS != *"${PKG_EXT[$i]}"* ]] && USER_PKGS+=" ${PKG_EXT[$i]}"
|
||||
done
|
||||
USER_PKGS="${USER_PKGS// / }"
|
||||
USER_PKGS="${USER_PKGS# }"
|
||||
USER_PKGS="${USER_PKGS% }"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
select_mirrorcmd()
|
||||
{
|
||||
local c='' key="5f29642060ab983b31fdf4c2935d8c56"
|
||||
|
||||
if hash reflector >/dev/null 2>&1; then
|
||||
MIRROR_CMD="reflector --score 100 -l 50 -f 5 --sort rate --verbose"
|
||||
yesno "Mirrorlist" "\nSort the mirrorlist automatically?\n\nTakes longer but can find faster mirrors.\n" && return 0
|
||||
|
||||
c="$(json 'country_name' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_name")"
|
||||
MIRROR_CMD="reflector --country $c --fastest 5 --sort rate --verbose"
|
||||
|
||||
tput cnorm
|
||||
dialog --cr-wrap --backtitle "$DIST Installer - $SYS - v$VER" \
|
||||
--title " Mirrorlist " --inputbox "\nThe command below will be used to sort the mirrorlist, edit if needed.\n\n
|
||||
--score n Limit the list to the n servers with the highest score.
|
||||
--latest n Limit the list to the n most recently synchronized servers.
|
||||
--fastest n Return the n fastest mirrors that meet the other criteria.
|
||||
--sort {age,rate,country,score,delay}
|
||||
|
||||
'age': Last server synchronization;
|
||||
'rate': Download rate;
|
||||
'country': Server location;
|
||||
'score': MirrorStatus score;
|
||||
'delay': MirrorStatus delay.\n" 0 0 "$MIRROR_CMD" 2>"$ANS"
|
||||
|
||||
[ $? -eq 0 ] || return 1
|
||||
read -r MIRROR_CMD < "$ANS"
|
||||
elif hash rankmirrors >/dev/null 2>&1; then
|
||||
msg "Mirrorlist" "\nQuerying mirrors near your location\n"
|
||||
c="$(json 'country_code' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_code")"
|
||||
local w="https://www.archlinux.org/mirrorlist/?country="
|
||||
if [[ $c ]]; then
|
||||
[[ $c =~ (CA|US) ]] && MIRROR_CMD="curl -s '${w}US&country=CA&use_mirror_status=on'" || MIRROR_CMD="curl -s '${w}${c}&use_mirror_status=on'"
|
||||
else
|
||||
MIRROR_CMD="curl -s '${w}US&country=CA&country=NZ&country=GB&country=AU&use_mirror_status=on'"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
@ -812,7 +755,7 @@ part_menu()
|
||||
|
||||
fi
|
||||
|
||||
if [[-z $choice || $choice == 'done' ]]; then
|
||||
if [[ -z $choice || $choice == 'done' ]]; then
|
||||
return 0
|
||||
elif [[ $choice == 'auto' ]]; then
|
||||
local root_size txt ret table boot_fs
|
||||
@ -1011,7 +954,7 @@ part_device()
|
||||
|
||||
part_bootdev()
|
||||
{
|
||||
msg "Boot Device" "\nSetting device flags for: $BOOT_PART\n" 1
|
||||
msg "Boot Device" "\nSetting flags for boot partition $BOOT_PART\n" 1
|
||||
[[ $BOOT_PART = /dev/nvme* ]] && BOOT_DEV="${BOOT_PART%p[1-9]}" || BOOT_DEV="${BOOT_PART%[1-9]}"
|
||||
BOOT_PART_NUM="${BOOT_PART: -1}"
|
||||
if [[ $SYS == 'UEFI' ]]; then
|
||||
@ -1312,7 +1255,6 @@ install_main()
|
||||
genfstab -U $MNT >$MNT/etc/fstab 2>$ERR
|
||||
errshow 1 "genfstab -U $MNT >$MNT/etc/fstab"
|
||||
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
|
||||
install_mirrorlist
|
||||
install_packages
|
||||
install_mkinitcpio
|
||||
install_boot
|
||||
@ -1356,21 +1298,25 @@ install_main()
|
||||
|
||||
install_base()
|
||||
{
|
||||
if [[ $RSYNC_PID ]]; then
|
||||
while kill -0 $RSYNC_PID 2>/dev/null; do
|
||||
if [[ $RSYNC_PID || $MIRROR_PID ]]; then
|
||||
while kill -0 $RSYNC_PID 2>/dev/null || kill -0 $MIRROR_PID 2>/dev/null; do
|
||||
clear
|
||||
printf "\nSystem base is still unpacking...\n"
|
||||
printf "\nBackground install process is currently running...\n"
|
||||
sleep 1
|
||||
done
|
||||
trap - EXIT
|
||||
unset RSYNC_PID
|
||||
unset RSYNC_PID MIRROR_PID
|
||||
elif [[ -d /run/archiso/sfs/airootfs/etc/skel ]]; then
|
||||
rsync -ahv /run/archiso/sfs/airootfs/ $MNT/ 2>$ERR
|
||||
errshow 1 "rsync -ahv /run/archiso/sfs/airootfs/ $MNT/"
|
||||
install_mirrorlist "$MNT/etc/pacman.d/mirrorlist"
|
||||
else
|
||||
install_mirrorlist
|
||||
pacstrap $MNT base $KERNEL $UCODE $ISO_BASE 2>$ERR
|
||||
errshow 1 "pacstrap $MNT base $KERNEL $UCODE $ISO_BASE"
|
||||
mkdir -p /etc/pacman.d/mirrorlist
|
||||
install_mirrorlist "/etc/pacman.d/mirrorlist"
|
||||
pacstrap $MNT base $UCODE $ISO_BASE 2>$ERR
|
||||
errshow 1 "pacstrap $MNT base $KERNEL $UCODE $ISO_BASE $BASE_PKGS"
|
||||
mkdir -p $MNT/etc/pacman.d/mirrorlist
|
||||
cp -f "/etc/pacman.d/mirrorlist" "$MNT/etc/pacman.d/mirrorlist"
|
||||
fi
|
||||
|
||||
rm -rf $MNT/etc/mkinitcpio-archiso.conf
|
||||
@ -1392,7 +1338,7 @@ EOF
|
||||
|
||||
if [[ -e /run/archiso/sfs/airootfs ]]; then
|
||||
[[ $KERNEL == 'linux' ]] && cp -vf $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux
|
||||
[[ $UCODE ]] && cp -vf $RUN/${UCODE/-/_}.img $MNT/boot/$UCODE.img
|
||||
[[ $UCODE && -e "$RUN/${UCODE/-/_}.img" ]] && cp -vf $RUN/${UCODE/-/_}.img $MNT/boot/$UCODE.img
|
||||
fi
|
||||
|
||||
cp -fv /etc/resolv.conf $MNT/etc/
|
||||
@ -1605,7 +1551,7 @@ install_packages()
|
||||
local rmpkg=""
|
||||
|
||||
if pacman -Qsq 'archlabs-installer' >/dev/null 2>&1; then
|
||||
rmpkg+="archlabs-installer"
|
||||
rmpkg+=" archlabs-installer"
|
||||
elif [[ -e "$MNT/usr/bin/archlabs-installer" ]]; then
|
||||
rm -f "$MNT/usr/bin/archlabs-installer"
|
||||
fi
|
||||
@ -1620,8 +1566,11 @@ install_packages()
|
||||
[[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps|dwm|fluxbox) ]] && inpkg+=" $WM_BASE_PKGS"
|
||||
[[ $INSTALL_WMS =~ ^(plasma|gnome|cinnamon)$ ]] || inpkg+=" archlabs-ksuperkey"
|
||||
|
||||
|
||||
chrun "pacman -Syyu --noconfirm"
|
||||
if [[ $rmpkg ]]; then
|
||||
chrun "pacman -Rns $rmpkg --noconfirm"
|
||||
fi
|
||||
chrun "pacman -S iputils --noconfirm"
|
||||
chrun "pacman -S $inpkg --needed --noconfirm"
|
||||
|
||||
@ -1656,16 +1605,6 @@ install_suckless()
|
||||
fi
|
||||
}
|
||||
|
||||
install_mirrorlist()
|
||||
{
|
||||
if hash reflector >/dev/null 2>&1; then
|
||||
$MIRROR_CMD --save $MNT/etc/pacman.d/mirrorlist --verbose || reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist
|
||||
else
|
||||
{ eval $MIRROR_CMD || curl -s 'https://www.archlinux.org/mirrorlist/all/'; } |
|
||||
sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -v -t -n 10 - > $MNT/etc/pacman.d/mirrorlist
|
||||
fi
|
||||
}
|
||||
|
||||
install_mkinitcpio()
|
||||
{
|
||||
local add=''
|
||||
@ -1677,13 +1616,36 @@ install_mkinitcpio()
|
||||
errshow 1 "mkinitcpio -p $KERNEL"
|
||||
}
|
||||
|
||||
install_mirrorlist()
|
||||
{
|
||||
mfile="$1"
|
||||
|
||||
if hash reflector; then
|
||||
reflector --score 120 -l 50 -f 5 --sort rate --save "$mfile"
|
||||
elif hash rankmirrors; then
|
||||
i="$(json 'ip' "check&?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=ip")"
|
||||
c="$(json 'country_code' "${i}?access_key=5f29642060ab983b31fdf4c2935d8c56&fields=country_code")"
|
||||
if [[ $c && $c =~ (CA|US) ]]; then
|
||||
m="https://www.archlinux.org/mirrorlist/?country=US&country=CA&use_mirror_status=on"
|
||||
elif [[ $c ]]; then
|
||||
m="https://www.archlinux.org/mirrorlist/?country=${c}&use_mirror_status=on"
|
||||
else
|
||||
m="https://www.archlinux.org/mirrorlist/?country=US&country=CA&country=NZ&country=GB&country=AU&use_mirror_status=on"
|
||||
fi
|
||||
curl -s "$m" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -t -n 10 - | tail -n 10 >"$mfile"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
install_background()
|
||||
{
|
||||
if [[ -d /run/archiso/sfs/airootfs/etc/skel ]] && grep -qw "$MNT" /proc/mounts && (grep -qw "$MNT/$BOOTDIR" /proc/mounts || [[ $SYS == 'BIOS' && -z $LUKS ]]); then
|
||||
msg "Background Install" "\nThe system base will now be unpacked in the background.\n" 2
|
||||
rsync -a /run/archiso/sfs/airootfs/ $MNT/ >/dev/null 2>&1 &
|
||||
yesno "Background Install" "\nA portion of the install can be done in the background while you continue.\n\nUtilize background install?\n" || return 0
|
||||
rsync -a /run/archiso/sfs/airootfs/ $MNT/ &
|
||||
RSYNC_PID=$!
|
||||
trap "kill $RSYNC_PID 2>/dev/null" EXIT
|
||||
( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" ) >/dev/null 2>&1 &
|
||||
MIRROR_PID=$!
|
||||
trap "kill $RSYNC_PID 2>/dev/null; kill $MIRROR_PID 2>/dev/null" EXIT
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -2554,7 +2516,7 @@ system_identify()
|
||||
|
||||
check_background_install()
|
||||
{
|
||||
[[ $RSYNC_PID ]] || return 0
|
||||
[[ $RSYNC_PID || $MIRROR_PID ]] || return 0
|
||||
msg "Install Running" "\nA background install process is currently running.\n" 2
|
||||
return 1
|
||||
}
|
||||
|
Reference in New Issue
Block a user