uniq only works on sorted input

This commit is contained in:
natemaia 2020-05-17 18:29:26 -07:00
parent 1fe5a7ae88
commit 07af2cd556

140
installer
View File

@ -310,6 +310,7 @@ _format="is already formatted correctly.\n\nFor a clean install, existing partit
_swapsize="\nEnter the size of the swapfile in megabytes (M) or gigabytes (G).\n\ne.g. 100M will create a 100 megabyte swapfile, while 10G will create a 10 gigabyte swapfile.\n\nFor ease of use and as an example it is filled in to match the size of your system memory (RAM).\n\nMust be greater than 1, contain only whole numbers, and end with either M or G." _swapsize="\nEnter the size of the swapfile in megabytes (M) or gigabytes (G).\n\ne.g. 100M will create a 100 megabyte swapfile, while 10G will create a 10 gigabyte swapfile.\n\nFor ease of use and as an example it is filled in to match the size of your system memory (RAM).\n\nMust be greater than 1, contain only whole numbers, and end with either M or G."
_expart="\nYou can now choose any additional partitions you want mounted, you'll be asked for a mountpoint after.\n\nSelect 'done' to finish the mounting step and begin unpacking the base system in the background." _expart="\nYou can now choose any additional partitions you want mounted, you'll be asked for a mountpoint after.\n\nSelect 'done' to finish the mounting step and begin unpacking the base system in the background."
_exmnt="\nWhere do you want the partition mounted?\n\nEnsure the name begins with a slash (/).\nExamples include: /usr, /home, /var, etc." _exmnt="\nWhere do you want the partition mounted?\n\nEnsure the name begins with a slash (/).\nExamples include: /usr, /home, /var, etc."
_mirrors="\nAutomatic mirror selection using reflector is preferred and should yield fast mirrors, however\nyou may want to select which countries mirrors to use for faster sorting and more control\n\nUse automatic mirrors?\n"
_bginstall="\nThe background base install will now start, select which base to use\n\nPacstrap - downloads all packages, avoids issues but can be slower depending on your network.\n\nCopy ISO - faster and not network dependant but can result in installation issues when using an older ISO.\n" _bginstall="\nThe background base install will now start, select which base to use\n\nPacstrap - downloads all packages, avoids issues but can be slower depending on your network.\n\nCopy ISO - faster and not network dependant but can result in installation issues when using an older ISO.\n"
_user="\nEnter a name and password for the new user account.\n\nThe name must not use capital letters, contain any periods (.), end with a hyphen (-), or include any colons (:)\n\nNOTE: Use [Up], [Down], or [Tab] to switch between fields, and [Enter] to accept." _user="\nEnter a name and password for the new user account.\n\nThe name must not use capital letters, contain any periods (.), end with a hyphen (-), or include any colons (:)\n\nNOTE: Use [Up], [Down], or [Tab] to switch between fields, and [Enter] to accept."
_hostname="\nEnter a hostname for the new system.\n\nA hostname is used to identify systems on the network.\n\nIt's restricted to alphanumeric characters (a-z, A-Z, 0-9).\nIt can contain hyphens (-) BUT NOT at the beginning or end." _hostname="\nEnter a hostname for the new system.\n\nA hostname is used to identify systems on the network.\n\nIt's restricted to alphanumeric characters (a-z, A-Z, 0-9).\nIt can contain hyphens (-) BUT NOT at the beginning or end."
@ -324,18 +325,12 @@ _usercmd="\nEnter command to be run in the newly installed system (chroot) below
_edit="\nBefore exiting you can select configuration files to review/change.\n\nIf you need to make other changes with the drives still mounted, use Ctrl-z to pause the installer, when finished type 'fg' and [Enter] to resume the installer, if you want to avoid the automatic reboot using Ctrl-c will cleanly exit." _edit="\nBefore exiting you can select configuration files to review/change.\n\nIf you need to make other changes with the drives still mounted, use Ctrl-z to pause the installer, when finished type 'fg' and [Enter] to resume the installer, if you want to avoid the automatic reboot using Ctrl-c will cleanly exit."
# LUKS # LUKS
_luksnew="Basic LUKS Encryption"
_luksadv="Advanced LUKS Encryption"
_luksopen="Open Existing LUKS Partition"
_luksmenu="\nA separate boot partition without encryption or logical volume management (LVM) is required (except BIOS systems using grub).\n\nBasic uses the default encryption settings, and is recommended for beginners. Advanced allows cypher and key size parameters to be entered manually." _luksmenu="\nA separate boot partition without encryption or logical volume management (LVM) is required (except BIOS systems using grub).\n\nBasic uses the default encryption settings, and is recommended for beginners. Advanced allows cypher and key size parameters to be entered manually."
_luksomenu="\nEnter a name and password for the encrypted device.\n\nIt is not necessary to prefix the name with /dev/mapper/, an example has been provided." _luksomenu="\nEnter a name and password for the encrypted device.\n\nIt is not necessary to prefix the name with /dev/mapper/, an example has been provided."
_lukskey="Once the specified flags have been amended, they will automatically be used with the 'cryptsetup -q luksFormat /dev/...' command.\n\nNOTE: Do not specify any additional flags such as -v (--verbose) or -y (--verify-passphrase)." _lukskey="Once the specified flags have been amended, they will automatically be used with the 'cryptsetup -q luksFormat /dev/...' command.\n\nNOTE: Do not specify any additional flags such as -v (--verbose) or -y (--verify-passphrase)."
# LVM # LVM
_lvmmenu="\nLogical volume management (LVM) allows 'virtual' hard drives (volume groups) and partitions (logical volumes) to be created from existing device partitions.\n\nA volume group must be created first, then one or more logical volumes within it.\n\nLVM can also be used with an encrypted partition to create multiple logical volumes (e.g. root and home) within it." _lvmmenu="\nLogical volume management (LVM) allows 'virtual' hard drives (volume groups) and partitions (logical volumes) to be created from existing device partitions.\n\nA volume group must be created first, then one or more logical volumes within it.\n\nLVM can also be used with an encrypted partition to create multiple logical volumes (e.g. root and home) within it."
_lvmnew="Create Volume Group and Volume(s)"
_lvmdel="Delete an Existing Volume Group"
_lvmdelall="Delete ALL Volume Group(s) and Volume(s)"
_lvmvgname="\nEnter a name for the volume group (VG) being created from the partition(s) selected." _lvmvgname="\nEnter a name for the volume group (VG) being created from the partition(s) selected."
_lvmlvname="\nEnter a name for the logical volume (LV) being created.\n\nThis is similar to setting a label for a partition." _lvmlvname="\nEnter a name for the logical volume (LV) being created.\n\nThis is similar to setting a label for a partition."
_lvmlvsize="\nEnter what size you want the logical volume (LV) to be in megabytes (M) or gigabytes (G).\n\ne.g. 100M will create a 100 megabyte volume, 10G will create a 10 gigabyte volume." _lvmlvsize="\nEnter what size you want the logical volume (LV) to be in megabytes (M) or gigabytes (G).\n\ne.g. 100M will create a 100 megabyte volume, 10G will create a 10 gigabyte volume."
@ -867,9 +862,9 @@ dev_menu()
'part' 'Modify the partition layout of a device' \ 'part' 'Modify the partition layout of a device' \
'luks' 'Setup LUKS encryption on a partition or LVM' \ 'luks' 'Setup LUKS encryption on a partition or LVM' \
'lvm' 'Setup logical volume management on partition(s)' \ 'lvm' 'Setup logical volume management on partition(s)' \
'Back' "$back" || return 0 'back' "$back" || return 0
if [[ $DEVMNG_OPT == 'Back' ]]; then if [[ $DEVMNG_OPT == 'back' ]]; then
return 0 return 0
elif [[ -z $WARN && $DEVMNG_OPT != 'view' ]]; then elif [[ -z $WARN && $DEVMNG_OPT != 'view' ]]; then
msg "Data Warning" "$_warn" msg "Data Warning" "$_warn"
@ -900,17 +895,17 @@ part_menu()
while :; do while :; do
choice="" choice=""
dlg choice menu "Modify Partitions" "$_part\n\n$(lsblk -no NAME,MODEL,SIZE,FSTYPE,LABEL "$device")" \ dlg choice menu 'Modify Partitions' "$_part\n\n$(lsblk -no NAME,MODEL,SIZE,FSTYPE,LABEL "$device")" \
"auto" "Whole device automatic partitioning" \ 'auto' 'Whole device automatic partitioning' \
"cfdisk" "Curses based variant of fdisk" \ 'cfdisk' 'Curses based variant of fdisk' \
"cgdisk" "Curses based variant of gdisk" \ 'cgdisk' 'Curses based variant of gdisk' \
"parted" "GNU partition editor" $([[ "$DISPLAY" ]] && hash gparted >/dev/null 2>&1 && printf \ 'parted' 'GNU partition editor' $([[ "$DISPLAY" ]] && hash gparted >/dev/null 2>&1 && printf \
"gparted -") \ 'gparted -') \
"fdisk" "Dialog-driven creation and manipulation of partitions" \ 'fdisk' 'Dialog-driven creation and manipulation of partitions' \
"gdisk" "A text-mode partitioning tool that works on GUID Partition Table (GPT) disks" \ 'gdisk' 'A text-mode partitioning tool that works on GUID Partition Table (GPT) disks' \
"Back" "Return to the device management menu" 'back' 'Return to the device management menu'
if [[ -z $choice || $choice == 'done' ]]; then if [[ -z $choice || $choice == 'back' ]]; then
return 0 return 0
elif [[ $choice == 'auto' ]]; then elif [[ $choice == 'auto' ]]; then
local root_size txt label boot_fs boot_type local root_size txt label boot_fs boot_type
@ -1181,14 +1176,14 @@ part_cryptlv()
if lsblk -lno TYPE "$part" | grep -q 'crypt'; then if lsblk -lno TYPE "$part" | grep -q 'crypt'; then
LUKS='encrypted' LUKS='encrypted'
LUKS_NAME="${part#/dev/mapper/}" LUKS_NAME="${part#/dev/mapper/}"
for dev in $(awk '/lvm/ && /crypto_LUKS/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do for dev in $(awk '/lvm/ && /crypto_LUKS/ {print "/dev/mapper/"$1}' <<< "$devs" | sort | uniq); do
if lsblk -lno NAME "$dev" | grep -q "$LUKS_NAME"; then if lsblk -lno NAME "$dev" | grep -q "$LUKS_NAME"; then
LUKS_DEV="${LUKS_DEV}cryptdevice=$dev:$LUKS_NAME " LUKS_DEV="${LUKS_DEV}cryptdevice=$dev:$LUKS_NAME "
LVM='logical volume' LVM='logical volume'
break break
fi fi
done done
for dev in $(awk '/part/ && /crypto_LUKS/ {print "/dev/"$1}' <<< "$devs" | uniq); do for dev in $(awk '/part/ && /crypto_LUKS/ {print "/dev/"$1}' <<< "$devs" | sort | uniq); do
if lsblk -lno NAME "$dev" | grep -q "$LUKS_NAME"; then if lsblk -lno NAME "$dev" | grep -q "$LUKS_NAME"; then
LUKS_UUID="$(lsblk -lno UUID,TYPE,FSTYPE "$dev" | awk '/part/ && /crypto_LUKS/ {print $1}')" 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_DEV="${LUKS_DEV}cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME "
@ -1198,13 +1193,13 @@ part_cryptlv()
elif lsblk -lno TYPE "$part" | grep -q 'lvm'; then elif lsblk -lno TYPE "$part" | grep -q 'lvm'; then
LVM='logical volume' LVM='logical volume'
VNAME="${part#/dev/mapper/}" VNAME="${part#/dev/mapper/}"
for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | sort | uniq); do
if lsblk -lno NAME "$dev" | grep -q "$VNAME"; then if lsblk -lno NAME "$dev" | grep -q "$VNAME"; then
LUKS_NAME="${dev/\/dev\/mapper\//}" LUKS_NAME="${dev/\/dev\/mapper\//}"
break break
fi fi
done done
for dev in $(awk '/part/ && /crypto_LUKS/ {print "/dev/"$1}' <<< "$devs" | uniq); do for dev in $(awk '/part/ && /crypto_LUKS/ {print "/dev/"$1}' <<< "$devs" | sort | uniq); do
if lsblk -lno NAME "$dev" | grep -q "$LUKS_NAME"; then if lsblk -lno NAME "$dev" | grep -q "$LUKS_NAME"; then
LUKS_UUID="$(lsblk -lno UUID,TYPE,FSTYPE "$dev" | awk '/part/ && /crypto_LUKS/ {print $1}')" 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_DEV="${LUKS_DEV}cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME "
@ -2075,13 +2070,12 @@ install_mirrorlist()
install_background() install_background()
{ {
local luks='' net="networkmanager" local luks='' net='networkmanager'
[[ ! -d /etc/NetworkManager/system-connections ]] && net="netctl" [[ ! -d /etc/NetworkManager/system-connections ]] && net='netctl'
[[ $LUKS ]] && luks="cryptsetup" [[ $LUKS ]] && luks='cryptsetup'
local txt="\nAutomatic mirror selection using reflector is preferred and should yield fast mirrors, however\nyou may want to select which countries mirrors to use for faster sorting and more control\n\nUse automatic mirrors?\n" if hash reflector > /dev/null 2>&1 && yesno 'Mirrorlist' "$_mirrors"; then
if hash reflector > /dev/null 2>&1 && yesno "Mirrorlist" "$txt"; then
AUTO_MIR=true AUTO_MIR=true
else else
AUTO_MIR='' AUTO_MIR=''
@ -2089,7 +2083,7 @@ install_background()
fi fi
if hash rsync > /dev/null 2>&1; then if hash rsync > /dev/null 2>&1; then
yesno "Background Install" "$_bginstall" "Pacstrap" "Copy ISO" || PACSTRAP=0 yesno 'Background Install' "$_bginstall" 'Pacstrap' 'Copy ISO' || PACSTRAP=0
fi fi
( (
install_mirrorlist > /tmp/bgout 2>&1 install_mirrorlist > /tmp/bgout 2>&1
@ -2108,14 +2102,14 @@ install_background()
if [[ $PACSTRAP == 1 ]]; then if [[ $PACSTRAP == 1 ]]; then
chrun "pacman -S ${ISO_PKGS[*]} $net $luks --noconfirm --needed" >> /tmp/bgout 2>&1 chrun "pacman -S ${ISO_PKGS[*]} $net $luks --noconfirm --needed" >> /tmp/bgout 2>&1
else else
chrun "pacman -Sy" >> /tmp/bgout 2>&1 chrun 'pacman -Sy' >> /tmp/bgout 2>&1
chrun "pacman -S $net --noconfirm --needed" >> /tmp/bgout 2>&1 chrun "pacman -S $net --noconfirm --needed" >> /tmp/bgout 2>&1
fi fi
if [[ $net == "networkmanager" ]]; then if [[ $net == "networkmanager" ]]; then
chrun "systemctl enable NetworkManager.service" >> /tmp/bgout 2>&1 chrun 'systemctl enable NetworkManager.service' >> /tmp/bgout 2>&1
else else
chrun "systemctl enable netctl.service" >> /tmp/bgout 2>&1 chrun 'systemctl enable netctl.service' >> /tmp/bgout 2>&1
fi fi
if [[ -e /tmp/wmlist ]]; then if [[ -e /tmp/wmlist ]]; then
@ -2540,18 +2534,17 @@ lvm_menu()
local choice local choice
while :; do while :; do
dlg choice menu "Logical Volume Management" "$_lvmmenu" \ dlg choice menu "Logical Volume Management" "$_lvmmenu" \
"$_lvmnew" "vgcreate -f, lvcreate -L -n" \ 'create' "Create a new volume group and volumes" \
"$_lvmdel" "vgremove -f" \ 'remove' "Delete an existing volume group" \
"$_lvmdelall" "lvrmeove, vgremove, pvremove -f" \ 'remove_all' "Delete ALL volume groups and volumes" \
"Back" "Return to the device management menu" "back" "Return to the device management menu"
case "$choice" in case "$choice" in
"$_lvmnew") lvm_create && break ;; 'create') lvm_create && break ;;
"$_lvmdel") lvm_delgroup && yesno "$_lvmdel" "$_lvmdelask" && vgremove -f "$DEL_VG" > /dev/null 2>&1 ;; 'remove') lvm_delgroup && yesno "Remove Volume Group" "$_lvmdelask" && vgremove -f "$DEL_VG" > /dev/null 2>&1 ;;
"$_lvmdelall") lvm_del_all ;; 'remove_all') lvm_del_all ;;
*) break ;; *) break ;;
esac esac
done done
return 0 return 0
} }
@ -2575,20 +2568,20 @@ lvm_create()
lvm_mkgroup || return 1 lvm_mkgroup || return 1
local txt="\nThe last (or only) logical volume will automatically use all remaining space in the volume group." local txt="\nThe last (or only) logical volume will automatically use all remaining space in the volume group."
dlg VOL_COUNT menu "$_lvmnew" "\nSelect the number of logical volumes (LVs) to create in: $VGROUP\n$txt" \ dlg VOL_COUNT menu "Create Volume Group" "\nSelect the number of logical volumes (LVs) to create in: $VGROUP\n$txt" \
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -
[[ $VOL_COUNT ]] || return 1 [[ $VOL_COUNT ]] || return 1
lvm_extra_lvs || return 1 lvm_extra_lvs || return 1
lvm_volume_name "$_lvmlvname\nNOTE: This LV will use up all remaining space in the volume group (${VGROUP_MB}MB)" || return 1 lvm_volume_name "$_lvmlvname\nNOTE: This LV will use up all remaining space in the volume group (${VGROUP_MB}MB)" || return 1
msg "$_lvmnew (LV:$VOL_COUNT)" "\nCreating volume $VNAME from remaining space in $VGROUP\n" 0 msg "Create Volume Group (LV:$VOL_COUNT)" "\nCreating volume $VNAME from remaining space in $VGROUP\n" 0
lvcreate -l +100%FREE "$VGROUP" -n "$VNAME" > /dev/null 2> "$ERR" lvcreate -l +100%FREE "$VGROUP" -n "$VNAME" > /dev/null 2> "$ERR"
errshow 0 "lvcreate -l +100%FREE $VGROUP -n $VNAME" || return 1 errshow 0 "lvcreate -l +100%FREE $VGROUP -n $VNAME" || return 1
LVM='logical volume' LVM='logical volume'
sleep 0.5 sleep 0.5
txt="\nDone, volume: $VGROUP-$VNAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) has been created.\n" txt="\nDone, volume: $VGROUP-$VNAME (${VOLUME_SIZE:-${VGROUP_MB}MB}) has been created.\n"
msg "$_lvmnew (LV:$VOL_COUNT)" "$txt\n$(lsblk -o NAME,SIZE $LVM_PARTS)\n" msg "Create Volume Group (LV:$VOL_COUNT)" "$txt\n$(lsblk -o NAME,SIZE $LVM_PARTS)\n"
return 0 return 0
} }
@ -2598,7 +2591,7 @@ lvm_lv_size()
while :; do while :; do
ERR_SIZE=0 ERR_SIZE=0
dlg VOLUME_SIZE input "$_lvmnew (LV:$VOL_COUNT)" "$txt" dlg VOLUME_SIZE input "Create Volume Group (LV:$VOL_COUNT)" "$txt"
if [[ -z $VOLUME_SIZE ]]; then if [[ -z $VOLUME_SIZE ]]; then
ERR_SIZE=1 ERR_SIZE=1
break # allow bailing with escape or an empty choice break # allow bailing with escape or an empty choice
@ -2650,10 +2643,10 @@ lvm_mkgroup()
until [[ $named ]]; do until [[ $named ]]; do
lvm_partitions || return 1 lvm_partitions || return 1
lvm_group_name || return 1 lvm_group_name || return 1
yesno "$_lvmnew" "\nCreate volume group: $VGROUP\n\nusing these partition(s): $LVM_PARTS\n" && named=true yesno "Create Volume Group" "\nCreate volume group: $VGROUP\n\nusing these partition(s): $LVM_PARTS\n" && named=true
done done
msg "$_lvmnew" "\nCreating volume group: $VGROUP\n" 0 msg "Create Volume Group" "\nCreating volume group: $VGROUP\n" 0
vgcreate -f "$VGROUP" $LVM_PARTS > /dev/null 2> "$ERR" vgcreate -f "$VGROUP" $LVM_PARTS > /dev/null 2> "$ERR"
errshow 0 "vgcreate -f '$VGROUP' $LVM_PARTS >/dev/null" || return 1 errshow 0 "vgcreate -f '$VGROUP' $LVM_PARTS >/dev/null" || return 1
@ -2666,7 +2659,7 @@ lvm_mkgroup()
VGROUP_MB=$SIZE VGROUP_MB=$SIZE
fi fi
msg "$_lvmnew" "\nVolume group $VGROUP (${SIZE}$SIZE_UNIT) successfully created\n" 2 msg "Create Volume Group" "\nVolume group $VGROUP (${SIZE}$SIZE_UNIT) successfully created\n" 2
} }
lvm_del_all() lvm_del_all()
@ -2677,7 +2670,7 @@ lvm_del_all()
VGROUP="$(vgs -o vg_name --noheading 2> /dev/null)" VGROUP="$(vgs -o vg_name --noheading 2> /dev/null)"
if [[ $VGROUP || $v || $pv ]]; then if [[ $VGROUP || $v || $pv ]]; then
if yesno "$_lvmdelall" "$_lvmdelask"; then if yesno "Remove All Volume Groups" "$_lvmdelask"; then
for i in $v; do lvremove -f "/dev/mapper/$i" > /dev/null 2>&1; done for i in $v; do lvremove -f "/dev/mapper/$i" > /dev/null 2>&1; done
for i in $VGROUP; do vgremove -f "$i" > /dev/null 2>&1; done for i in $VGROUP; do vgremove -f "$i" > /dev/null 2>&1; done
for i in $pv; do pvremove -f "$i" > /dev/null 2>&1; done for i in $pv; do pvremove -f "$i" > /dev/null 2>&1; done
@ -2697,7 +2690,7 @@ lvm_delgroup()
DEL_VG='' DEL_VG=''
VOL_GROUP_LIST='' VOL_GROUP_LIST=''
for i in $(lvs --noheadings | awk '{print $2}' | uniq); do for i in $(lvs --noheadings | awk '{print $2}' | sort | uniq); do
VOL_GROUP_LIST+="$i $(vgdisplay "$i" | awk '/VG Size/ {print $3$4}') " VOL_GROUP_LIST+="$i $(vgdisplay "$i" | awk '/VG Size/ {print $3$4}') "
done done
@ -2713,11 +2706,11 @@ lvm_extra_lvs()
lvm_volume_name "$_lvmlvname" || return 1 lvm_volume_name "$_lvmlvname" || return 1
lvm_lv_size || return 1 lvm_lv_size || return 1
msg "$_lvmnew (LV:$VOL_COUNT)" "\nCreating a $VOLUME_SIZE volume $VNAME in $VGROUP\n" 0 msg "Create Volume Group (LV:$VOL_COUNT)" "\nCreating a $VOLUME_SIZE volume $VNAME in $VGROUP\n" 0
lvcreate -L "$VOLUME_SIZE" "$VGROUP" -n "$VNAME" > /dev/null 2> "$ERR" lvcreate -L "$VOLUME_SIZE" "$VGROUP" -n "$VNAME" > /dev/null 2> "$ERR"
errshow 0 "lvcreate -L '$VOLUME_SIZE' '$VGROUP' -n '$VNAME'" || return 1 errshow 0 "lvcreate -L '$VOLUME_SIZE' '$VGROUP' -n '$VNAME'" || return 1
msg "$_lvmnew (LV:$VOL_COUNT)" "\nDone, logical volume (LV) $VNAME ($VOLUME_SIZE) has been created.\n" msg "Create Volume Group (LV:$VOL_COUNT)" "\nDone, logical volume (LV) $VNAME ($VOLUME_SIZE) has been created.\n"
(( VOL_COUNT-- )) (( VOL_COUNT-- ))
done done
return 0 return 0
@ -2728,14 +2721,14 @@ lvm_partitions()
part_find 'part|crypt' || return 1 part_find 'part|crypt' || return 1
PARTS="$(awk 'NF > 0 {print $0 " off"}' <<< "$PARTS")" PARTS="$(awk 'NF > 0 {print $0 " off"}' <<< "$PARTS")"
[[ $LUKS && $LUKS_PART ]] && part_countdec $LUKS_PART [[ $LUKS && $LUKS_PART ]] && part_countdec $LUKS_PART
dlg LVM_PARTS check "$_lvmnew" "\nSelect the partition(s) to use for the physical volume (PV)." $PARTS dlg LVM_PARTS check "Create Volume Group" "\nSelect the partition(s) to use for the physical volume (PV)." $PARTS
} }
lvm_group_name() lvm_group_name()
{ {
VGROUP='' VGROUP=''
until [[ $VGROUP ]]; do until [[ $VGROUP ]]; do
dlg VGROUP input "$_lvmnew" "$_lvmvgname" dlg VGROUP input "Create Volume Group" "$_lvmvgname"
if [[ -z $VGROUP ]]; then if [[ -z $VGROUP ]]; then
return 1 return 1
elif [[ ${VGROUP:0:1} == "/" || $VGROUP =~ \ |\' ]] || vgdisplay | grep -q "$VGROUP"; then elif [[ ${VGROUP:0:1} == "/" || $VGROUP =~ \ |\' ]] || vgdisplay | grep -q "$VGROUP"; then
@ -2751,7 +2744,7 @@ lvm_volume_name()
VNAME='' VNAME=''
local txt="$1" local txt="$1"
until [[ $VNAME ]]; do until [[ $VNAME ]]; do
dlg VNAME input "$_lvmnew (LV:$VOL_COUNT)" "\n$txt" dlg VNAME input "Create Volume Group (LV:$VOL_COUNT)" "\n$txt"
if [[ -z $VNAME ]]; then if [[ -z $VNAME ]]; then
return 1 return 1
elif [[ ${VNAME:0:1} == "/" || $VNAME =~ \ |\' ]] || lsblk | grep -q "$VNAME"; then elif [[ ${VNAME:0:1} == "/" || $VNAME =~ \ |\' ]] || lsblk | grep -q "$VNAME"; then
@ -2769,18 +2762,19 @@ luks_menu()
{ {
local choice local choice
is_bg_install || return 1 is_bg_install || return 1
dlg choice menu "LUKS Encryption" "$_luksmenu" \ while :; do
"$_luksnew" "cryptsetup -q luksFormat" \ dlg choice menu 'LUKS Encryption' "$_luksmenu" \
"$_luksopen" "cryptsetup open --type luks" \ 'basic' 'LUKS setup with default settings' \
"$_luksadv" "cryptsetup -q -s -c luksFormat" \ 'open' 'Open an existing LUKS partition' \
"Back" "Return to the device management menu" 'advanced' 'Specify cypher type and other flags for cryptsetup' \
'back' 'Return to the device management menu'
case "$choice" in case "$choice" in
"$_luksnew") luks_basic || return 1 ;; 'basic') luks_basic || return 1 ;;
"$_luksopen") luks_open || return 1 ;; 'open') luks_open || return 1 ;;
"$_luksadv") luks_advanced || return 1 ;; 'advanced') luks_advanced || return 1 ;;
esac *) break ;;
esac
done
return 0 return 0
} }
@ -2794,13 +2788,13 @@ luks_open()
LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")" LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
else else
[[ $LVM && $LVM_PARTS ]] && part_countdec $LVM_PARTS [[ $LVM && $LVM_PARTS ]] && part_countdec $LVM_PARTS
dlg LUKS_PART menu "$_luksopen" "\nSelect which partition to open." $PARTS dlg LUKS_PART menu "LUKS Open" "\nSelect which partition to open." $PARTS
fi fi
[[ $LUKS_PART ]] || return 1 [[ $LUKS_PART ]] || return 1
luks_pass "$_luksopen" || return 1 luks_pass "LUKS Open" || return 1
msg "$_luksopen" "\nOpening encryption: $LUKS_NAME\n\nUsing device/volume: $(part_pretty "$LUKS_PART")\n" 0 msg "LUKS Open" "\nOpening encryption: $LUKS_NAME\n\nUsing device/volume: $(part_pretty "$LUKS_PART")\n" 0
cryptsetup open --type luks "$LUKS_PART" "$LUKS_NAME" <<< "$LUKS_PASS" 2> "$ERR" cryptsetup open --type luks "$LUKS_PART" "$LUKS_NAME" <<< "$LUKS_PASS" 2> "$ERR"
errshow 0 "cryptsetup open --type luks '$LUKS_PART' '$LUKS_NAME' <<< '$LUKS_PASS'" || return 1 errshow 0 "cryptsetup open --type luks '$LUKS_PART' '$LUKS_NAME' <<< '$LUKS_PASS'" || return 1
LUKS='encrypted' LUKS='encrypted'
@ -2841,7 +2835,7 @@ luks_pass()
luks_show() luks_show()
{ {
sleep 0.5 sleep 0.5
msg "$_luksnew" "\nEncrypted partition ready for mounting.\n\n$(lsblk -o NAME,SIZE,FSTYPE "$LUKS_PART")\n\n" msg "LUKS Encryption" "\nEncrypted partition ready for mounting.\n\n$(lsblk -o NAME,SIZE,FSTYPE "$LUKS_PART")\n\n"
} }
luks_setup() luks_setup()
@ -2856,17 +2850,17 @@ luks_setup()
LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")" LUKS_PART="$(awk 'NF > 0 {print $1}' <<< "$PARTS")"
else else
[[ $LVM && $LVM_PARTS ]] && part_countdec $LVM_PARTS [[ $LVM && $LVM_PARTS ]] && part_countdec $LVM_PARTS
dlg LUKS_PART menu "$_luksnew" "\nSelect the partition you want to encrypt." $PARTS dlg LUKS_PART menu "LUKS Encryption" "\nSelect the partition you want to encrypt." $PARTS
fi fi
[[ $LUKS_PART ]] || return 1 [[ $LUKS_PART ]] || return 1
luks_pass "$_luksnew" luks_pass "LUKS Encryption"
} }
luks_basic() luks_basic()
{ {
luks_setup || return 1 luks_setup || return 1
msg "$_luksnew" "\nCreating encrypted partition: $LUKS_NAME\n\nDevice or volume used: $LUKS_PART\n" 0 msg "LUKS Encryption" "\nCreating encrypted partition: $LUKS_NAME\n\nDevice or volume used: $LUKS_PART\n" 0
cryptsetup -q luksFormat "$LUKS_PART" <<< "$LUKS_PASS" 2> "$ERR" cryptsetup -q luksFormat "$LUKS_PART" <<< "$LUKS_PASS" 2> "$ERR"
errshow 0 "cryptsetup -q luksFormat '$LUKS_PART' <<< '$LUKS_PASS'" || return 1 errshow 0 "cryptsetup -q luksFormat '$LUKS_PART' <<< '$LUKS_PASS'" || return 1
cryptsetup open "$LUKS_PART" "$LUKS_NAME" <<< "$LUKS_PASS" 2> "$ERR" cryptsetup open "$LUKS_PART" "$LUKS_NAME" <<< "$LUKS_PASS" 2> "$ERR"
@ -2882,7 +2876,7 @@ luks_advanced()
local cipher local cipher
dlg cipher input "LUKS Encryption" "$_lukskey" "-s 512 -c aes-xts-plain64" dlg cipher input "LUKS Encryption" "$_lukskey" "-s 512 -c aes-xts-plain64"
[[ $cipher ]] || return 1 [[ $cipher ]] || return 1
msg "$_luksadv" "\nCreating encrypted partition: $LUKS_NAME\n\nDevice or volume used: $LUKS_PART\n" 0 msg "LUKS Encryption" "\nCreating encrypted partition: $LUKS_NAME\n\nDevice or volume used: $LUKS_PART\n" 0
cryptsetup -q $cipher luksFormat "$LUKS_PART" <<< "$LUKS_PASS" 2> "$ERR" cryptsetup -q $cipher luksFormat "$LUKS_PART" <<< "$LUKS_PASS" 2> "$ERR"
errshow 0 "cryptsetup -q $cipher luksFormat '$LUKS_PART' <<< '$LUKS_PASS'" || return 1 errshow 0 "cryptsetup -q $cipher luksFormat '$LUKS_PART' <<< '$LUKS_PASS'" || return 1
cryptsetup open "$LUKS_PART" "$LUKS_NAME" <<< "$LUKS_PASS" 2> "$ERR" cryptsetup open "$LUKS_PART" "$LUKS_NAME" <<< "$LUKS_PASS" 2> "$ERR"