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

@ -16,21 +16,22 @@
- `vim` for editing files post install.
- `parted` for partition creation.
- `wipe` for the secure wipe.
- `awk` `sed` `grep` `uniq` `sort` `find` `ping` `mkfs` `lsblk` `curl`.
- `arch-chroot` to perform operations in a chroot.
- `chpasswd` to set root and user passwords.
- `openssl` to encrypt passwords.
- Basic Unix tools
- `awk` `sed` `grep` `uniq` `sort` `find` `ping` `mkfs` `lsblk` `curl`.
- Network connection is needed to install packages and update the system.
#### Manual Installation
- curl
```
sh -c "$(curl -fsSL https://bitbucket.org/archlabslinux/installer/raw/cfca6ca4d234f0a92c9d323fbeeb7214ce800fb0/install.sh)"
sh -c "$(curl -fsSL https://bitbucket.org/archlabslinux/installer/raw/master/install.sh)"
```
- wget
```
sh -c "$(wget https://bitbucket.org/archlabslinux/installer/raw/cfca6ca4d234f0a92c9d323fbeeb7214ce800fb0/install.sh -O -)"
sh -c "$(wget https://bitbucket.org/archlabslinux/installer/raw/master/install.sh -O -)"
```
- Packages for `pacman` can be found in our repos:

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

View File

@ -19,12 +19,12 @@ declare -Agr BMNTS=(
[BIOS-syslinux]="/boot" [UEFI-syslinux]="/boot"
)
declare -Agr BOOTLDRS=(
declare -Agrx BOOTLDRS=(
[BIOS]="grub ${BMNTS[BIOS-grub]} syslinux ${BMNTS[BIOS-syslinux]}"
[UEFI]="systemd-boot ${BMNTS[UEFI-systemd-boot]} grub ${BMNTS[UEFI-grub]} syslinux ${BMNTS[UEFI-syslinux]}"
)
declare -gA EDIT_FILES=(
declare -Agx EDIT_FILES=(
[2]="/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard /etc/vconsole.conf"
[3]="/etc/locale.conf /etc/default/locale"
[4]="/etc/hostname /etc/hosts"

View File

@ -140,7 +140,7 @@ create_user() {
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/etc/{group,gshadow,passwd,shadow}
if [[ -d $MNT/home/$NEWUSER ]]; then
rm -rf $MNT/home/$LIVE
rm -rf ${MNT:?}/home/$LIVE
else
# fix up some user files that reference the liveuser
sed -i "s/${LIVE}/${NEWUSER}/g" $MNT/home/$LIVE/.config/gtk-3.0/bookmarks \

View File

@ -6,10 +6,11 @@
# this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised
# shellcheck disable=2154
# set -n
declare -g LUKS=""
declare -g LUKS_DEV=""
declare -gx LUKS_DEV=""
declare -g LUKS_PART=""
declare -g LUKS_PASS=""
declare -g LUKS_UUID=""
@ -27,9 +28,9 @@ luks_open() {
infobox "$_LuksOpen" "${_OnlyOne}: $LUKS_PART\n" 1
else
tput civis
LUKS_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_LuksOpen " --menu "$_LuksMenuBody" 0 0 0 $PARTS)"
[[ $? != 0 || $LUKS_PART == "" ]] && return 1
if ! LUKS_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_LuksOpen " --menu "$_LuksMenuBody" 0 0 0 $PARTS)"; then
return 1
fi
fi
# get password and name for encryption
@ -52,13 +53,14 @@ luks_pass() {
tput cnorm
local values
values="$(dialog --stdout --separator '~' --ok-label "Submit" --backtitle "$BT" \
if ! values="$(dialog --stdout --separator '~' --ok-label "Submit" --backtitle "$BT" \
--title " $title " --insecure --mixedform "$_LuksOpenBody" 16 75 4 \
"$_Name" 1 1 "$name" 1 $((${#_Name} + 2)) 71 0 0 \
"$_Password" 2 1 "" 2 $((${#_Password} + 2)) 71 0 1 \
"$_Password2" 3 1 "" 3 $((${#_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
name="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
awk -F'~' '{print $1}')"
@ -99,9 +101,9 @@ luks_setup() {
infobox "$_LuksEncrypt" "${_OnlyOne}: $LUKS_PART\n" 1
else
tput civis
LUKS_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_LuksEncrypt " --menu "$_LuksEncryptBody" 0 0 0 $PARTS)"
[[ $? != 0 || $LUKS_PART == "" ]] && return 1
if ! LUKS_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_LuksEncrypt " --menu "$_LuksEncryptBody" 0 0 0 $PARTS)"; then
return 1
fi
fi
else
infobox "$_PrepMount" "\nUsing root partition created earlier: $ROOT_PART\n" 1
@ -132,8 +134,9 @@ luks_keycmd() {
if luks_setup; then
tput cnorm
local cipher
cipher="$(getinput "$_PrepLUKS" "$_LuksCipherKey" "-s 512 -c aes-xts-plain64")"
[[ $? != 0 || $cipher == "" ]] && return 1
if ! cipher="$(getinput "$_PrepLUKS" "$_LuksCipherKey" "-s 512 -c aes-xts-plain64")"; then
return 1
fi
infobox "$_LuksEncryptAdv" "$_LuksWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0

View File

@ -6,6 +6,7 @@
# this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised
# shellcheck disable=2154
# set -n
declare -g LVM=""
@ -42,17 +43,19 @@ lvm_show_vg() {
fi
tput civis
DEL_VG="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepLVM " --menu "$_LvmSelVGBody" 18 70 10 $VOL_GROUP_LIST)"
[[ $? != 0 || $DEL_VG == "" ]] && return 1
if ! DEL_VG="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PrepLVM " --menu "$_LvmSelVGBody" 18 70 10 $VOL_GROUP_LIST)"; then
return 1
fi
return 0
}
get_lv_size() {
tput cnorm
local ttl=" $_LvmCreateVG (LV:$VOL_COUNT) "
local msg="${VOLUME_GROUP}: ${GROUP_SIZE}$GROUP_SIZE_TYPE (${VOL_GROUP_MB}MB $_LvmLvSizeBody1).$_LvmLvSizeBody2"
VOLUME_SIZE="$(getinput "$ttl" "$msg" "")"
[[ $? != 0 || $VOLUME_SIZE == "" ]] && return 1
if ! VOLUME_SIZE="$(getinput "$ttl" "$msg" "")"; then
return 1
fi
ERR_SIZE=0
# if the size is empty or 0
@ -104,8 +107,9 @@ lvm_volume_name() {
tput cnorm
local name
name="$(getinput "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg" "$default")"
[[ $? != 0 || $name == "" ]] && return 1
if ! name="$(getinput "$_LvmCreateVG (LV:$VOL_COUNT)" "$msg" "$default")"; then
return 1
fi
# bad volume name answer or name already in use
if [[ ${name:0:1} == "/" || ${#name} -eq 0 || $name =~ \ |\' ]] || grep -q "$name" <<< "$(lsblk)"; then
@ -120,8 +124,9 @@ lvm_volume_name() {
lvm_group_name() {
tput cnorm
local group
group="$(getinput "$_LvmCreateVG" "$_LvmNameVgBody" "VolGroup")"
[[ $? != 0 || $group == "" ]] && return 1
if ! group="$(getinput "$_LvmCreateVG" "$_LvmNameVgBody" "VolGroup")"; then
return 1
fi
# bad answer or group name already taken
if [[ ${group:0:1} == "/" || ${#group} -eq 0 || $group =~ \ |\' ]] || grep -q "$group" <<< "$(lsblk)"; then
@ -151,11 +156,12 @@ lvm_extra_lvs() {
}
lvm_volume_count() {
VOL_COUNT=$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_LvmCreateVG " \
if ! VOL_COUNT=$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_LvmCreateVG " \
--radiolist "$_LvmLvNumBody1 $VOLUME_GROUP\n$_LvmLvNumBody2" 0 0 0 \
"1" "-" off "2" "-" off "3" "-" off "4" "-" off "5" "-" off \
"6" "-" off "7" "-" off "8" "-" off "9" "-" off)
[[ $? != 0 || $VOL_COUNT == "" ]] && return 1
"6" "-" off "7" "-" off "8" "-" off "9" "-" off); then
return 1
fi
return 0
}
@ -165,9 +171,9 @@ lvm_partitions() {
# choose partitions
tput civis
GROUP_PARTS="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_LvmCreateVG " --checklist "$_LvmPvSelBody" 0 0 0 $PARTS)"
[[ $? != 0 || $GROUP_PARTS == "" ]] && return 1
if ! GROUP_PARTS="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_LvmCreateVG " --checklist "$_LvmPvSelBody" 0 0 0 $PARTS)"; then
return 1
fi
return 0
}
@ -247,7 +253,7 @@ lvm_del_all() {
for i in $PHYSICAL_VOLUMES; do
pvremove -f "$i" >/dev/null 2>&1
done
LVM=' logical volume'
export LVM=' logical volume'
fi
return 0

View File

@ -6,10 +6,11 @@
# this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised
# shellcheck disable=2154,2153,2046
# set -n
readonly SYS_MEM="$(awk '/MemTotal/ {print int($2 / 1024)"M"}' /proc/meminfo)"
readonly SALT="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
readonly SALT="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 32 | head -n 1)"
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
readonly CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}')"
@ -28,7 +29,7 @@ mount_install_partitions() {
infobox "$_PrepMount" "\nUsing boot partition: $BOOT_PART\n" 1
elif [[ $SYS == "UEFI" ]]; then
select_efi_partition || { BOOT_PART=""; return 1; }
elif (( $COUNT > 0 )); then
elif (( COUNT > 0 )); then
select_boot_partition || { BOOT_PART=""; return 1; }
fi
@ -41,27 +42,28 @@ mount_install_partitions() {
unmount_install_partitions() {
swapoff -a
for i in $(mount | awk "/${MNT//\//\\/}/"' {print $3}' | sort -r); do
umount "$i" >/dev/null 2>&1
done
umount -R $MNT # >/dev/null 2>&1
}
select_swap() {
# Ask user to select partition or create swapfile
tput civis
SWAP_PART="$(dialog --backtitle "$BT" --cr-wrap --stdout --title " $_SelSwpSetup " \
--menu "$_SelSwpBody" 0 0 0 "$_SelSwpNone" "-" "$_SelSwpFile" "$SYS_MEM" $PARTS)"
[[ $? != 0 || $SWAP_PART == "$_SelSwpNone" ]] && { SWAP_PART=""; return 0; }
if ! SWAP_PART="$(dialog --backtitle "$BT" --cr-wrap --stdout --title " $_SelSwpSetup " \
--menu "$_SelSwpBody" 0 0 0 "$_SelSwpNone" "-" "$_SelSwpFile" "$SYS_MEM" $PARTS)" || [[ $SWAP_PART == "$_SelSwpNone" ]]; then
SWAP_PART=""; return 0
fi
if [[ $SWAP_PART == "$_SelSwpFile" ]]; then
tput cnorm
SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"
[[ $? != 0 || ! $SWAP_SIZE ]] && { SWAP_PART=""; SWAP_SIZE=""; return 0; }
if ! SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"; then
SWAP_PART=""; SWAP_SIZE=""; return 0
fi
while ! [[ ${SWAP_SIZE:0:1} =~ [1-9] && ${SWAP_SIZE: -1} =~ (M|G) ]]; do
msgbox "$_SelSwpSetup Error" "\n$_SelSwpErr $SWAP_SIZE\n"
SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"
[[ $? != 0 || ! $SWAP_SIZE ]] && { SWAP_PART=""; SWAP_SIZE=""; break; return 0; }
if ! SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"; then
SWAP_PART=""; SWAP_SIZE=""; break; return 0
fi
done
enable_swap "$MNT/swapfile"
@ -76,8 +78,9 @@ select_swap() {
select_mountpoint() {
tput cnorm
EXTRA_MNT="$(getinput "$_PrepMount $part" "$_ExtPartBody1 /home /var\n" "/")"
[[ $? != 0 || $EXTRA_MNT == "" ]] && return 1
if ! EXTRA_MNT="$(getinput "$_PrepMount $part" "$_ExtPartBody1 /home /var\n" "/")"; then
return 1
fi
# bad mountpoint
if [[ ${EXTRA_MNT:0:1} != "/" || ${#EXTRA_MNT} -le 1 || $EXTRA_MNT =~ \ |\' ]]; then
@ -90,9 +93,10 @@ select_mountpoint() {
select_boot_setup() {
# choose bootloader and mountpoint (if needed)
tput civis
BOOTLDR="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"
[[ $? != 0 || $BOOTLDR == "" ]] && return 1
if ! BOOTLDR="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_MntBootBody" 0 0 0 ${BOOTLDRS[$SYS]})"; then
return 1
fi
# grub on BIOS needs an install device, NOT partition eg. /dev/sda
if [[ $SYS == 'BIOS' && $BOOTLDR == 'grub' && $BOOT_DEVICE == "" ]]; then
@ -104,17 +108,18 @@ select_boot_setup() {
elif [[ $BOOTLDR == 'syslinux' ]]; then
if [[ $SYS == 'BIOS' ]]; then
FILES[9]="/boot/syslinux/syslinux.cfg"
BCMDS[$BOOTLDR]="$(dialog --cr-wrap --stdout --backtitle "$BT" \
if ! BCMDS[$BOOTLDR]="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_InstSysTitle " --menu "$_InstSysBody" 0 0 0 \
"syslinux-install_update -iam" "Install to MBR (Master Boot Record)" \
"syslinux-install_update -i" "Install to root partition (/)")"
[[ $? != 0 || ${BCMDS[$BOOTLDR]} == "" ]] && return 1
"syslinux-install_update -i" "Install to root partition (/)")"; then
return 1
fi
else
FILES[9]="/boot/EFI/syslinux/syslinux.cfg"
BCMDS[syslinux]="efibootmgr -c -d $BOOT_DEVICE -p $BOOT_PART_NUM -l /EFI/syslinux/syslinux.efi -L $DIST"
fi
else
FILES[9]="/etc/default/grub"
export FILES[9]="/etc/default/grub"
if [[ $SYS == 'UEFI' ]]; then
local ttype="i386-efi"
[[ $IS_64BIT == true ]] && ttype='x86_64-efi'
@ -122,7 +127,6 @@ select_boot_setup() {
else
BCMDS[grub]+=" --target=i386-pc $BOOT_DEVICE"
fi
BCMDS[grub]+=" && grub-mkconfig -o /boot/grub/grub.cfg"
fi
@ -131,7 +135,7 @@ select_boot_setup() {
setup_boot_device
mount_partition "$BOOT_PART" "${BMNTS[$SYS-$BOOTLDR]}" ||
{ src /usr/share/archlabs/installer/lib/boot.sh ; return 1; }
SEPERATE_BOOT=true
export SEPERATE_BOOT=true
fi
return 0
}
@ -140,16 +144,15 @@ select_mount_opts() {
local part="$1"
local fs="$2"
local title="${fs^} Mount Options"
local opts
opts="${FS_OPTS[$fs]}"
ssd "$part" && opts=$(sed 's/discard - off/discard - on/' <<< "$opts")
tput civis
if ssd "$part"; then
MNT_OPTS="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " --checklist \
"$_MntBody" 0 0 0 $(sed 's/discard - off/discard - on/' <<< "${FS_OPTS[$fs]}") | sed 's/ /,/g; $s/,$//')"
else
MNT_OPTS="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " \
--checklist "$_MntBody" 0 0 0 ${FS_OPTS[$fs]} | sed 's/ /,/g; $s/,$//')"
if ! MNT_OPTS="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $title " \
--checklist "$_MntBody" 0 0 0 $opts | sed 's/ /,/g; $s/,$//')"; then
return 1
fi
[[ $? != 0 || $MNT_OPTS == "" ]] && return 1
if ! yesno "$title" "$_MntConfBody $MNT_OPTS\n"; then
select_mount_opts "$part" "$fs" || return 1
@ -159,21 +162,21 @@ select_mount_opts() {
select_filesystem() {
local part="$1"
local cur_fs="$(lsblk -lno FSTYPE $part)"
local str="$([[ $cur_fs && $part != $ROOT_PART ]] && printf "\nExisting Filesystem: %s" "$cur_fs")"
local cur_fs str
cur_fs="$(lsblk -lno FSTYPE $part)"
str="$([[ $cur_fs && $part != "$ROOT_PART" ]] && printf "\nExisting Filesystem: %s" "$cur_fs")"
tput civis
local fs
fs="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_FSTitle: $part " \
--menu "\nSelect which filesystem you want to use for $part\n\nPartition Name: ${part}${str}$_FSBody" 0 0 0 \
$([[ $cur_fs && $part != $ROOT_PART ]] && printf "%s" "$_Skip -") \
$([[ $cur_fs && $part != "$ROOT_PART" ]] && printf "%s" "$_Skip -") \
"ext4" "${FS_CMDS[ext4]}" "ext3" "${FS_CMDS[ext3]}" \
"ext2" "${FS_CMDS[ext2]}" "vfat" "${FS_CMDS[vfat]}" \
"ntfs" "${FS_CMDS[ntfs]}" "f2fs" "${FS_CMDS[f2fs]}" \
"jfs" "${FS_CMDS[jfs]}" "nilfs2" "${FS_CMDS[nilfs2]}" \
"reiserfs" "${FS_CMDS[reiserfs]}" "xfs" "${FS_CMDS[xfs]}")"
[[ $fs == "$_Skip" ]] && return 0
[[ $fs == "" ]] && return 1
[[ $fs == "$_Skip" ]] && return 0 || { [[ $fs == "" ]] && return 1; }
if yesno "$_FSTitle" "\nFormat $part as $fs?\n"; then
format $part $fs
@ -189,9 +192,10 @@ select_efi_partition() {
BOOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
infobox "$_PrepMount" "$_OnlyOne for EFI: $BOOT_PART\n" 1
else
BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_SelUefiBody" 0 0 0 $PARTS)"
[[ $? != 0 || $BOOT_PART == "" ]] && return 1
if ! BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_SelUefiBody" 0 0 0 $PARTS)"; then
return 1
fi
fi
if grep -q 'fat' <<< "$(fsck -N "$BOOT_PART")"; then
@ -206,10 +210,8 @@ select_efi_partition() {
select_boot_partition() {
tput civis
BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_SelBiosBody" 0 0 0 "$_Skip" "-" $PARTS)"
if [[ $BOOT_PART == "$_Skip" || ! $BOOT_PART ]]; then
if ! BOOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PrepMount " \
--menu "$_SelBiosBody" 0 0 0 "$_Skip" "-" $PARTS)" || [[ $BOOT_PART == "$_Skip" ]]; then
BOOT_PART=""
else
if grep -q 'ext[34]' <<< "$(fsck -N "$BOOT_PART")"; then
@ -230,7 +232,7 @@ select_root_partition() {
decr_count "$LUKS_PART"
elif [[ $LVM ]]; then
[[ $LUKS ]] && decr_count "$LUKS_PART"
for part in $(echo "$GROUP_PARTS"); do decr_count "$part"; done
for part in $(printf "%s" "$GROUP_PARTS"); do decr_count "$part"; done
ROOT_PART=""
fi
@ -239,9 +241,10 @@ select_root_partition() {
infobox "$_PrepMount" "$_OnlyOne for root (/): $ROOT_PART\n" 1
elif [[ ! $ROOT_PART || $LVM ]]; then
tput civis
ROOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_SelRootBody" 0 0 0 $PARTS)"
[[ $? != 0 || $ROOT_PART == "" ]] && return 1
if ! ROOT_PART="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_SelRootBody" 0 0 0 $PARTS)"; then
return 1
fi
else
local msg="\nUsing${LUKS} root partition:" # $LUKS might just be an empty string
infobox "$_PrepMount" "$msg $ROOT_PART\n" 1
@ -256,9 +259,10 @@ select_extra_partitions() {
while (( COUNT > 0 )); do
tput civis
local part
part="$(dialog --cr-wrap --stdout --backtitle "$BT" \
--title " $_PrepMount " --menu "$_ExtPartBody" 0 0 0 "$_Done" "-" $PARTS)"
[[ $? != 0 || $part == "$_Done" || $part == "" ]] && break
if ! part="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PrepMount " \
--menu "$_ExtPartBody" 0 0 0 "$_Done" "-" $PARTS)" || [[ $part == "$_Done" ]]; then
break
fi
# choose what filesystem and get the mountpoint
select_filesystem "$part" || { break; return 1; }

View File

@ -6,6 +6,7 @@
# this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised
# shellcheck disable=2154,2153,2046
# set -n
declare -Agr FS_CMDS=(
@ -40,11 +41,12 @@ partition() {
tput civis
local choice
choice="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PartTitle " \
if ! choice="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_PartTitle " \
--menu "$_PartBody" 0 0 0 "$_PartShowTree" "-" "$_PartAuto" "-" \
$( ([[ $DISPLAY ]] && hash gparted >/dev/null 2>&1) && printf "gparted -") \
"cfdisk" "-" "parted" "-" "$_PartWipe" "-")"
[[ $? != 0 || $choice == "" ]] && return 1
$({ [[ $DISPLAY ]] && hash gparted >/dev/null 2>&1; } && printf "gparted -") \
"cfdisk" "-" "parted" "-" "$_PartWipe" "-")"; then
return 1
fi
tput civis
if [[ $choice != "$_PartWipe" && $choice != "$_PartAuto" && $choice != "$_PartShowTree" ]]; then
@ -109,9 +111,10 @@ select_device() {
infobox "$_DevSelTitle" "$msg $DEVICE\n" 1
elif (( DEV_COUNT > 1 )); then
tput civis
DEVICE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_DevSelTitle " \
--menu "${msg}$_DevSelBody" 0 0 0 $SYS_DEVS)"
[[ $? != 0 || $DEVICE == "" ]] && return 1
if ! DEVICE="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_DevSelTitle " \
--menu "${msg}$_DevSelBody" 0 0 0 $SYS_DEVS)"; then
return 1
fi
else
msg="\nNo available devices to use$([[ $1 == 'boot' ]] && printf " for bootloader")."
msgbox "$_ErrTitle" "$msg\n$_Exit"
@ -129,7 +132,7 @@ confirm_mount() {
local msg="Partition: $part\n"
[[ $mount == "$MNT" ]] && msg+="Mountpoint: / (root)" || msg+="Mountpoint: ${mount#$MNT}"
if [[ $(mount) =~ "$mount" ]]; then
if [[ $(mount) == *"$mount"* ]]; then
infobox "$_MntTitle" "$_MntSucc\n$msg\n" 1 && decr_count "$part"
else
infobox "$_MntTitle" "$_MntFail\n$msg\n" 1 && return 1
@ -140,7 +143,8 @@ confirm_mount() {
check_cryptlvm() {
local dev=""
local part="$1"
local devs="$(lsblk -lno NAME,FSTYPE,TYPE)"
local devs
devs="$(lsblk -lno NAME,FSTYPE,TYPE)"
# Identify if $part is "crypt" (LUKS on LVM, or LUKS alone)
if [[ $(lsblk -lno TYPE "$part") =~ 'crypt' ]]; then
@ -163,7 +167,7 @@ check_cryptlvm() {
done
elif [[ $(lsblk -lno TYPE "$part") =~ 'lvm' ]]; then
LVM=' logical volume'
export LVM=' logical volume'
VOLUME_NAME="${part#/dev/mapper/}"
for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do
@ -176,7 +180,7 @@ check_cryptlvm() {
if grep -q "$LUKS_NAME" <<< "$(lsblk -lno NAME "$dev")"; then
LUKS_UUID="$(lsblk -lno UUID,TYPE,FSTYPE "$dev" | awk '/part/ && /crypto_LUKS/ {print $1}')"
LUKS_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME"
LUKS=' encrypted'
export LUKS=' encrypted'
break
fi
done
@ -185,7 +189,8 @@ check_cryptlvm() {
auto_partition() {
local device="$1"
local size=$(lsblk -lno SIZE $device | awk 'NR == 1 {
local size
size=$(lsblk -lno SIZE $device | awk 'NR == 1 {
if ($1 ~ "G") {
sub(/G/, ""); print ($1 * 1000 - 512) / 1000"G"
} else {
@ -206,9 +211,11 @@ auto_partition() {
swapoff -a # in case the device was previously used for swap
local dev_info="$(parted -s $device print)"
local dev_info
dev_info="$(parted -s $device print)"
# walk the partitions on the device in reverse order and delete them
# shellcheck disable=2013
for i in $(awk '/^ [1-9][0-9]?/ {print $1}' <<< "$dev_info" | sort -r); do
parted -s $device rm $i >/dev/null 2>&1
done
@ -247,7 +254,8 @@ auto_partition() {
mount_partition() {
local part="$1"
local mountp="${MNT}$2"
local fs="$(lsblk -lno FSTYPE $part)"
local fs
fs="$(lsblk -lno FSTYPE $part)"
mkdir -p "$mountp"

View File

@ -6,6 +6,7 @@
# this file is not meant to be run directly
# sourcing this file in a non bash shell is not advised
# shellcheck disable=2154
# set -n
chrun() {
@ -29,8 +30,8 @@ ssd() {
die() {
tput cnorm
fuser -km $MNT # >/dev/null 2>&1
unmount_install_partitions
pgrep -f "$TERM_CMD -e tail" && pkill -f "$TERM_CMD -e tail"
[[ $1 =~ [0-9] ]] && exit $1 || $1
}
@ -53,10 +54,11 @@ oneshot() {
getinput() {
local answer
answer="$(dialog --cr-wrap --max-input 63 --stdout --no-cancel \
--backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")"
[[ $? != 0 || $answer == "" ]] && return 1
printf "$answer"
if ! answer="$(dialog --cr-wrap --max-input 63 --stdout --no-cancel \
--backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")" || [[ $answer == '' ]]; then
return 1
fi
printf "%s" "$answer"
}
infobox() {
@ -67,7 +69,7 @@ infobox() {
}
printq() {
local str="$@"
local str="$*"
if [[ ${#str} -gt $(( ${COLUMNS:-$(tput cols)} / 2 )) ]]; then
q=$(awk '{print int(NF / 4)}' <<< "$str")
str="$(awk '{
@ -102,7 +104,7 @@ devices() {
SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE | awk '/disk/ {print "/dev/" $1 " " $2}')"
fi
DEV_COUNT="$(wc -l <<< "$SYS_DEVS")"
declare -gr SYS_DEVS IGNORE_DEV DEV_COUNT
declare -grx SYS_DEVS IGNORE_DEV DEV_COUNT
}
sysid() {
@ -110,9 +112,9 @@ sysid() {
local efidir="/sys/firmware/efi"
if grep -q 'GenuineIntel' /proc/cpuinfo; then
declare -g UCODE="intel-ucode.img"
declare -gx UCODE="intel-ucode.img"
elif grep -q 'AuthenticAMD' /proc/cpuinfo; then
declare -g UCODE="amd-ucode.img"
declare -gx UCODE="amd-ucode.img"
fi
if grep -qi 'apple' /sys/class/dmi/id/sys_vendor; then
@ -123,7 +125,7 @@ sysid() {
if [[ -d $efidir ]]; then
SYS="UEFI"
[[ $(cat $efidir/fw_platform_size) == 64 ]] && IS_64BIT=true
[[ $(cat $efidir/fw_platform_size) == 64 ]] && export IS_64BIT=true
grep -q $efidir/efivars <<< "$(mount)" || mount -t efivarfs efivarfs $efidir/efivars
else
SYS="BIOS"
@ -149,7 +151,8 @@ checks() {
echeck() {
# return if the last process exited normally
(( $? == 0 )) && return 0
local last_exit_code=$?
(( last_exit_code == 0 )) && return 0
local msg="\nThe command exited abnormally: $1"
# get error message from logfile and strip any non-printable characters,
@ -169,8 +172,8 @@ echeck() {
}
icheck() {
[[ $(lsblk -o MOUNTPOINT) =~ $MNT ]] || { msgbox "$_ErrTitle" "$_ErrNoMount"; SELECTED=4; return 1; }
[[ $CONFIG_DONE == true ]] || { msgbox "$_ErrTitle" "$_ErrNoConfig"; SELECTED=5; return 1; }
[[ $(lsblk -o MOUNTPOINT) =~ $MNT ]] || { msgbox "$_ErrTitle" "$_ErrNoMount"; export SELECTED=4; return 1; }
[[ $CONFIG_DONE == true ]] || { msgbox "$_ErrTitle" "$_ErrNoConfig"; export SELECTED=5; return 1; }
return 0
}
@ -200,5 +203,5 @@ debug() {
xterm -e "tail -f /tmp/debug-log" &
fi
fi
DEBUG=true
export DEBUG=true
}