Dont check directly instead of checking 0 everytime, update README

This commit is contained in:
natemaia
2018-11-07 20:07:40 -08:00
parent 92fb1c6cff
commit 7426259dc5
9 changed files with 228 additions and 190 deletions

View File

@ -9,10 +9,12 @@
# set -n
# shellcheck disable=2154
# globals {
# immutable values
readonly VER="1.7.11" # Installer version
readonly VER="1.7.12" # Installer version
readonly DIST="ArchLabs" # Linux distributor
readonly LIVE="liveuser" # Live session user
readonly MNT="/mnt/install" # Install mountpoint
@ -22,7 +24,7 @@ readonly ERR="/tmp/errlog" # Built-in error log
declare -g WARN=false
declare -g AUTOLOGIN=false
declare -g CONFIG_DONE=false
declare -g SEPERATE_BOOT=false
declare -gx SEPERATE_BOOT=false
declare -g BT="$DIST Installer - (x86_64) - Version $VER"
declare -g ROOT_PART=""
@ -90,7 +92,7 @@ select_language() {
user_creation() {
tput cnorm
local values
values="$(dialog --stdout --no-cancel --separator '~' --ok-label "Submit" --backtitle "$BT" \
if ! values="$(dialog --stdout --no-cancel --separator '~' --ok-label "Submit" --backtitle "$BT" \
--title " $_UserTitle " --insecure --mixedform "$_UserBody" 27 75 10 \
"$_Username" 1 1 "" 1 $((${#_Username} + 2)) 71 0 0 \
"$_Password" 2 1 "" 2 $((${#_Password} + 2)) 71 0 1 \
@ -98,15 +100,16 @@ user_creation() {
"$_RootBody" 6 1 "" 6 $((${#_RootBody} + 1)) 71 0 2 \
"$_Password" 8 1 "" 8 $((${#_Password} + 2)) 71 0 1 \
"$_Password2" 9 1 "" 9 $((${#_Password2} + 2)) 71 0 1 |
openssl enc -pbkdf2 -a -salt -pass pass:$SALT)"
[[ $? != 0 || $values == "" ]] && return 1
openssl enc -pbkdf2 -a -salt -pass pass:$SALT)"; then
return 1
fi
# username doesn't need to be re-encrypted
local user
user="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
awk -F'~' '{print $1}')"
# username doesn't need to be re-encrypted
local user
user="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
awk -F'~' '{print $1}')"
# all of this is a bit hacky, but we don't ever want the passwords to be stored in plain text
# all of this is a bit hacky, but we don't ever want the passwords to be stored in plain text
# so it decrypts the string '$values', gets the field we want, and re-encrypts it
local pass pass2
pass="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
@ -145,46 +148,48 @@ user_creation() {
# recursively loop back unless the user cancels
user || return 1
else
NEWUSER="$user"
USER_PASS="$pass"
ROOT_PASS="$rpass"
export NEWUSER="$user"
export USER_PASS="$pass"
export ROOT_PASS="$rpass"
fi
return 0
}
select_keymap() {
tput civis
KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
if ! KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepLayout " --menu "$_XMapBody" 20 70 12 \
'us' 'English' 'cm' 'English' 'gb' 'English' 'au' 'English' 'gh' 'English' \
'za' 'English' 'ng' 'English' 'ca' 'French' 'cd' 'French' 'gn' 'French' \
'tg' 'French' 'fr' 'French' 'de' 'German' 'at' 'German' 'ch' 'German' \
'es' 'Spanish' 'latam' 'Spanish' 'br' 'Portuguese' 'pt' 'Portuguese' 'ma' 'Arabic' \
'sy' 'Arabic' 'ara' 'Arabic' 'ua' 'Ukrainian' 'cz' 'Czech' 'ru' 'Russian' \
'sk' 'Slovak' 'nl' 'Dutch' 'it' 'Italian' 'hu' 'Hungarian' 'cn' 'Chinese' \
'tw' 'Taiwanese' 'vn' 'Vietnamese' 'kr' 'Korean' 'jp' 'Japanese' 'th' 'Thai' \
'la' 'Lao' 'pl' 'Polish' 'se' 'Swedish' 'is' 'Icelandic' 'fi' 'Finnish' \
'dk' 'Danish' 'be' 'Belgian' 'in' 'Indian' 'al' 'Albanian' 'am' 'Armenian' \
'bd' 'Bangla' 'ba' 'Bosnian' 'bg' 'Bulgarian' 'dz' 'Berber' 'mm' 'Burmese' \
'hr' 'Croatian' 'gr' 'Greek' 'il' 'Hebrew' 'ir' 'Persian' 'iq' 'Iraqi' \
'af' 'Afghani' 'fo' 'Faroese' 'ge' 'Georgian' 'ee' 'Estonian' 'kg' 'Kyrgyz' \
'kz' 'Kazakh' 'lt' 'Lithuanian' 'mt' 'Maltese' 'mn' 'Mongolian' 'ro' 'Romanian' \
'no' 'Norwegian' 'rs' 'Serbian' 'si' 'Slovenian' 'tj' 'Tajik' 'lk' 'Sinhala' \
'tr' 'Turkish' 'uz' 'Uzbek' 'ie' 'Irish' 'pk' 'Urdu' 'mv' 'Dhivehi' \
'np' 'Nepali' 'et' 'Amharic' 'sn' 'Wolof' 'ml' 'Bambara' 'tz' 'Swahili' \
'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')"
[[ $? != 0 || $KEYMAP == "" ]] && return 1
'us' 'English' 'cm' 'English' 'gb' 'English' 'au' 'English' 'gh' 'English' \
'za' 'English' 'ng' 'English' 'ca' 'French' 'cd' 'French' 'gn' 'French' \
'tg' 'French' 'fr' 'French' 'de' 'German' 'at' 'German' 'ch' 'German' \
'es' 'Spanish' 'latam' 'Spanish' 'br' 'Portuguese' 'pt' 'Portuguese' 'ma' 'Arabic' \
'sy' 'Arabic' 'ara' 'Arabic' 'ua' 'Ukrainian' 'cz' 'Czech' 'ru' 'Russian' \
'sk' 'Slovak' 'nl' 'Dutch' 'it' 'Italian' 'hu' 'Hungarian' 'cn' 'Chinese' \
'tw' 'Taiwanese' 'vn' 'Vietnamese' 'kr' 'Korean' 'jp' 'Japanese' 'th' 'Thai' \
'la' 'Lao' 'pl' 'Polish' 'se' 'Swedish' 'is' 'Icelandic' 'fi' 'Finnish' \
'dk' 'Danish' 'be' 'Belgian' 'in' 'Indian' 'al' 'Albanian' 'am' 'Armenian' \
'bd' 'Bangla' 'ba' 'Bosnian' 'bg' 'Bulgarian' 'dz' 'Berber' 'mm' 'Burmese' \
'hr' 'Croatian' 'gr' 'Greek' 'il' 'Hebrew' 'ir' 'Persian' 'iq' 'Iraqi' \
'af' 'Afghani' 'fo' 'Faroese' 'ge' 'Georgian' 'ee' 'Estonian' 'kg' 'Kyrgyz' \
'kz' 'Kazakh' 'lt' 'Lithuanian' 'mt' 'Maltese' 'mn' 'Mongolian' 'ro' 'Romanian' \
'no' 'Norwegian' 'rs' 'Serbian' 'si' 'Slovenian' 'tj' 'Tajik' 'lk' 'Sinhala' \
'tr' 'Turkish' 'uz' 'Uzbek' 'ie' 'Irish' 'pk' 'Urdu' 'mv' 'Dhivehi' \
'np' 'Nepali' 'et' 'Amharic' 'sn' 'Wolof' 'ml' 'Bambara' 'tz' 'Swahili' \
'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')"; then
return 1
fi
# when a matching console map is not available open a selection dialog
if [[ $CMAPS =~ "$KEYMAP -" ]]; then
# shellcheck disable=SC2153
if [[ $CMAPS == *"$KEYMAP"* ]]; then
CMAP="$KEYMAP"
else
CMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CMAPS)"
[[ $? != 0 || $CMAP == "" ]] && return 1
if ! CMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CMAPS)"; then
return 1
fi
fi
if [[ $DISPLAY && $TERM != 'linux' ]]; then
@ -204,22 +209,24 @@ select_timezone() {
done
tput civis
ZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
if ! 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
'Europe' '-' 'Indian' '-' 'Pacific' '-' 'Arctic' '-' 'Antarctica' '-')"; then
return 1
fi
SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 20 70 12 ${SUBZONES[$ZONE]})"
[[ $? != 0 || $SUBZONE == "" ]] && return 1
if ! SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 20 70 12 ${SUBZONES[$ZONE]})"; then
return 1
fi
yesno "$_TimeZTitle" "$_TimeZQ $ZONE/$SUBZONE?\n" && return 0 || select_timezone
}
select_wm_or_de() {
tput civis
INSTALL_WMS="$(dialog --cr-wrap --stdout --backtitle "$BT" \
if ! 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 \
@ -227,8 +234,9 @@ select_wm_or_de() {
"dwm" "A customized fork of dwm, with patches and modifications" off \
"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)"
[[ $? -eq 0 ]] || return 1
"xfce4" "A lightweight and modular desktop environment based on GTK+ 2 and 3" off)"; then
return 1
fi
[[ $INSTALL_WMS ]] || INSTALL_WMS='openbox'
WM_NUM=$(awk '{print NF}' <<< "$INSTALL_WMS")
@ -244,13 +252,12 @@ select_wm_or_de() {
gnome) WM_PACKAGES+=" gnome-extra" ;;
i3-gaps) WM_PACKAGES+=" i3status perl-anyevent-i3" ;;
xfce4) WM_PACKAGES+=" xfce4-goodies xfce4-pulseaudio-plugin" ;;
openbox) WM_PACKAGES+=" archlabs-obkey archlabs-kickshaw archlabs-skippy-xd obconf tint2 conky jgmenu" ;;
openbox) WM_PACKAGES+=" archlabs-obkey obconf archlabs-kickshaw tint2 archlabs-skippy-xd conky jgmenu" ;;
esac
done
if [[ $INSTALL_WMS =~ (openbox|bspwm|i3-gaps) ]]; then
WM_PACKAGES+=" rofi termite thunar archlabs-polybar archlabs-paranoid"
WM_PACKAGES+=" libmpdclient jsoncpp archlabs-screenlock archlabs-oblogout"
WM_PACKAGES+=" libmpdclient rofi jsoncpp archlabs-screenlock termite archlabs-oblogout thunar archlabs-polybar archlabs-paranoid"
elif [[ $INSTALL_WMS =~ (xfce4) ]]; then
WM_PACKAGES+=" archlabs-oblogout archlabs-screenlock archlabs-paranoid"
fi
@ -263,9 +270,10 @@ select_wm_or_de() {
if [[ $WM_NUM -eq 1 ]]; then
LOGIN_WM="$INSTALL_WMS"
else
LOGIN_WM="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
--title " $_WMLogin " --menu "$_WMLoginBody" 0 0 0 $LOGIN_CHOICES)"
[[ $? -eq 0 ]] || return 1
if ! LOGIN_WM="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
--title " $_WMLogin " --menu "$_WMLoginBody" 0 0 0 $LOGIN_CHOICES)"; then
return 1
fi
fi
case $LOGIN_WM in
@ -288,11 +296,12 @@ select_wm_or_de() {
}
select_login_method() {
LOGIN_TYPE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
if ! LOGIN_TYPE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_WMLogin " --menu "$_LoginTypeBody" 0 0 0 \
"xinit" "Console login without a display manager" \
"lightdm" "Lightweight display manager with the gtk greeter")"
[[ $? -eq 0 ]] || return 1
"lightdm" "Lightweight display manager with the gtk greeter")"; then
return 1
fi
if [[ $LOGIN_TYPE == 'lightdm' ]]; then
WM_PACKAGES+=" lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice"
EDIT_FILES[11]="/etc/lightdm/lightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf"
@ -386,8 +395,8 @@ select_extra_packages() {
[[ $pkgs =~ noto-fonts ]] && pkgs+=" noto-fonts-emoji"
[[ $pkgs =~ cairo-dock ]] && pkgs+=" cairo-dock-plug-ins"
[[ $pkgs =~ kdenlive ]] && pkgs+=" kdebase-runtime dvdauthor frei0r-plugins breeze breeze-gtk"
([[ $INSTALL_WMS =~ dwm ]] && ! [[ $pkgs =~ ttf-hack ]]) && pkgs+=" ttf-hack"
([[ $pkgs =~ (qutebrowser|qbittorrent|kdenlive|vlc) ]] && ! [[ $pkgs =~ qt5ct ]]) && pkgs+=" qt5ct qt5-styleplugins"
{ [[ $INSTALL_WMS =~ dwm ]] && ! [[ $pkgs =~ ttf-hack ]]; } && pkgs+=" ttf-hack"
{ [[ $pkgs =~ (qutebrowser|qbittorrent|kdenlive|vlc) ]] && ! [[ $pkgs =~ qt5ct ]]; } && pkgs+=" qt5ct qt5-styleplugins"
PACKAGES+=" $pkgs" # add chosen packages to the main package list
PACKAGES="${PACKAGES/^ /}" # remove leading spaces from the package string
@ -395,14 +404,15 @@ select_extra_packages() {
}
select_mirrorlist_command() {
local ip c
local key="5f29642060ab983b31fdf4c2935d8c56"
if hash reflector >/dev/null 2>&1; then
MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate --verbose"
yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0
local ip="$(json 'ip' "check&?access_key=${key}&fields=ip")"
local c="$(json 'country_name' "${ip}?access_key=${key}&fields=country_name")"
ip="$(json 'ip' "check&?access_key=${key}&fields=ip")"
c="$(json 'country_name' "${ip}?access_key=${key}&fields=country_name")"
MIRROR_CMD="reflector --country $c --score 80 --latest 40 --fastest 10 --sort rate --verbose"
tput cnorm
@ -419,8 +429,8 @@ select_mirrorlist_command() {
'score': MirrorStatus score;
'delay': MirrorStatus delay.\n" 0 0 "$MIRROR_CMD")"
else
local ip="$(json 'ip' "check&?access_key=${key}&fields=ip")"
local c="$(json 'country_code' "${ip}?access_key=${key}&fields=country_code")"
ip="$(json 'ip' "check&?access_key=${key}&fields=ip")"
c="$(json 'country_code' "${ip}?access_key=${key}&fields=country_code")"
local w="https://www.archlinux.org/mirrorlist"
if [[ $c ]]; then
if [[ $c =~ (CA|US) ]]; then
@ -442,12 +452,12 @@ display_system_settings() {
msgbox "$_PrepTitle" "\n\n---------- PARTITION CONFIGURATION ------------
Root: ${ROOT_PART:-None}
Boot: ${BOOT_PART:-None}
Boot: ${BOOT_PART:-${BOOT_DEVICE:-None}}
Swap: ${SWAP_PART:-None}
Size: ${SWAP_SIZE:-None}
Extra: ${EXTRA_MNTS:-None}
Extra: ${EXTRA_MNTS:-${EXTRA_MNT:-None}}
Hooks: ${MKINIT_HOOKS:-None}
LVM: ${LVM:-None}
@ -487,13 +497,15 @@ display_system_settings() {
configure_system_settings() {
tput cnorm
HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"
[[ $? != 0 || ! $HOSTNAME ]] && return 1
if ! HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"; then
return 1
fi
tput civis
LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_ConfLocale " --menu "$_LocaleBody" 25 70 20 $LOCALES)"
[[ $? != 0 || ! $LOCALE ]] && return 1
# shellcheck disable=SC2153
if ! LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_ConfLocale " --menu "$_LocaleBody" 25 70 20 $LOCALES)"; then
return 1
fi
select_timezone || return 1
select_mirrorlist_command || return 1
@ -501,11 +513,11 @@ configure_system_settings() {
select_wm_or_de || return 1
tput civis
KERNEL="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_KernelTitle " --menu "$_KernelBody" 0 0 0 'linux' '-' 'linux-lts' '-')"
[[ $? != 0 || ! $KERNEL ]] && return 1
if ! KERNEL="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_KernelTitle " --menu "$_KernelBody" 0 0 0 'linux' '-' 'linux-lts' '-')"; then
return 1
fi
select_extra_packages || return 1
CONFIG_DONE=true
export CONFIG_DONE=true
return 0
}
@ -517,8 +529,8 @@ edit_system_configs() {
fi
tput civis
local exitstr="Exit"
[[ $DEBUG == true ]] && exitstr+=" & Reboot" || exitstr+=" & Reboot"
local exitstr
[[ $DEBUG == true ]] && exitstr="View Log & Shutdown" || exitstr="Exit & Reboot"
SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_EditTitle " --default-item $SELECTED --menu "$_EditBody" 0 0 0 \
@ -527,10 +539,11 @@ edit_system_configs() {
"9" "${BOOTLDR^}" "10" "Pacman.conf" "11" "${LOGIN_TYPE^}")
if [[ ! $SELECTED || $SELECTED -eq 1 ]]; then
[[ $DEBUG == true ]] && { more /tmp/debug-log; die 0; } || die 'systemctl -i reboot'
[[ $DEBUG == true ]] && { more /tmp/debug-log; die 'shutdown -h now'; }
die 'systemctl -i reboot'
else
local existing_files=""
for f in $(echo "${EDIT_FILES[$SELECTED]}"); do
for f in $(printf "%s" "${EDIT_FILES[$SELECTED]}"); do
[[ -e ${MNT}$f ]] && existing_files+=" ${MNT}$f"
done
if [[ ! $existing_files ]]; then
@ -598,7 +611,7 @@ done
# trap Ctrl-C to properly exit
trap sigint INT
for arg in $@; do case $arg in
for arg in "$@"; do case $arg in
--debug|-d) debug ;;
esac done