You've already forked al-installer
Update/overhaul mirror_cmd() function to not rely on reflector
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
# immutable variables {
|
||||
|
||||
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 MNT="/mnt/install" # Install mountpoint
|
||||
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 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 CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD")"
|
||||
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}')
|
||||
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)"M"}')
|
||||
readonly IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
|
||||
|
||||
if [[ $IGNORE_DEV ]]; then
|
||||
@ -104,7 +103,7 @@ init_variables() {
|
||||
declare -g EXTRA_MNT=""
|
||||
declare -g EXTRA_MNTS=""
|
||||
declare -g SWAP="none"
|
||||
declare -g SWAP_SIZE="${SYS_MEM}M"
|
||||
declare -g SWAP_SIZE="$SYS_MEM"
|
||||
declare -g NEWUSER=""
|
||||
declare -g USER_PASS=""
|
||||
declare -g ROOT_PASS=""
|
||||
@ -115,7 +114,6 @@ init_variables() {
|
||||
declare -g WM_PACKAGES=""
|
||||
declare -g EXTRA_PACKAGES=""
|
||||
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 AUTOLOGIN=false
|
||||
@ -142,13 +140,10 @@ init_variables() {
|
||||
}
|
||||
|
||||
source_file() {
|
||||
if ! . $1 2>/dev/null; then
|
||||
echo -e "\nFailed to source library file $1"; die 1
|
||||
fi
|
||||
return 0
|
||||
. $1 2>/dev/null || { printf "\nFailed to source library file %s" "$1"; die 1; }
|
||||
}
|
||||
|
||||
user_setup() {
|
||||
user_creation() {
|
||||
tput cnorm
|
||||
local values
|
||||
values="$(dialog --stdout --no-cancel --separator '~' --ok-label "Submit" --backtitle "$BT" \
|
||||
@ -204,7 +199,7 @@ user_setup() {
|
||||
user=""
|
||||
fi
|
||||
# recursively loop back unless the user cancels
|
||||
user_setup || return 1
|
||||
user_creation || return 1
|
||||
else
|
||||
NEWUSER="$user"
|
||||
USER_PASS="$pass"
|
||||
@ -228,17 +223,17 @@ select_language() {
|
||||
FONT="ter-i16n"
|
||||
|
||||
case $lang in
|
||||
1) LOC="en_US.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" ;;
|
||||
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-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" ;;
|
||||
10) source_file $TRN/chinese.trans && LOC="zh_CN.UTF-8" ;;
|
||||
*) die 0
|
||||
1) LOC="en_US.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" ;;
|
||||
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-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" ;;
|
||||
10) source_file $TRN/chinese.trans && LOC="zh_CN.UTF-8" ;;
|
||||
*) die 0
|
||||
esac
|
||||
|
||||
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"
|
||||
fi
|
||||
|
||||
EXTRA_PACKAGES="$EXTRA_PACKAGES$([[ $pkgs ]] && echo -n " $pkgs")"
|
||||
EXTRA_PACKAGES="$EXTRA_PACKAGES$([[ $pkgs ]] && printf " %s" "$pkgs")"
|
||||
return 0
|
||||
}
|
||||
|
||||
mirrorlist_cmd() {
|
||||
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
|
||||
yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0
|
||||
local key="5f29642060ab983b31fdf4c2935d8c56"
|
||||
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
|
||||
local countries
|
||||
countries="$(reflector --list-countries | awk 'NF > 1 {print $1 " -"}')"
|
||||
if hash reflector >/dev/null 2>&1; then
|
||||
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate"
|
||||
yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0
|
||||
|
||||
if [[ $countries != "" ]]; then
|
||||
tput civis
|
||||
local country
|
||||
country="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
||||
--title " $_MirrorTitle " --menu "$_MirrorCountry" 22 70 10 $countries)"
|
||||
MIRROR_CMD="reflector --country $country --score 80 --latest 40 --fastest 10 --sort rate"
|
||||
fi
|
||||
local c="$(curl -s "http://api.ipstack.com/${ip}?access_key=${key}&fields=country_name" |
|
||||
val_from_json 'country_name')"
|
||||
if [[ $c != "" ]]; then
|
||||
MIRROR_CMD="reflector --country $c --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.
|
||||
--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."
|
||||
'age': Last server synchronization;
|
||||
'rate': Download rate;
|
||||
'country': Server location;
|
||||
'score': MirrorStatus score;
|
||||
'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
|
||||
MIRROR_CMD="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \
|
||||
--title " $_MirrorTitle " --inputbox "$_MirrorCmd\n\n$ref\n" 0 0 "$cmd")"
|
||||
local w="https://www.archlinux.org/mirrorlist"
|
||||
if [[ $c != "" ]]; then
|
||||
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
|
||||
}
|
||||
|
||||
@ -531,11 +539,11 @@ configure_install() {
|
||||
|
||||
setup_timezone || return 1
|
||||
mirrorlist_cmd || return 1
|
||||
user_setup || return 1
|
||||
user_creation || return 1
|
||||
window_manager || return 1
|
||||
|
||||
local msg="\nUse the current Linux kernel or the LTS kernel?\n"
|
||||
yesno 'Choose Kernel' "$msg" 'Current' 'LTS' && KERNEL='linux' || KERNEL='linux-lts'
|
||||
yesno 'Choose Kernel' "\nUse the current kernel or the LTS kernel?\n" 'Current' 'LTS' &&
|
||||
KERNEL='linux' || KERNEL='linux-lts'
|
||||
|
||||
extra_packages || return 1
|
||||
CONFIG_DONE=true
|
||||
|
Reference in New Issue
Block a user