Update/overhaul mirror_cmd() function to not rely on reflector
This commit is contained in:
parent
e6bbc6a999
commit
ad8af90d43
@ -12,7 +12,7 @@
|
|||||||
# immutable variables {
|
# immutable variables {
|
||||||
|
|
||||||
readonly DIST="ArchLabs" # Linux distributor
|
readonly DIST="ArchLabs" # Linux distributor
|
||||||
readonly VER="1.6.77" # Installer version
|
readonly VER="1.6.78" # Installer version
|
||||||
readonly LIVE="liveuser" # Live session user
|
readonly LIVE="liveuser" # Live session user
|
||||||
readonly MNT="/mnt/install" # Install mountpoint
|
readonly MNT="/mnt/install" # Install mountpoint
|
||||||
readonly ERR="/tmp/errlog" # Built-in error log
|
readonly ERR="/tmp/errlog" # Built-in error log
|
||||||
@ -22,10 +22,9 @@ readonly RUN="/run/archiso/bootmnt/arch/boot"
|
|||||||
|
|
||||||
readonly SALT="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
|
readonly SALT="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
|
||||||
readonly VM="$(dmesg | grep -i "hypervisor")"
|
readonly VM="$(dmesg | grep -i "hypervisor")"
|
||||||
readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')"
|
|
||||||
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
|
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
|
||||||
readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD")"
|
readonly CONSOLE_MAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}')"
|
||||||
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
|
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)"M"}')
|
||||||
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
|
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
|
||||||
|
|
||||||
if [[ $IGNORE_DEV ]]; then
|
if [[ $IGNORE_DEV ]]; then
|
||||||
@ -104,7 +103,7 @@ init_variables() {
|
|||||||
declare -g EXTRA_MNT=""
|
declare -g EXTRA_MNT=""
|
||||||
declare -g EXTRA_MNTS=""
|
declare -g EXTRA_MNTS=""
|
||||||
declare -g SWAP="none"
|
declare -g SWAP="none"
|
||||||
declare -g SWAP_SIZE="${SYS_MEM}M"
|
declare -g SWAP_SIZE="$SYS_MEM"
|
||||||
declare -g NEWUSER=""
|
declare -g NEWUSER=""
|
||||||
declare -g USER_PASS=""
|
declare -g USER_PASS=""
|
||||||
declare -g ROOT_PASS=""
|
declare -g ROOT_PASS=""
|
||||||
@ -115,7 +114,6 @@ init_variables() {
|
|||||||
declare -g WM_PACKAGES=""
|
declare -g WM_PACKAGES=""
|
||||||
declare -g EXTRA_PACKAGES=""
|
declare -g EXTRA_PACKAGES=""
|
||||||
declare -g MKINIT_HOOKS="shutdown"
|
declare -g MKINIT_HOOKS="shutdown"
|
||||||
declare -g MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
|
|
||||||
|
|
||||||
declare -g IS_64BIT=false
|
declare -g IS_64BIT=false
|
||||||
declare -g AUTOLOGIN=false
|
declare -g AUTOLOGIN=false
|
||||||
@ -142,13 +140,10 @@ init_variables() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
source_file() {
|
source_file() {
|
||||||
if ! . $1 2>/dev/null; then
|
. $1 2>/dev/null || { printf "\nFailed to source library file %s" "$1"; die 1; }
|
||||||
echo -e "\nFailed to source library file $1"; die 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
user_setup() {
|
user_creation() {
|
||||||
tput cnorm
|
tput cnorm
|
||||||
local values
|
local values
|
||||||
values="$(dialog --stdout --no-cancel --separator '~' --ok-label "Submit" --backtitle "$BT" \
|
values="$(dialog --stdout --no-cancel --separator '~' --ok-label "Submit" --backtitle "$BT" \
|
||||||
@ -204,7 +199,7 @@ user_setup() {
|
|||||||
user=""
|
user=""
|
||||||
fi
|
fi
|
||||||
# recursively loop back unless the user cancels
|
# recursively loop back unless the user cancels
|
||||||
user_setup || return 1
|
user_creation || return 1
|
||||||
else
|
else
|
||||||
NEWUSER="$user"
|
NEWUSER="$user"
|
||||||
USER_PASS="$pass"
|
USER_PASS="$pass"
|
||||||
@ -228,17 +223,17 @@ select_language() {
|
|||||||
FONT="ter-i16n"
|
FONT="ter-i16n"
|
||||||
|
|
||||||
case $lang in
|
case $lang in
|
||||||
1) LOC="en_US.UTF-8" ;;
|
1) LOC="en_US.UTF-8" ;;
|
||||||
2) source_file $TRN/spanish.trans && LOC="es_ES.UTF-8" ;;
|
2) source_file $TRN/spanish.trans && LOC="es_ES.UTF-8" ;;
|
||||||
3) source_file $TRN/p_brasil.trans && LOC="pt_BR.UTF-8" ;;
|
3) source_file $TRN/p_brasil.trans && LOC="pt_BR.UTF-8" ;;
|
||||||
4) source_file $TRN/portuguese.trans && LOC="pt_PT.UTF-8" ;;
|
4) source_file $TRN/portuguese.trans && LOC="pt_PT.UTF-8" ;;
|
||||||
5) source_file $TRN/french.trans && LOC="fr_FR.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-16" ;;
|
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" ;;
|
7) source_file $TRN/italian.trans && LOC="it_IT.UTF-8" ;;
|
||||||
8) source_file $TRN/dutch.trans && LOC="nl_NL.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" ;;
|
9) source_file $TRN/hungarian.trans && LOC="hu_HU.UTF-8" FONT="lat2-16" ;;
|
||||||
10) source_file $TRN/chinese.trans && LOC="zh_CN.UTF-8" ;;
|
10) source_file $TRN/chinese.trans && LOC="zh_CN.UTF-8" ;;
|
||||||
*) die 0
|
*) die 0
|
||||||
esac
|
esac
|
||||||
|
|
||||||
sed -i "s/#en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen
|
sed -i "s/#en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen
|
||||||
@ -447,40 +442,53 @@ extra_packages() {
|
|||||||
pkgs="$pkgs qt5ct qt5-styleplugins"
|
pkgs="$pkgs qt5ct qt5-styleplugins"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
EXTRA_PACKAGES="$EXTRA_PACKAGES$([[ $pkgs ]] && echo -n " $pkgs")"
|
EXTRA_PACKAGES="$EXTRA_PACKAGES$([[ $pkgs ]] && printf " %s" "$pkgs")"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
mirrorlist_cmd() {
|
mirrorlist_cmd() {
|
||||||
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
|
local key="5f29642060ab983b31fdf4c2935d8c56"
|
||||||
yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0
|
local ip="$(curl -s "http://api.ipstack.com/check&fields=ip&?access_key=${key}" |
|
||||||
|
val_from_json 'ip')"
|
||||||
|
|
||||||
infobox "$_MirrorTitle" "\nGathering mirror countries..\n" 0
|
if hash reflector >/dev/null 2>&1; then
|
||||||
local countries
|
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
|
||||||
countries="$(reflector --list-countries | awk 'NF > 1 {print $1 " -"}')"
|
yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0
|
||||||
|
|
||||||
if [[ $countries != "" ]]; then
|
local c="$(curl -s "http://api.ipstack.com/${ip}?access_key=${key}&fields=country_name" |
|
||||||
tput civis
|
val_from_json 'country_name')"
|
||||||
local country
|
if [[ $c != "" ]]; then
|
||||||
country="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
MIRROR_CMD="reflector --country $c --score 80 --latest 40 --fastest 10 --sort rate"
|
||||||
--title " $_MirrorTitle " --menu "$_MirrorCountry" 22 70 10 $countries)"
|
fi
|
||||||
MIRROR_CMD="reflector --country $country --score 80 --latest 40 --fastest 10 --sort rate"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local ref=" --score n Limit the list to the n servers with the highest score.
|
tput cnorm
|
||||||
|
MIRROR_CMD="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
|
||||||
|
--title " $_MirrorTitle " --inputbox "$_MirrorCmd\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.
|
--latest n Limit the list to the n most recently synchronized servers.
|
||||||
--fastest n Return the n fastest mirrors that meet the other criteria.
|
--fastest n Return the n fastest mirrors that meet the other criteria.
|
||||||
--sort {age,rate,country,score,delay}
|
--sort {age,rate,country,score,delay}
|
||||||
|
|
||||||
'age': Last server synchronization;
|
'age': Last server synchronization;
|
||||||
'rate': Download rate;
|
'rate': Download rate;
|
||||||
'country': Server location;
|
'country': Server location;
|
||||||
'score': MirrorStatus score;
|
'score': MirrorStatus score;
|
||||||
'delay': MirrorStatus delay."
|
'delay': MirrorStatus delay.\n" 0 0 "$MIRROR_CMD")"
|
||||||
|
else
|
||||||
|
local c="$(curl -s "http://api.ipstack.com/${ip}?access_key=${key}&fields=country_code" |
|
||||||
|
val_from_json 'country_code')"
|
||||||
|
|
||||||
tput cnorm
|
local w="https://www.archlinux.org/mirrorlist"
|
||||||
MIRROR_CMD="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
|
if [[ $c != "" ]]; then
|
||||||
--title " $_MirrorTitle " --inputbox "$_MirrorCmd\n\n$ref\n" 0 0 "$cmd")"
|
if [[ $c =~ (CA|US) ]]; then
|
||||||
|
MIRROR_CMD="curl -s '$w/?country=US&country=CA&protocol=https&use_mirror_status=on'"
|
||||||
|
else
|
||||||
|
MIRROR_CMD="curl -s '$w/?country=${c}&protocol=https&use_mirror_status=on'"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
MIRROR_CMD="curl -s '$w/?country=US&country=CA&country=NZ&country=GB&country=AU&protocol=https&use_mirror_status=on'"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,11 +539,11 @@ configure_install() {
|
|||||||
|
|
||||||
setup_timezone || return 1
|
setup_timezone || return 1
|
||||||
mirrorlist_cmd || return 1
|
mirrorlist_cmd || return 1
|
||||||
user_setup || return 1
|
user_creation || return 1
|
||||||
window_manager || return 1
|
window_manager || return 1
|
||||||
|
|
||||||
local msg="\nUse the current Linux kernel or the LTS kernel?\n"
|
yesno 'Choose Kernel' "\nUse the current kernel or the LTS kernel?\n" 'Current' 'LTS' &&
|
||||||
yesno 'Choose Kernel' "$msg" 'Current' 'LTS' && KERNEL='linux' || KERNEL='linux-lts'
|
KERNEL='linux' || KERNEL='linux-lts'
|
||||||
|
|
||||||
extra_packages || return 1
|
extra_packages || return 1
|
||||||
CONFIG_DONE=true
|
CONFIG_DONE=true
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
# set -n
|
||||||
|
|
||||||
uefi_boot_fallback() {
|
uefi_boot_fallback() {
|
||||||
# some UEFI firmware requires a directory in the ESP and a generic bootx64.efi
|
# some UEFI firmware requires a directory in the ESP and a generic bootx64.efi
|
||||||
# see: https://wiki.archlinux.org/index.php/GRUB#UEFI
|
# see: https://wiki.archlinux.org/index.php/GRUB#UEFI
|
||||||
@ -53,21 +55,21 @@ prep_for_systemd-boot() {
|
|||||||
[[ $ROOT_PART =~ /dev/mapper ]] || ROOT_PART_ID="PART$ROOT_PART_ID"
|
[[ $ROOT_PART =~ /dev/mapper ]] || ROOT_PART_ID="PART$ROOT_PART_ID"
|
||||||
|
|
||||||
# create the boot entry configs
|
# create the boot entry configs
|
||||||
mkdir -p $MNT/boot/loader/entries
|
mkdir -p ${MNT}${BOOT_MNTS[$SYS-$BOOTLDR]}/loader/entries
|
||||||
cat > $MNT/boot/loader/loader.conf << EOF
|
cat > ${MNT}${BOOT_MNTS[$SYS-$BOOTLDR]}/loader/loader.conf << EOF
|
||||||
default $DIST
|
default $DIST
|
||||||
timeout 5
|
timeout 5
|
||||||
editor no
|
editor no
|
||||||
EOF
|
EOF
|
||||||
cat > $MNT/boot/loader/entries/${DIST}.conf << EOF
|
cat > ${MNT}${BOOT_MNTS[$SYS-$BOOTLDR]}/loader/entries/${DIST}.conf << EOF
|
||||||
title $DIST Linux
|
title $DIST Linux
|
||||||
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && echo -en "\ninitrd /$UCODE")
|
linux /vmlinuz-${KERNEL}$([[ $UCODE ]] && printf "\ninitrd %s" "/$UCODE")
|
||||||
initrd /initramfs-$KERNEL.img
|
initrd /initramfs-$KERNEL.img
|
||||||
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV")rw
|
options root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
|
||||||
EOF
|
EOF
|
||||||
# add pacman hook to update the bootloader when systemd receives an update
|
# add pacman hook to update the bootloader when systemd receives an update
|
||||||
mkdir -p $MNT/pacman.d/hooks
|
mkdir -p $MNT/etc/pacman.d/hooks
|
||||||
cat > $MNT/pacman.d/hooks/systemd-boot.hook << EOF
|
cat > $MNT/etc/pacman.d/hooks/systemd-boot.hook << EOF
|
||||||
[Trigger]
|
[Trigger]
|
||||||
Type = Package
|
Type = Package
|
||||||
Operation = Upgrade
|
Operation = Upgrade
|
||||||
@ -85,11 +87,11 @@ EOF
|
|||||||
|
|
||||||
prep_for_syslinux() {
|
prep_for_syslinux() {
|
||||||
if [[ $SYS == 'UEFI' ]]; then
|
if [[ $SYS == 'UEFI' ]]; then
|
||||||
local cfgdir="$MNT/boot/EFI/syslinux"
|
local cfgdir="${MNT}${BOOT_MNTS[$SYS-$BOOTLDR]}/EFI/syslinux"
|
||||||
local cfgsrcdir="/usr/lib/syslinux/efi32/"
|
local cfgsrcdir="/usr/lib/syslinux/efi32/"
|
||||||
[[ $IS_64BIT == true ]] && cfgsrcdir="/usr/lib/syslinux/efi64/"
|
[[ $IS_64BIT == true ]] && cfgsrcdir="/usr/lib/syslinux/efi64/"
|
||||||
else
|
else
|
||||||
local cfgdir="$MNT/boot/syslinux"
|
local cfgdir="$MNT${BOOT_MNTS[$SYS-$BOOTLDR]}/syslinux"
|
||||||
local cfgsrcdir="/usr/lib/syslinux/bios/"
|
local cfgsrcdir="/usr/lib/syslinux/bios/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -106,16 +108,16 @@ DEFAULT $DIST
|
|||||||
LABEL $DIST
|
LABEL $DIST
|
||||||
MENU LABEL $DIST Linux
|
MENU LABEL $DIST Linux
|
||||||
LINUX ../vmlinuz-$KERNEL
|
LINUX ../vmlinuz-$KERNEL
|
||||||
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
|
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
|
||||||
INITRD ../initramfs-$KERNEL.img
|
INITRD ../initramfs-$KERNEL.img
|
||||||
$([[ $UCODE ]] && echo -en "\nINITRD ../$UCODE")
|
$([[ $UCODE ]] && printf "\nINITRD %s" "../$UCODE")
|
||||||
|
|
||||||
LABEL ${DIST}fallback
|
LABEL ${DIST}fallback
|
||||||
MENU LABEL $DIST Linux Fallback
|
MENU LABEL $DIST Linux Fallback
|
||||||
LINUX ../vmlinuz-$KERNEL
|
LINUX ../vmlinuz-$KERNEL
|
||||||
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && echo -n "$LUKS_DEV ")rw
|
APPEND root=$ROOT_PART_ID $([[ $LUKS_DEV ]] && printf "%s " "$LUKS_DEV")rw
|
||||||
INITRD ../initramfs-$KERNEL-fallback.img
|
INITRD ../initramfs-$KERNEL-fallback.img
|
||||||
$([[ $UCODE ]] && echo -en "\nINITRD ../$UCODE")
|
$([[ $UCODE ]] && printf "\nINITRD %s" "../$UCODE")
|
||||||
EOF
|
EOF
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -123,7 +125,7 @@ EOF
|
|||||||
install_bootloader() {
|
install_bootloader() {
|
||||||
# not an LVM we can use the UUID for booting otherwise use the partition label
|
# not an LVM we can use the UUID for booting otherwise use the partition label
|
||||||
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
|
if ! [[ $ROOT_PART =~ /dev/mapper ]]; then
|
||||||
ROOT_PART_ID="UUID=$(blkid -s PARTUUID $ROOT_PART | sed 's/.*=//g; s/"//g')"
|
ROOT_PART_ID="UUID=$(blkid -s PARTUUID -o value $ROOT_PART)"
|
||||||
else
|
else
|
||||||
ROOT_PART_ID="$ROOT_PART"
|
ROOT_PART_ID="$ROOT_PART"
|
||||||
fi
|
fi
|
||||||
|
@ -6,8 +6,13 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
# set -n
|
||||||
|
|
||||||
install_main() {
|
install_main() {
|
||||||
clear && tput cnorm
|
# function calls prefixed with 'oneshot' will only ever be run once
|
||||||
|
# otherwise the main function can be called repeatedly
|
||||||
|
clear
|
||||||
|
tput cnorm
|
||||||
|
|
||||||
# unpack the file system
|
# unpack the file system
|
||||||
oneshot install_base
|
oneshot install_base
|
||||||
@ -18,8 +23,14 @@ install_main() {
|
|||||||
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
|
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
|
||||||
|
|
||||||
# update the mirrorlist.. MUST be done before updating or it may be slow
|
# update the mirrorlist.. MUST be done before updating or it may be slow
|
||||||
$MIRROR_CMD --verbose --save $MNT/etc/pacman.d/mirrorlist ||
|
printf "%s\n\n" "Sorting the mirrorlist"
|
||||||
reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist
|
if hash reflector >/dev/null 2>&1; then
|
||||||
|
$MIRROR_CMD --save $MNT/etc/pacman.d/mirrorlist ||
|
||||||
|
reflector --score 100 -l 50 -f 10 --sort rate --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 -n 10 - >$MNT/etc/pacman.d/mirrorlist
|
||||||
|
fi
|
||||||
|
|
||||||
# MUST be before bootloader and mkinitcpio
|
# MUST be before bootloader and mkinitcpio
|
||||||
oneshot package_operations
|
oneshot package_operations
|
||||||
@ -27,24 +38,25 @@ install_main() {
|
|||||||
# set up user login
|
# set up user login
|
||||||
oneshot login_manager
|
oneshot login_manager
|
||||||
|
|
||||||
# MUST be done after installing the packages
|
# mkinitcpio and bootloader install should only be done after installing the packages
|
||||||
|
# and updating the mirrorlist, otherwise the chosen kernel may not be fully set up
|
||||||
run_mkinitcpio
|
run_mkinitcpio
|
||||||
install_bootloader
|
install_bootloader
|
||||||
|
|
||||||
|
# hwclock setup, falls back to setting --directisa if the default fails
|
||||||
chroot_cmd "hwclock --systohc --utc" || chroot_cmd "hwclock --systohc --utc --directisa"
|
chroot_cmd "hwclock --systohc --utc" || chroot_cmd "hwclock --systohc --utc --directisa"
|
||||||
|
|
||||||
oneshot create_user # create the user last to avoid referencing multiple $HOME locations
|
# create the user last to avoid referencing multiple $HOME locations for liveuser/newuser
|
||||||
|
oneshot create_user
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
install_base() {
|
install_base() {
|
||||||
echo -e "\nUnpacking base file system --- Total: ~ 2.8G\n\n"
|
printf "\nUnpacking base file system --- Total: ~ 2.8G\n\n"
|
||||||
rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/
|
rsync -ah --info=progress2 /run/archiso/sfs/airootfs/ $MNT/
|
||||||
|
|
||||||
# remove archiso init files and clean up install files
|
# remove archiso init files and clean up install files
|
||||||
rm -rf $MNT/etc/sudoers.d/g_wheel
|
rm -rf $MNT/etc/{sudoers.d/g_wheel,mkinitcpio-archiso.conf,polkit-1/rules.d/49-nopasswd_global.rules}
|
||||||
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 '{}' \;
|
find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm '{}' \;
|
||||||
|
|
||||||
# cleanup system permissions
|
# cleanup system permissions
|
||||||
@ -106,7 +118,7 @@ KEYMAP=$CONSOLE_MAP
|
|||||||
FONT=$FONT
|
FONT=$FONT
|
||||||
EOF
|
EOF
|
||||||
# set the hostname
|
# set the hostname
|
||||||
echo "$HOSTNAME" > $MNT/etc/hostname
|
printf "%s\n" "$HOSTNAME" > $MNT/etc/hostname
|
||||||
cat > $MNT/etc/hosts << EOF
|
cat > $MNT/etc/hosts << EOF
|
||||||
127.0.0.1 localhost
|
127.0.0.1 localhost
|
||||||
127.0.1.1 $HOSTNAME
|
127.0.1.1 $HOSTNAME
|
||||||
@ -148,7 +160,7 @@ run_mkinitcpio() {
|
|||||||
|
|
||||||
# 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
|
||||||
(( LVM == 1 )) && add="lvm2"
|
(( LVM == 1 )) && add="lvm2"
|
||||||
(( LUKS == 1 )) && add="encrypt$([[ $add ]] && echo -n " $add")"
|
(( LUKS == 1 )) && add="encrypt$([[ $add ]] && printf " %s" "$add")"
|
||||||
sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $MNT/etc/mkinitcpio.conf
|
sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $MNT/etc/mkinitcpio.conf
|
||||||
|
|
||||||
chroot_cmd "mkinitcpio -p $KERNEL" 2>$ERR
|
chroot_cmd "mkinitcpio -p $KERNEL" 2>$ERR
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
# set -n
|
||||||
|
|
||||||
declare -g LUKS=0
|
declare -g LUKS=0
|
||||||
declare -g LUKS_DEV=""
|
declare -g LUKS_DEV=""
|
||||||
declare -g LUKS_PART=""
|
declare -g LUKS_PART=""
|
||||||
@ -150,9 +152,7 @@ luks_keycmd() {
|
|||||||
luks_show() {
|
luks_show() {
|
||||||
tput civis
|
tput civis
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
echo -e "$_LuksEncryptSucc" > /tmp/.devlist
|
msgbox "$_LuksEncrypt" "${_LuksEncryptSucc}\n$(lsblk $LUKS_PART -o NAME,MODEL,TYPE,FSTYPE,SIZE)"
|
||||||
lsblk -o NAME,TYPE,FSTYPE,SIZE $LUKS_PART >> /tmp/.devlist
|
|
||||||
dialog --cr-wrap --backtitle "$BT" --title " $_LuksEncrypt " --textbox /tmp/.devlist 0 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
luks_menu() {
|
luks_menu() {
|
||||||
@ -182,7 +182,7 @@ luks_keyfile() {
|
|||||||
|
|
||||||
if [[ ! -e $MNT/crypto_keyfile.bin ]]; then
|
if [[ ! -e $MNT/crypto_keyfile.bin ]]; then
|
||||||
infobox "$_LuksKeyFileTitle" "$_LuksKeyFileCreate" 0
|
infobox "$_LuksKeyFileTitle" "$_LuksKeyFileCreate" 0
|
||||||
echo -e "$_LuksKeyFileCreate"
|
printf "$_LuksKeyFileCreate"
|
||||||
|
|
||||||
local n
|
local n
|
||||||
n="$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')"
|
n="$(lsblk -lno NAME,UUID,TYPE | awk "/$LUKS_UUID/"' && /part|crypt|lvm/ {print $1}')"
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
# set -n
|
||||||
|
|
||||||
declare -g LVM=0
|
declare -g LVM=0
|
||||||
declare -g VOL_GROUP_MB=0
|
declare -g VOL_GROUP_MB=0
|
||||||
declare -g GROUP_PARTS=0
|
declare -g GROUP_PARTS=0
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
# set -n
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
## Partition functions ##
|
## Partition functions ##
|
||||||
########################################################
|
########################################################
|
||||||
@ -232,7 +234,7 @@ select_device() {
|
|||||||
|
|
||||||
if [[ $DEV_COUNT -eq 1 && $SYS_DEVS ]]; then
|
if [[ $DEV_COUNT -eq 1 && $SYS_DEVS ]]; then
|
||||||
DEVICE="$(awk '{print $1}' <<< "$SYS_DEVS")"
|
DEVICE="$(awk '{print $1}' <<< "$SYS_DEVS")"
|
||||||
msg="\nOnly one device available$([[ $1 == 'boot' ]] && echo -n " for grub bootloader"):"
|
msg="\nOnly one device available$([[ $1 == 'boot' ]] && printf " for grub bootloader"):"
|
||||||
infobox "$_DevSelTitle" "$msg $DEVICE\n" 1
|
infobox "$_DevSelTitle" "$msg $DEVICE\n" 1
|
||||||
elif (( DEV_COUNT > 1 )); then
|
elif (( DEV_COUNT > 1 )); then
|
||||||
tput civis
|
tput civis
|
||||||
@ -240,8 +242,7 @@ select_device() {
|
|||||||
--menu "${msg}$_DevSelBody" 0 0 0 $SYS_DEVS)"
|
--menu "${msg}$_DevSelBody" 0 0 0 $SYS_DEVS)"
|
||||||
[[ $? != 0 || $DEVICE == "" ]] && return 1
|
[[ $? != 0 || $DEVICE == "" ]] && return 1
|
||||||
else
|
else
|
||||||
msg="\nNo available devices for installation to use$([[ $1 == 'boot' ]] &&
|
msg="\nNo available devices for installation to use$([[ $1 == 'boot' ]] && printf " for grub bootloader")."
|
||||||
echo -n " for grub bootloader")."
|
|
||||||
msgbox "$_ErrTitle" "$msg\n$_Exit"
|
msgbox "$_ErrTitle" "$msg\n$_Exit"
|
||||||
die 1
|
die 1
|
||||||
fi
|
fi
|
||||||
@ -264,10 +265,11 @@ edit_partitions() {
|
|||||||
local choice
|
local choice
|
||||||
choice="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
choice="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||||
--title " $_PartTitle " --menu "$_PartBody" 0 0 0 "$_PartAuto" "-" \
|
--title " $_PartTitle " --menu "$_PartBody" 0 0 0 "$_PartAuto" "-" \
|
||||||
$( ([[ $DISPLAY ]] && hash gparted >/dev/null 2>&1) && echo -n "gparted -") "cfdisk" "-"\
|
$( ([[ $DISPLAY ]] && hash gparted >/dev/null 2>&1) && printf "gparted -") \
|
||||||
"parted" "-" "$_PartWipe" "-")"
|
"cfdisk" "-" "parted" "-" "$_PartWipe" "-")"
|
||||||
[[ $? != 0 || $choice == "" ]] && return 1
|
[[ $? != 0 || $choice == "" ]] && return 1
|
||||||
clear; tput cnorm
|
clear
|
||||||
|
tput cnorm
|
||||||
|
|
||||||
if [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" ]]; then
|
if [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" ]]; then
|
||||||
$choice $device
|
$choice $device
|
||||||
@ -325,17 +327,17 @@ select_swap() {
|
|||||||
# Ask user to select partition or create swapfile
|
# Ask user to select partition or create swapfile
|
||||||
tput civis
|
tput civis
|
||||||
SWAP="$(dialog --backtitle "$BT" --cr-wrap --stdout --title " $_SelSwpSetup " \
|
SWAP="$(dialog --backtitle "$BT" --cr-wrap --stdout --title " $_SelSwpSetup " \
|
||||||
--menu "$_SelSwpBody" 0 0 0 "$_SelSwpNone" "-" "$_SelSwpFile" "${SYS_MEM}M" $PARTS)"
|
--menu "$_SelSwpBody" 0 0 0 "$_SelSwpNone" "-" "$_SelSwpFile" "$SYS_MEM" $PARTS)"
|
||||||
[[ $? != 0 || $SWAP == "$_SelSwpNone" ]] && return 0
|
[[ $? != 0 || $SWAP == "$_SelSwpNone" ]] && return 0
|
||||||
|
|
||||||
if [[ $SWAP == "$_SelSwpFile" ]]; then
|
if [[ $SWAP == "$_SelSwpFile" ]]; then
|
||||||
tput cnorm
|
tput cnorm
|
||||||
SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "${SYS_MEM}M")"
|
SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"
|
||||||
[[ $? != 0 || $SWAP_SIZE == "" ]] && return 1
|
[[ $? != 0 || $SWAP_SIZE == "" ]] && return 1
|
||||||
|
|
||||||
while ! [[ ${SWAP_SIZE:0:1} =~ [1-9] && ${SWAP_SIZE: -1} =~ (M|G) ]]; do
|
while ! [[ ${SWAP_SIZE:0:1} =~ [1-9] && ${SWAP_SIZE: -1} =~ (M|G) ]]; do
|
||||||
msgbox "$_SelSwpSetup Error" "\n$_SelSwpErr $SWAP_SIZE\n"
|
msgbox "$_SelSwpSetup Error" "\n$_SelSwpErr $SWAP_SIZE\n"
|
||||||
SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "${SYS_MEM}M")"
|
SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"
|
||||||
[[ $? != 0 || $SWAP_SIZE == "" ]] && { break; return 1; }
|
[[ $? != 0 || $SWAP_SIZE == "" ]] && { break; return 1; }
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -415,8 +417,8 @@ select_filesystem() {
|
|||||||
local fs
|
local fs
|
||||||
fs="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_FSTitle: $part " \
|
fs="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_FSTitle: $part " \
|
||||||
--menu "\nPartition: ${part}$([[ $cur_fs != "" ]] &&
|
--menu "\nPartition: ${part}$([[ $cur_fs != "" ]] &&
|
||||||
echo -en "\nCurrent: ${cur_fs}")\n$_FSBody" 0 0 0 \
|
printf "\nCurrent: %s" "$cur_fs")\n$_FSBody" 0 0 0 \
|
||||||
$([[ $cur_fs != "" ]] && echo -n "$_Skip -") \
|
$([[ $cur_fs != "" ]] && printf "%s -" "$_Skip") \
|
||||||
"ext4" "${FS_CMDS[ext4]}" "ext3" "${FS_CMDS[ext3]}" \
|
"ext4" "${FS_CMDS[ext4]}" "ext3" "${FS_CMDS[ext3]}" \
|
||||||
"ext2" "${FS_CMDS[ext2]}" "vfat" "${FS_CMDS[vfat]}" \
|
"ext2" "${FS_CMDS[ext2]}" "vfat" "${FS_CMDS[vfat]}" \
|
||||||
"ntfs" "${FS_CMDS[ntfs]}" "f2fs" "${FS_CMDS[f2fs]}" \
|
"ntfs" "${FS_CMDS[ntfs]}" "f2fs" "${FS_CMDS[f2fs]}" \
|
||||||
@ -481,7 +483,9 @@ select_root_partition() {
|
|||||||
decr_count "$LUKS_PART"
|
decr_count "$LUKS_PART"
|
||||||
elif (( LVM == 1 )); then
|
elif (( LVM == 1 )); then
|
||||||
(( LUKS == 1 )) && decr_count "$LUKS_PART"
|
(( LUKS == 1 )) && decr_count "$LUKS_PART"
|
||||||
for part in $(echo "$GROUP_PARTS"); do decr_count "$part"; done
|
for part in $(echo "$GROUP_PARTS"); do
|
||||||
|
decr_count "$part"
|
||||||
|
done
|
||||||
ROOT_PART=""
|
ROOT_PART=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -494,7 +498,7 @@ select_root_partition() {
|
|||||||
--title " $_PrepMount " --menu "$_SelRootBody" 0 0 0 $PARTS)"
|
--title " $_PrepMount " --menu "$_SelRootBody" 0 0 0 $PARTS)"
|
||||||
[[ $? != 0 || $ROOT_PART == "" ]] && return 1
|
[[ $? != 0 || $ROOT_PART == "" ]] && return 1
|
||||||
else
|
else
|
||||||
local msg="\nUsing $([[ $LUKS -eq 1 ]] && echo -n "encrypted ")root partition:"
|
local msg="\nUsing $([[ $LUKS -eq 1 ]] && printf "encrypted ")root partition:"
|
||||||
infobox "$_PrepMount" "$msg $ROOT_PART\n" 1
|
infobox "$_PrepMount" "$msg $ROOT_PART\n" 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -6,10 +6,16 @@
|
|||||||
# 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
|
||||||
|
|
||||||
|
# set -n
|
||||||
|
|
||||||
chroot_cmd() {
|
chroot_cmd() {
|
||||||
arch-chroot $MNT /bin/bash -c "$1"
|
arch-chroot $MNT /bin/bash -c "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val_from_json() {
|
||||||
|
python3 -c "import sys, json; print(json.load(sys.stdin)['$1'])"
|
||||||
|
}
|
||||||
|
|
||||||
identify_system() {
|
identify_system() {
|
||||||
if grep -qi 'apple' /sys/class/dmi/id/sys_vendor; then
|
if grep -qi 'apple' /sys/class/dmi/id/sys_vendor; then
|
||||||
modprobe -r -q efivars
|
modprobe -r -q efivars
|
||||||
@ -53,9 +59,9 @@ check_for_errors() {
|
|||||||
err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$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"
|
[[ $err != "" ]] && msgbox "$_ErrTitle" "$msg\n\nWith the following error message:\n\n$err"
|
||||||
|
|
||||||
msg="$([[ $err == "" ]] && echo -n "$msg")\n$_ErrChoice"
|
msg="$([[ $err == "" ]] && printf "%s" "$msg")\n$_ErrChoice"
|
||||||
if [[ -e /tmp/debug-log && $TERM == 'linux' ]]; then
|
if [[ -e /tmp/debug-log && $TERM == 'linux' ]]; then
|
||||||
msg="$([[ $err == "" ]] && echo -n "$msg")\n$_ErrChoiceConsole"
|
msg="$([[ $err == "" ]] && printf "%s" "$msg")\n$_ErrChoiceConsole"
|
||||||
yesno "$_ErrTitle" "$msg" "Exit & Open Log" "Ignore & Continue" && { less /tmp/debug-log; die 0; }
|
yesno "$_ErrTitle" "$msg" "Exit & Open Log" "Ignore & Continue" && { less /tmp/debug-log; die 0; }
|
||||||
else
|
else
|
||||||
yesno "$_ErrTitle" "$msg" "Exit & Shutdown" "Ignore & Continue" && die 'shutdown -h now'
|
yesno "$_ErrTitle" "$msg" "Exit & Shutdown" "Ignore & Continue" && die 'shutdown -h now'
|
||||||
@ -89,7 +95,7 @@ getinput() {
|
|||||||
answer="$(dialog --cr-wrap --max-input 63 --stdout --no-cancel \
|
answer="$(dialog --cr-wrap --max-input 63 --stdout --no-cancel \
|
||||||
--backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")"
|
--backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")"
|
||||||
[[ $? != 0 || $answer == "" ]] && return 1
|
[[ $? != 0 || $answer == "" ]] && return 1
|
||||||
echo "$answer"
|
printf "$answer"
|
||||||
}
|
}
|
||||||
|
|
||||||
msgbox() {
|
msgbox() {
|
||||||
@ -133,7 +139,7 @@ die() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sigint() {
|
sigint() {
|
||||||
echo -e "\n** CTRL-C caught"
|
printf "\n** CTRL-C caught"
|
||||||
die 1
|
die 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user