Change LUKS and LVM to strings
This commit is contained in:
parent
0c1b09ab7e
commit
2bb960f486
@ -113,6 +113,9 @@ _DevSelBody="\nSelect a device from the list below.\n\nDevices (/dev) are the av
|
||||
_ExtPartBody="\nYou can now select additional partitions you want mounted, once choosen you will be asked to enter a mountpoint.\n\nSelect '$_Done' to finish the mounting step and return to the main menu."
|
||||
_ExtPartBody1="\nWhere do you want the partition mounted?\n\nEnsure the name begins with a forward slash (/).\nSome examples include:"
|
||||
|
||||
# kernel
|
||||
_KernelTitle="Choose Kernel"
|
||||
_KernelBody="\nKeep the default linux kernel or switch to the LTS kernel?\n"
|
||||
|
||||
# Partitioning Menu
|
||||
_PartTitle="Partitioning Tool"
|
||||
|
@ -12,7 +12,7 @@
|
||||
# immutable {
|
||||
|
||||
readonly DIST="ArchLabs" # Linux distributor
|
||||
readonly VER="1.7.2" # Installer version
|
||||
readonly VER="1.7.5" # Installer version
|
||||
readonly LIVE="liveuser" # Live session user
|
||||
readonly MNT="/mnt/install" # Install mountpoint
|
||||
readonly ERR="/tmp/errlog" # Built-in error log
|
||||
@ -24,7 +24,7 @@ readonly VM="$(dmesg | grep -i "hypervisor")"
|
||||
readonly SALT="$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
|
||||
readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)"M"}')
|
||||
readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)"
|
||||
readonly CONSOLE_MAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}')"
|
||||
readonly CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}')"
|
||||
|
||||
if grep -q 'GenuineIntel' /proc/cpuinfo; then
|
||||
readonly UCODE="intel-ucode.img"
|
||||
@ -59,6 +59,8 @@ epo Esperanto np Nepali et Amharic sn Wolof ml Bambara tz Swahili ke Swahili bw
|
||||
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"
|
||||
|
||||
readonly KERNELS="linux - linux-lts -"
|
||||
|
||||
declare -Agr BMNTS=(
|
||||
[UEFI-grub]="/boot/efi" [UEFI-systemd-boot]="/boot" [BIOS-grub]="/boot"
|
||||
[BIOS-syslinux]="/boot" [UEFI-syslinux]="/boot"
|
||||
@ -94,7 +96,7 @@ init() {
|
||||
declare -g BOOTLDR=""
|
||||
declare -g EXTRA_MNT=""
|
||||
declare -g EXTRA_MNTS=""
|
||||
declare -g SWAP="none"
|
||||
declare -g SWAP=""
|
||||
declare -g SWAP_SIZE="$SYS_MEM"
|
||||
declare -g NEWUSER=""
|
||||
declare -g USER_PASS=""
|
||||
@ -243,18 +245,18 @@ keymap() {
|
||||
[[ $? != 0 || $KEYMAP == "" ]] && return 1
|
||||
|
||||
# when a matching console map is not available open a selection dialog
|
||||
if ! [[ $CONSOLE_MAPS =~ "$KEYMAP -" ]]; then
|
||||
CONSOLE_MAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CONSOLE_MAPS)"
|
||||
[[ $? != 0 || $CONSOLE_MAP == "" ]] && return 1
|
||||
if [[ $CMAPS =~ "$KEYMAP -" ]]; then
|
||||
CMAP="$KEYMAP"
|
||||
else
|
||||
CONSOLE_MAP="$KEYMAP"
|
||||
CMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CMAPS)"
|
||||
[[ $? != 0 || $CMAP == "" ]] && return 1
|
||||
fi
|
||||
|
||||
if [[ $DISPLAY && $TERM != 'linux' ]]; then
|
||||
hash setxkbmap >/dev/null 2>&1 && setxkbmap $KEYMAP >/dev/null 2>&1
|
||||
setxkbmap $KEYMAP >/dev/null 2>&1
|
||||
else
|
||||
hash loadkeys >/dev/null 2>&1 && loadkeys $CONSOLE_MAP >/dev/null 2>&1
|
||||
loadkeys $CMAP >/dev/null 2>&1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
@ -438,7 +440,7 @@ packages() {
|
||||
([[ $INSTALL_WMS =~ dwm ]] && ! [[ $pkgs =~ ttf-hack ]]) && pkgs+=" ttf-hack"
|
||||
([[ $pkgs =~ (qutebrowser|qbittorrent|kdenlive|vlc) ]] && ! [[ $pkgs =~ qt5ct ]]) && pkgs+=" qt5ct qt5-styleplugins"
|
||||
|
||||
EXTRA_PACKAGES+="$pkgs"
|
||||
EXTRA_PACKAGES+=" $pkgs"
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -482,51 +484,59 @@ mirrors() {
|
||||
}
|
||||
|
||||
display() {
|
||||
msgbox "$_PrepTitle" "\nConfiguration values used for install\n\n
|
||||
Root: $ROOT_PART
|
||||
Boot: $BOOT_PART
|
||||
Swap: $SWAP
|
||||
local cmd mnt
|
||||
cmd="${BCMDS[$BOOTLDR]}"
|
||||
mnt="${BMNTS[$SYS-$BOOTLDR]}"
|
||||
msgbox "$_PrepTitle" "\nConfiguration values for the current install\n\n
|
||||
Root: ${ROOT_PART:-None}
|
||||
Boot: ${BOOT_PART:-None}
|
||||
Swap: ${SWAP:-None}
|
||||
|
||||
Extra: ${EXTRA_MNTS:-None}
|
||||
Hooks: ${MKINIT_HOOKS:-None}
|
||||
|
||||
LVM: $LVM
|
||||
LUKS: $LUKS
|
||||
LVM: ${LVM:-None}
|
||||
LUKS: ${LUKS:-None}
|
||||
|
||||
Bootloader: $BOOTLDR
|
||||
Boot Mount: ${BMNTS[$SYS-$BOOTLDR]}
|
||||
Boot Command: ${BCMDS[$BOOTLDR]}
|
||||
Bootloader: ${BOOTLDR:-None}
|
||||
Boot Mount: ${mnt:-None}
|
||||
Boot Command: ${cmd:-None}
|
||||
|
||||
User: $NEWUSER
|
||||
Hostname: $HOSTNAME
|
||||
Locale: $LOCALE
|
||||
Keymap: $KEYMAP
|
||||
Timezone: $ZONE/$SUBZONE
|
||||
User: ${NEWUSER:-None}
|
||||
Hostname: ${HOSTNAME:-None}
|
||||
Locale: ${LOCALE:-None}
|
||||
Keymap: ${KEYMAP:-None}
|
||||
Timezone: ${ZONE:-None}/${SUBZONE:-None}
|
||||
|
||||
Autologin: $AUTOLOGIN
|
||||
Login: $LOGIN_WM
|
||||
Login Type: $LOGIN_TYPE
|
||||
Autologin: ${AUTOLOGIN:-None}
|
||||
Login: ${LOGIN_WM:-None}
|
||||
Login Type: ${LOGIN_TYPE:-None}
|
||||
|
||||
Sessions: $INSTALL_WMS
|
||||
Kernel: $KERNEL
|
||||
Mirrors: $MIRROR_CMD
|
||||
Packages: $EXTRA_PACKAGES\n"
|
||||
Sessions: ${INSTALL_WMS:-None}
|
||||
Kernel: ${KERNEL:-None}
|
||||
Mirrors: ${MIRROR_CMD:-None}
|
||||
Packages: ${EXTRA_PACKAGES:-None}\n"
|
||||
}
|
||||
|
||||
configure() {
|
||||
tput cnorm
|
||||
HOSTNAME="$(getinput "$_ConfHost" "$_HostNameBody" "${DIST,,}")"
|
||||
[[ $? != 0 || $HOSTNAME == "" ]] && return 1
|
||||
[[ $? != 0 || ! $HOSTNAME ]] && return 1
|
||||
|
||||
tput civis
|
||||
LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_ConfLocale " --menu "$_LocaleBody" 25 70 20 $LOCALES)"
|
||||
[[ $? != 0 || $LOCALE == "" ]] && return 1
|
||||
[[ $? != 0 || ! $LOCALE ]] && return 1
|
||||
|
||||
timezone || return 1
|
||||
mirrors || return 1
|
||||
user || return 1
|
||||
sessions || return 1
|
||||
yesno 'Choose Kernel' "\nUse the current kernel or the LTS kernel?\n" 'Current' 'LTS' &&
|
||||
KERNEL='linux' || KERNEL='linux-lts'
|
||||
|
||||
tput civis
|
||||
KERNEL="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_KernelTitle " --menu "$_KernelBody" 0 0 0 $KERNELS)"
|
||||
[[ $? != 0 || ! $KERNEL ]] && return 1
|
||||
packages || return 1
|
||||
CONFIG_DONE=true
|
||||
return 0
|
||||
@ -540,14 +550,17 @@ configs() {
|
||||
fi
|
||||
|
||||
tput civis
|
||||
local exitstr="Exit"
|
||||
[[ $DEBUG != true ]] && exitstr+=" & Reboot"
|
||||
|
||||
SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_EditTitle " --default-item $SELECTED --menu "$_EditBody" 0 0 0 \
|
||||
"1" "Exit & Reboot" "2" "Keyboard" "3" "Locale" "4" "Hostname" "5" "Sudoers" \
|
||||
"1" "$exitstr" "2" "Keyboard" "3" "Locale" "4" "Hostname" "5" "Sudoers" \
|
||||
"6" "Mkinitcpio.conf" "7" "Fstab" "8" "Crypttab" "9" "${BOOTLDR^}" "10" "Pacman.conf" \
|
||||
"11" "${LOGIN_TYPE^}")
|
||||
|
||||
if [[ ! $SELECTED || $SELECTED -eq 1 ]]; then
|
||||
die 'reboot'
|
||||
[[ $DEBUG == true ]] && die 0 || die 'reboot'
|
||||
else
|
||||
local existing_files=""
|
||||
for f in $(echo "${FILES[$SELECTED]}"); do
|
||||
|
@ -12,11 +12,11 @@ prep_for_grub() {
|
||||
local cfg="$MNT/etc/default/grub"
|
||||
sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DIST}\"/g;
|
||||
s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/g" $cfg
|
||||
if [[ $LUKS -eq 1 ]]; then
|
||||
if [[ $LUKS_DEV ]]; then
|
||||
sed -i "s~#GRUB_ENABLE_CRYPTODISK~GRUB_ENABLE_CRYPTODISK~g;
|
||||
s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"${LUKS_DEV}\"~g" $cfg
|
||||
fi
|
||||
if [[ $SYS == 'BIOS' && $LVM -eq 1 && $SEPERATE_BOOT == false ]]; then
|
||||
if [[ $SYS == 'BIOS' && $LVM && $SEPERATE_BOOT == false ]]; then
|
||||
sed -i "s/GRUB_PRELOAD_MODULES=.*/GRUB_PRELOAD_MODULES=\"lvm\"/g" $cfg
|
||||
fi
|
||||
return 0
|
||||
@ -124,8 +124,7 @@ uefi_boot_fallback() {
|
||||
# also: https://wiki.archlinux.org/index.php/syslinux#UEFI_Systems
|
||||
|
||||
local esp="${MNT}${BMNTS[$SYS-$BOOTLDR]}"
|
||||
|
||||
local default="boot"
|
||||
local default="Boot"
|
||||
default="$(find $esp/EFI/ -maxdepth 1 -mindepth 1 -name '[Bb][oO][oO][tT]' -type d)"
|
||||
[[ $default ]] && default="$(basename $default)"
|
||||
|
||||
|
@ -17,7 +17,7 @@ install() {
|
||||
oneshot install_base
|
||||
|
||||
# generate /etc/fstab and touch it up if we used a swapfile
|
||||
genfstab -U $MNT > $MNT/etc/fstab # 2>$ERR
|
||||
genfstab -U $MNT > $MNT/etc/fstab 2>$ERR
|
||||
echeck "genfstab -U $MNT > $MNT/etc/fstab"
|
||||
[[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab
|
||||
|
||||
@ -112,7 +112,7 @@ BACKSPACE="guess"
|
||||
EOF
|
||||
# console keymap
|
||||
cat > $MNT/etc/vconsole.conf <<EOF
|
||||
KEYMAP=$CONSOLE_MAP
|
||||
KEYMAP=$CMAP
|
||||
FONT=$FONT
|
||||
EOF
|
||||
# set the hostname
|
||||
@ -206,14 +206,14 @@ EOF
|
||||
run_mkinitcpio() {
|
||||
local add=""
|
||||
# setup a keyfile for LUKS.. Only when choosing grub and system is UEFI
|
||||
[[ $LUKS -eq 1 && $LVM -eq 0 && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]] && luks_keyfile
|
||||
[[ $LUKS && ! $LVM && $SYS == 'UEFI' && $BOOTLDR == 'grub' ]] && luks_keyfile
|
||||
|
||||
# new hooks needed in /etc/mkinitcpio.conf if we used LUKS and/or LVM
|
||||
(( LVM == 1 )) && add="lvm2"
|
||||
(( LUKS == 1 )) && add="encrypt$([[ $add ]] && printf " %s" "$add")"
|
||||
[[ $LVM ]] && add="lvm2"
|
||||
[[ $LUKS ]] && add="encrypt$([[ $add ]] && printf " %s" "$add")"
|
||||
sed -i "s/block filesystems/block ${add} filesystems ${MKINIT_HOOKS}/g" $MNT/etc/mkinitcpio.conf
|
||||
|
||||
chrun "mkinitcpio -p $KERNEL" # 2>$ERR
|
||||
chrun "mkinitcpio -p $KERNEL" 2>$ERR
|
||||
echeck "mkinitcpio -p $KERNEL"
|
||||
}
|
||||
|
||||
@ -239,21 +239,12 @@ package_operations() {
|
||||
rmpkg+=" virtualbox-guest-modules-arch linux"
|
||||
inpkg+=" linux-lts"
|
||||
# if the system is a VM then install the needed packages otherwise remove the guest utils
|
||||
if [[ $VM ]]; then
|
||||
inpkg+=" virtualbox-guest-dkms linux-lts-headers"
|
||||
else
|
||||
rmpkg+=" virtualbox-guest-utils"
|
||||
fi
|
||||
[[ $VM ]] && inpkg+=" virtualbox-guest-dkms linux-lts-headers" || rmpkg+=" virtualbox-guest-utils"
|
||||
else
|
||||
# if the system is not a VM then remove the guest utils
|
||||
if ! [[ $VM ]]; then
|
||||
rmpkg+=" virtualbox-guest-modules-arch virtualbox-guest-utils"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $UCODE == 'amd-ucode.img' ]]; then
|
||||
inpkg+=" amd-ucode"
|
||||
[[ $VM ]] || rmpkg+=" virtualbox-guest-modules-arch virtualbox-guest-utils"
|
||||
fi
|
||||
[[ $UCODE == 'amd-ucode.img' ]] && inpkg+=" amd-ucode"
|
||||
|
||||
# for only gnome or cinnamon we don't need the xfce provided stuff
|
||||
[[ $INSTALL_WMS =~ (gnome|cinnamon) ]] && rmpkg+=" $(pacman -Qssq 'xfce4*' 2>/dev/null)"
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
# set -n
|
||||
|
||||
declare -g LUKS=0
|
||||
declare -g LUKS=""
|
||||
declare -g LUKS_DEV=""
|
||||
declare -g LUKS_PART=""
|
||||
declare -g LUKS_PASS=""
|
||||
@ -36,10 +36,10 @@ luks_open() {
|
||||
luks_pass "$_LuksOpen" "$LUKS_NAME" || return 1
|
||||
|
||||
infobox "$_LuksOpen" "$_LuksWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
|
||||
cryptsetup open --type luks $LUKS_PART "$LUKS_NAME" <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" # 2>$ERR
|
||||
cryptsetup open --type luks $LUKS_PART "$LUKS_NAME" <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" 2>$ERR
|
||||
echeck "cryptsetup open --type luks $LUKS_PART $LUKS_NAME"
|
||||
|
||||
LUKS=1
|
||||
LUKS=' encrypted'
|
||||
luks_show
|
||||
return 0
|
||||
}
|
||||
@ -90,7 +90,7 @@ luks_setup() {
|
||||
modprobe -a dm-mod dm_crypt
|
||||
unmountp
|
||||
|
||||
if [[ $ROOT_PART == "" || $LVM -eq 1 ]]; then
|
||||
if [[ ! $ROOT_PART || $LVM ]]; then
|
||||
find_partitions 'part|lvm' || return 1
|
||||
[[ $BOOT_PART != "" ]] && decr_count "$BOOT_PART"
|
||||
|
||||
@ -117,13 +117,13 @@ luks_default() {
|
||||
luks_setup || return 1
|
||||
infobox "$_LuksEncrypt" "$_LuksWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
|
||||
|
||||
cryptsetup -q luksFormat $LUKS_PART <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" # 2>$ERR
|
||||
cryptsetup -q luksFormat $LUKS_PART <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" 2>$ERR
|
||||
echeck "cryptsetup -q luksFormat $LUKS_PART"
|
||||
|
||||
cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" # 2>$ERR
|
||||
cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" 2>$ERR
|
||||
echeck "cryptsetup open $LUKS_PART $LUKS_NAME"
|
||||
|
||||
LUKS=1
|
||||
LUKS=' encrypted'
|
||||
luks_show
|
||||
return 0
|
||||
}
|
||||
@ -137,10 +137,10 @@ luks_keycmd() {
|
||||
|
||||
infobox "$_LuksEncryptAdv" "$_LuksWaitBody $LUKS_NAME $_LuksWaitBody2 $LUKS_PART\n" 0
|
||||
|
||||
cryptsetup -q $cipher luksFormat $LUKS_PART <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" # 2>$ERR
|
||||
cryptsetup -q $cipher luksFormat $LUKS_PART <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" 2>$ERR
|
||||
echeck "cryptsetup -q $cipher luksFormat $LUKS_PART"
|
||||
|
||||
cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" # 2>$ERR
|
||||
cryptsetup open $LUKS_PART "$LUKS_NAME" <<< "$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")" 2>$ERR
|
||||
echeck "cryptsetup open $LUKS_PART $LUKS_NAME"
|
||||
|
||||
luks_show
|
||||
@ -192,7 +192,7 @@ luks_keyfile() {
|
||||
mkkey="$mkkey && cryptsetup luksAddKey /dev/$n /crypto_keyfile.bin <<< '$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$LUKS_PASS")'"
|
||||
|
||||
chrun "$mkkey"
|
||||
sed -i 's/FILES=()/FILES=(\/crypto_keyfile.bin)/g' $MNT/etc/mkinitcpio.conf # 2>$ERR
|
||||
sed -i 's/FILES=()/FILES=(\/crypto_keyfile.bin)/g' $MNT/etc/mkinitcpio.conf 2>$ERR
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
# set -n
|
||||
|
||||
declare -g LVM=0
|
||||
declare -g LVM=""
|
||||
declare -g VOL_GROUP_MB=0
|
||||
declare -g GROUP_PARTS=0
|
||||
|
||||
@ -140,7 +140,7 @@ lvm_extra_lvs() {
|
||||
get_lv_size || { break; return 1; }
|
||||
|
||||
# create it
|
||||
lvcreate -L "$VOLUME_SIZE" "$VOLUME_GROUP" -n "$VOLUME_NAME" # 2>$ERR
|
||||
lvcreate -L "$VOLUME_SIZE" "$VOLUME_GROUP" -n "$VOLUME_NAME" 2>$ERR
|
||||
echeck "lvcreate -L $VOLUME_SIZE $VOLUME_GROUP -n $VOLUME_NAME"
|
||||
msgbox "$_LvmCreateVG (LV:$VOL_COUNT)" "$_Done LV $VOLUME_NAME ($VOLUME_SIZE) $_LvmPvDoneBody2."
|
||||
|
||||
@ -184,7 +184,7 @@ lvm_create_group() {
|
||||
|
||||
# create it
|
||||
infobox "$_LvmCreateVG" "$_LvmPvActBody1 $VOLUME_GROUP\n" 0
|
||||
vgcreate -f "$VOLUME_GROUP" "$GROUP_PARTS" >/dev/null # 2>$ERR
|
||||
vgcreate -f "$VOLUME_GROUP" "$GROUP_PARTS" >/dev/null 2>$ERR
|
||||
echeck "vgcreate -f $VOLUME_GROUP $GROUP_PARTS"
|
||||
|
||||
# get volume size size and transform size to MB if size is given in GB
|
||||
@ -204,7 +204,7 @@ lvm_create() {
|
||||
VOL_GROUP_MB=0
|
||||
unmountp
|
||||
|
||||
if [[ $LUKS -eq 1 && $LUKS_NAME != "" ]]; then
|
||||
if [[ $LUKS && $LUKS_NAME ]]; then
|
||||
GROUP_PARTS="/dev/mapper/$LUKS_NAME"
|
||||
infobox "$_LvmCreateVG" "\nUsing encrypted partition created earlier: $GROUP_PARTS\n" 1
|
||||
else
|
||||
@ -217,11 +217,10 @@ lvm_create() {
|
||||
|
||||
# last or only logical volume
|
||||
lvm_volume_name "$_LvmLvNameBody1 $_LvmLvNameBody2 (${VOL_GROUP_MB}MB)" || return 1
|
||||
lvcreate -l +100%FREE "$VOLUME_GROUP" -n "$VOLUME_NAME" # 2>$ERR
|
||||
lvcreate -l +100%FREE "$VOLUME_GROUP" -n "$VOLUME_NAME" 2>$ERR
|
||||
echeck "lvcreate -l +100%FREE $VOLUME_GROUP -n $VOLUME_NAME"
|
||||
|
||||
LVM=1
|
||||
|
||||
LVM=' logical volume'
|
||||
show_devices
|
||||
return 0
|
||||
}
|
||||
@ -248,7 +247,7 @@ lvm_del_all() {
|
||||
for i in $PHYSICAL_VOLUMES; do
|
||||
pvremove -f "$i" >/dev/null 2>&1
|
||||
done
|
||||
LVM=0
|
||||
LVM=' logical volume'
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
@ -8,10 +8,6 @@
|
||||
|
||||
# set -n
|
||||
|
||||
########################################################
|
||||
## Partition functions ##
|
||||
########################################################
|
||||
|
||||
format() {
|
||||
infobox "$_FSTitle" "\nFormatting: $1\n\nCommand: ${FS_CMDS[$2]}\n" 0
|
||||
${FS_CMDS[$2]} $1 >/dev/null 2>$ERR
|
||||
@ -62,14 +58,14 @@ decr_count() {
|
||||
|
||||
enable_swap() {
|
||||
if [[ $1 == "$MNT/swapfile" ]]; then
|
||||
fallocate -l $SWAP_SIZE $1 # 2>$ERR
|
||||
fallocate -l $SWAP_SIZE $1 2>$ERR
|
||||
echeck "fallocate -l $SWAP_SIZE $1"
|
||||
chmod 600 $1 # 2>$ERR
|
||||
chmod 600 $1 2>$ERR
|
||||
echeck "chmod 600 $1"
|
||||
fi
|
||||
mkswap $1 >/dev/null # 2>$ERR
|
||||
mkswap $1 >/dev/null 2>$ERR
|
||||
echeck "mkswap $1"
|
||||
swapon $1 >/dev/null # 2>$ERR
|
||||
swapon $1 >/dev/null 2>$ERR
|
||||
echeck "swapon $1"
|
||||
return 0
|
||||
}
|
||||
@ -116,34 +112,31 @@ select_device() {
|
||||
confirm_mount() {
|
||||
local part="$1"
|
||||
local mount="$2"
|
||||
|
||||
local msg="Partition: $part\n"
|
||||
[[ $mount == "$MNT" ]] && msg+="Mountpoint: / (root)" || msg+="Mountpoint: ${mount#$MNT}"
|
||||
|
||||
if [[ $(mount) =~ "$mount" ]]; then
|
||||
infobox "$_MntTitle" "$_MntSucc\n$msg\n" 1
|
||||
decr_count "$part"
|
||||
infobox "$_MntTitle" "$_MntSucc\n$msg\n" 1 && decr_count "$part"
|
||||
else
|
||||
infobox "$_MntTitle" "$_MntFail\n$msg\n" 1
|
||||
return 1
|
||||
infobox "$_MntTitle" "$_MntFail\n$msg\n" 1 && return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_cryptlvm() {
|
||||
local part="$1"
|
||||
local dev=""
|
||||
local part="$1"
|
||||
local devs="$(lsblk -lno NAME,FSTYPE,TYPE)"
|
||||
|
||||
# Identify if $part is "crypt" (LUKS on LVM, or LUKS alone)
|
||||
if [[ $(lsblk -lno TYPE "$part") =~ 'crypt' ]]; then
|
||||
LUKS=1
|
||||
LUKS=' encrypted'
|
||||
LUKS_NAME="${part#/dev/mapper/}"
|
||||
|
||||
for dev in $(awk '/lvm/ && /crypto_LUKS/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do
|
||||
if grep -q "$LUKS_NAME" <<< "$(lsblk -lno NAME "$dev")"; then
|
||||
LUKS_DEV="$LUKS_DEV cryptdevice=$dev:$LUKS_NAME"
|
||||
LVM=1
|
||||
LVM=' logical volume'
|
||||
break
|
||||
fi
|
||||
done
|
||||
@ -156,7 +149,7 @@ check_cryptlvm() {
|
||||
done
|
||||
|
||||
elif [[ $(lsblk -lno TYPE "$part") =~ 'lvm' ]]; then
|
||||
LVM=1
|
||||
LVM=' logical volume'
|
||||
VOLUME_NAME="${part#/dev/mapper/}"
|
||||
|
||||
for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do
|
||||
@ -169,7 +162,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=1
|
||||
LUKS=' encrypted'
|
||||
break
|
||||
fi
|
||||
done
|
||||
@ -187,7 +180,16 @@ auto_partition() {
|
||||
|
||||
# confirm or bail
|
||||
yesno "$_PrepParts" "$_PartBody1 $device $_PartBody2 ($size)$_PartBody3" || return 0
|
||||
infobox "$_PrepParts" "\nAuto partitioning device: $device\n" 0
|
||||
|
||||
local newtable format
|
||||
if [[ $SYS == BIOS ]]; then
|
||||
newtable="msdos"; format="ext4"
|
||||
else
|
||||
newtable="gpt"; format="fat32"
|
||||
fi
|
||||
|
||||
infobox "$_PrepParts" "\nRemoving existing partitions on $device and setting partition table to $newtable\n" 0
|
||||
|
||||
swapoff -a # in case the device was previously used for swap
|
||||
local dev_info="$(parted -s $device print)"
|
||||
|
||||
@ -196,16 +198,15 @@ auto_partition() {
|
||||
parted -s $device rm $i >/dev/null 2>&1
|
||||
done
|
||||
|
||||
local newtable
|
||||
[[ $SYS == BIOS ]] && newtable="msdos" || newtable="gpt"
|
||||
if [[ $(awk '/Table:/ {print $3}' <<< "$dev_info") != "$newtable" ]]; then
|
||||
parted -s $device mklabel $newtable >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
infobox "$_PrepParts" "\nCreating a 512M $format boot partition.\n" 0
|
||||
if [[ $SYS == "BIOS" ]]; then
|
||||
parted -s $device mkpart primary ext4 1MiB 513MiB >/dev/null 2>&1
|
||||
parted -s $device mkpart primary $format 1MiB 513MiB >/dev/null 2>&1
|
||||
else
|
||||
parted -s $device mkpart ESP fat32 1MiB 513MiB >/dev/null 2>&1
|
||||
parted -s $device mkpart ESP $format 1MiB 513MiB >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
sleep 0.1
|
||||
@ -218,6 +219,7 @@ auto_partition() {
|
||||
mkfs.vfat -F32 $BOOT_PART >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
infobox "$_PrepParts" "\nCreating a $size ext4 root partition.\n" 0
|
||||
parted -s $device mkpart primary ext4 513MiB 100% >/dev/null 2>&1
|
||||
sleep 0.1
|
||||
ROOT_PART=$(lsblk -lno NAME,TYPE $device | awk 'NR == 3 {print "/dev/"$1}')
|
||||
@ -229,20 +231,20 @@ auto_partition() {
|
||||
|
||||
mount_partition() {
|
||||
local part="$1"
|
||||
local mount="${MNT}$2"
|
||||
local mountp="${MNT}$2"
|
||||
local fs="$(lsblk -lno FSTYPE $part)"
|
||||
|
||||
mkdir -p "$mount"
|
||||
mkdir -p "$mountp"
|
||||
|
||||
if [[ ${FS_OPTS[$fs]} != "" && $part != "$BOOT_PART" ]] && select_mount_opts "$part" "$fs"; then
|
||||
mount -o $MNT_OPTS $part "$mount" # 2>$ERR
|
||||
echeck "mount -o $MNT_OPTS $part $mount"
|
||||
mount -o $MNT_OPTS $part "$mountp" 2>$ERR
|
||||
echeck "mount -o $MNT_OPTS $part $mountp"
|
||||
else
|
||||
mount $part "$mount" # 2>$ERR
|
||||
echeck "mount $part $mount"
|
||||
mount $part "$mountp" 2>$ERR
|
||||
echeck "mount $part $mountp"
|
||||
fi
|
||||
|
||||
confirm_mount $part "$mount" || return 1
|
||||
confirm_mount $part "$mountp" || return 1
|
||||
check_cryptlvm "$part"
|
||||
return 0
|
||||
}
|
||||
@ -292,10 +294,6 @@ setup_boot_device() {
|
||||
return 0
|
||||
}
|
||||
|
||||
########################################################
|
||||
## Mount functions ##
|
||||
########################################################
|
||||
|
||||
mountp() {
|
||||
# prepare partition list PARTS for dialog
|
||||
lvm_detect
|
||||
@ -334,7 +332,7 @@ mountp() {
|
||||
unmountp() {
|
||||
swapoff -a
|
||||
for i in $(mount | awk "/${MNT//\//\\/}/"' {print $3}' | sort -r); do
|
||||
umount -r "$i" >/dev/null 2>&1
|
||||
umount "$i" >/dev/null 2>&1
|
||||
done
|
||||
}
|
||||
|
||||
@ -343,17 +341,17 @@ select_swap() {
|
||||
tput civis
|
||||
SWAP="$(dialog --backtitle "$BT" --cr-wrap --stdout --title " $_SelSwpSetup " \
|
||||
--menu "$_SelSwpBody" 0 0 0 "$_SelSwpNone" "-" "$_SelSwpFile" "$SYS_MEM" $PARTS)"
|
||||
[[ $? != 0 || $SWAP == "$_SelSwpNone" ]] && return 0
|
||||
[[ $? != 0 || $SWAP == "$_SelSwpNone" ]] && { SWAP=""; return 0; }
|
||||
|
||||
if [[ $SWAP == "$_SelSwpFile" ]]; then
|
||||
tput cnorm
|
||||
SWAP_SIZE="$(getinput "$_SelSwpSetup" "$_SelSwpSize" "$SYS_MEM")"
|
||||
[[ $? != 0 || $SWAP_SIZE == "" ]] && return 1
|
||||
[[ $? != 0 || $SWAP_SIZE == "" ]] && { SWAP=""; return 0; }
|
||||
|
||||
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 == "" ]] && { break; return 1; }
|
||||
[[ $? != 0 || $SWAP_SIZE == "" ]] && { SWAP=""; break; return 0; }
|
||||
done
|
||||
|
||||
enable_swap "$MNT/swapfile"
|
||||
@ -508,27 +506,26 @@ select_boot_partition() {
|
||||
}
|
||||
|
||||
select_root_partition() {
|
||||
# if we used LUKS and no LVM or LUKS+LVM
|
||||
# remove the relevant partition labels from the list
|
||||
if (( LUKS == 1 && LVM == 0 )); then
|
||||
# if we used LUKS and no LVM or LUKS+LVM remove the relevant partition labels from the list
|
||||
if [[ $LUKS && ! $LVM ]]; then
|
||||
ROOT_PART="/dev/mapper/$LUKS_NAME"
|
||||
decr_count "$LUKS_PART"
|
||||
elif (( LVM == 1 )); then
|
||||
(( LUKS == 1 )) && decr_count "$LUKS_PART"
|
||||
elif [[ $LVM ]]; then
|
||||
[[ $LUKS ]] && decr_count "$LUKS_PART"
|
||||
for part in $(echo "$GROUP_PARTS"); do decr_count "$part"; done
|
||||
ROOT_PART=""
|
||||
fi
|
||||
|
||||
if [[ $COUNT -eq 1 && $ROOT_PART == "" ]]; then
|
||||
if [[ $COUNT -eq 1 && ! $ROOT_PART ]]; then
|
||||
ROOT_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
|
||||
infobox "$_PrepMount" "$_OnlyOne for root (/): $ROOT_PART\n" 1
|
||||
elif [[ $ROOT_PART == "" || $LVM -eq 1 ]]; then
|
||||
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
|
||||
else
|
||||
local msg="\nUsing $([[ $LUKS -eq 1 ]] && printf "encrypted ")root partition:"
|
||||
local msg="\nUsing${LUKS} root partition:" # $LUKS might just be an empty string
|
||||
infobox "$_PrepMount" "$msg $ROOT_PART\n" 1
|
||||
fi
|
||||
|
||||
@ -545,13 +542,12 @@ select_extra_partitions() {
|
||||
--title " $_PrepMount " --menu "$_ExtPartBody" 0 0 0 "$_Done" "-" $PARTS)"
|
||||
[[ $? != 0 || $part == "$_Done" || $part == "" ]] && break
|
||||
|
||||
# choose what filesystem and get mountpoint
|
||||
# choose what filesystem and get the mountpoint
|
||||
select_filesystem "$part" || { break; return 1; }
|
||||
select_mountpoint || { break; return 1; }
|
||||
|
||||
# mount it
|
||||
mount_partition "$part" "$EXTRA_MNT" || { break; return 1; }
|
||||
|
||||
EXTRA_MNTS="$EXTRA_MNTS $part: $EXTRA_MNT"
|
||||
|
||||
# if the mountpoint was /usr add 'usr' to MKINIT_HOOKS
|
||||
|
@ -28,7 +28,7 @@ ssd() {
|
||||
}
|
||||
|
||||
die() {
|
||||
tput cnorm && unmountp
|
||||
tput cnorm; unmountp; sleep 1
|
||||
pgrep -f "$TERM_CMD -e tail" && pkill -f "$TERM_CMD -e tail"
|
||||
[[ $1 =~ [0-9] ]] && exit $1 || $1
|
||||
}
|
||||
@ -164,4 +164,5 @@ debug() {
|
||||
$TERM_CMD -e "tail -f /tmp/debug-log" &
|
||||
fi
|
||||
fi
|
||||
DEBUG=true
|
||||
}
|
||||
|
Reference in New Issue
Block a user