Clean up boot, move funtion to file it's used in

This commit is contained in:
natemaia
2018-09-15 13:44:52 -07:00
parent 989a952751
commit b5fa475863
5 changed files with 161 additions and 164 deletions

View File

@ -12,25 +12,19 @@
# immutable variables {
readonly DIST="ArchLabs" # Linux distributor
readonly VER="1.6.73" # Installer version
readonly VER="1.6.74" # 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 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')"
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 IGNORE_DEV="$(lsblk -lno NAME,MOUNTPOINT | awk '/\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')"
if [[ $IGNORE_DEV ]]; then
@ -41,9 +35,9 @@ fi
readonly DEV_COUNT="$(wc -l <<< "$SYS_DEVS")"
if [[ $(grep 'GenuineIntel' /proc/cpuinfo) ]]; then
if grep -q 'GenuineIntel' /proc/cpuinfo; then
readonly UCODE="intel-ucode.img"
elif [[ $(grep 'AuthenticAMD' /proc/cpuinfo) ]]; then
elif grep -q 'AuthenticAMD' /proc/cpuinfo; then
readonly UCODE="amd-ucode.img"
fi
@ -52,11 +46,10 @@ declare -gA SUBZONES
for zone in America Australia Asia Atlantic Africa Europe Indian Pacific Arctic Antarctica; do
SUBZONES[$zone]="$(awk "/$zone\// {gsub(/$zone\//, \"\"); print \$3 \" \"\$1}" /usr/share/zoneinfo/zone.tab)"
done
readonly SUBZONES # make it read only
if [[ $DISPLAY && $TERM != 'linux' ]]; then
for t in st termite xterm; do
for t in termite st xterm; do
hash $t >/dev/null 2>&1 && { readonly TERM_CMD="$t"; break; }
done
fi
@ -73,8 +66,7 @@ af Afghani fo Faroese ge Georgian ee Estonian kg Kyrgyz kz Kazakh lt Lithuanian
mn Mongolian no Norwegian ro Romanian rs Serbian si Slovenian tj Tajik lk Sinhala tr Turkish
uz Uzbek ie Irish pk Urdu mv Dhivehi epo Esperanto np Nepali et Amharic sn Wolof ml Bambara
tz Swahili ke Swahili bw Tswana ph Filipino id Indonesian my Malay tm Turkmen bt Dzongkha
lv Latvian md Moldavian mao Maori by Belarusian me Montenegrin mk Macedonian kh Khmer
az Azerbaijani"
lv Latvian md Moldavian mao Maori by Belarusian me Montenegrin mk Macedonian kh Khmer az Azerbaijani"
declare -Agr BMNTS=(
[UEFI-grub]="/boot/efi" [UEFI-systemd-boot]="/boot" [BIOS-grub]="/boot"
@ -149,7 +141,10 @@ init_variables() {
}
source_file() {
. $1 2>/dev/null && return 0 || { echo -e "\nFailed to source library file $1"; die 1; }
if ! . $1 2>/dev/null; then
echo -e "\nFailed to source library file $1"; die 1
fi
return 0
}
user_setup() {
@ -183,7 +178,7 @@ user_setup() {
if [[ $pass == "" || "$pass" != "$pass2" || "$rpass" != "$rpass2" ]]; then
# password was left empty or doesn't match
if [[ $pass == "" ]]; then
msgbox "$_ErrTitle" "\nUser $_Password CANNOT be left empty.\n$_TryAgain"
msgbox "$_ErrTitle" "\nUser password CANNOT be left empty.\n$_TryAgain"
elif [[ "$rpass" != "$rpass2" ]]; then
msgbox "$_ErrTitle" "$_RootPassErr\n$_TryAgain"
else
@ -251,7 +246,6 @@ setup_keymap() {
# 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 --backtitle "$BT" \
--title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CONSOLE_MAPS)"
[[ $? != 0 || $CONSOLE_MAP == "" ]] && return 1
@ -362,7 +356,7 @@ extra_packages() {
"emacs" "An extensible, customizable, self-documenting real-time display editor" off \
"neovim" "A fork of Vim aiming to improve user experience, plugins, and GUIs." off \
"mousepad" "A simple text editor" off \
"urxvt" "A unicode enabled rxvt-clone terminal emulator" off \
"rxvt-unicode" "A unicode enabled rxvt-clone terminal emulator" off \
"termite" "A minimal VTE-based terminal emulator" off \
"tilix" "A tiling terminal emulator for Linux using GTK+ 3" off \
"terminator" "Terminal emulator that supports tabs and grids" off \
@ -372,7 +366,7 @@ extra_packages() {
"pcmanfm" "A fast and lightweight file manager based in Lxde" off \
"gnome-disk-utility" "Disk Management Utility" off \
"gnome-system-monitor" "View current processes and monitor system state" off \
"steam steam-native-runtime" "A popular game distribution platform by Valve" off \
"steam" "A popular game distribution platform by Valve" off \
"vlc" "A free and open source cross-platform multimedia player" off \
"mpd" "A flexible, powerful, server-side application for playing music" off \
"ncmpcpp" "An mpd client and almost exact clone of ncmpc with some new features" off \
@ -427,10 +421,14 @@ extra_packages() {
[[ $pkgs =~ mpd ]] && pkgs="$pkgs mpc"
[[ $pkgs =~ mupdf ]] && pkgs="$pkgs mupdf-tools"
[[ $pkgs =~ qt5ct ]] && pkgs="$pkgs qt5-styleplugins"
[[ $pkgs =~ steam ]] && pkgs="$pkgs steam-native-runtime"
[[ $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"
if [[ $INSTALL_WMS =~ dwm ]] && ! [[ $pkgs =~ ttf-hack ]]; then
pkgs="$pkgs ttf-hack"
fi
if [[ $pkgs =~ (qutebrowser|qbittorrent|kdenlive|vlc) ]] && ! [[ $pkgs =~ qt5ct ]]; then
pkgs="$pkgs qt5ct qt5-styleplugins"
fi
@ -553,7 +551,7 @@ edit_configs() {
[[ -e ${MNT}$f ]] && existing_files="$existing_files ${MNT}$f"
done
if [[ $existing_files != "" ]]; then
if [[ $existing_files ]]; then
vim -O $existing_files
else
msgbox "$_ErrTitle" "$_NoFileErr"