rename parameters

This commit is contained in:
Tobias Powalowski 2023-01-08 19:29:34 +01:00
parent fbdbb6d1d6
commit 19b0d64ea1
2 changed files with 257 additions and 257 deletions

View file

@ -226,7 +226,7 @@ findpartitions() {
# don't check on raid devices! # don't check on raid devices!
findbootloaderdisks() { findbootloaderdisks() {
if ! [[ "${USE_DMRAID}" == "1" ]]; then if ! [[ "${_USE_DMRAID}" == "1" ]]; then
blockdevices "${1}" blockdevices "${1}"
else else
dmraid_devices "${1}" dmraid_devices "${1}"
@ -247,17 +247,17 @@ activate_dmraid()
# activate lvm2 devices # activate lvm2 devices
activate_lvm2() activate_lvm2()
{ {
ACTIVATE_LVM2="" _ACTIVATE_LVM2=""
if [[ -e /usr/bin/lvm ]]; then if [[ -e /usr/bin/lvm ]]; then
OLD_LVM2_GROUPS=${LVM2_GROUPS} _OLD_LVM2_GROUPS=${_LVM2_GROUPS}
OLD_LVM2_VOLUMES=${LVM2_VOLUMES} _OLD_LVM2_VOLUMES=${_LVM2_VOLUMES}
DIALOG --infobox "Scanning logical volumes..." 0 0 DIALOG --infobox "Scanning logical volumes..." 0 0
lvm vgscan --ignorelockingfailure >/dev/null 2>&1 lvm vgscan --ignorelockingfailure >/dev/null 2>&1
DIALOG --infobox "Activating logical volumes..." 0 0 DIALOG --infobox "Activating logical volumes..." 0 0
lvm vgchange --ignorelockingfailure --ignoremonitoring -ay >/dev/null 2>&1 lvm vgchange --ignorelockingfailure --ignoremonitoring -ay >/dev/null 2>&1
LVM2_GROUPS="$(vgs -o vg_name --noheading 2>/dev/null)" _LVM2_GROUPS="$(vgs -o vg_name --noheading 2>/dev/null)"
LVM2_VOLUMES="$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)" _LVM2_VOLUMES="$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)"
[[ "${OLD_LVM2_GROUPS}" == "${LVM2_GROUPS}" && "${OLD_LVM2_VOLUMES}" == "${LVM2_VOLUMES}" ]] && ACTIVATE_LVM2="no" [[ "${_OLD_LVM2_GROUPS}" == "${_LVM2_GROUPS}" && "${_OLD_LVM2_VOLUMES}" == "${_LVM2_VOLUMES}" ]] && _ACTIVATE_LVM2="no"
fi fi
} }
@ -265,10 +265,10 @@ activate_lvm2()
# activate md devices # activate md devices
activate_raid() activate_raid()
{ {
ACTIVATE_RAID="" _ACTIVATE_RAID=""
if [[ -e /usr/bin/mdadm ]]; then if [[ -e /usr/bin/mdadm ]]; then
DIALOG --infobox "Activating RAID arrays..." 0 0 DIALOG --infobox "Activating RAID arrays..." 0 0
mdadm --assemble --scan >/dev/null 2>&1 || ACTIVATE_RAID="no" mdadm --assemble --scan >/dev/null 2>&1 || _ACTIVATE_RAID="no"
fi fi
} }
@ -276,23 +276,23 @@ activate_raid()
# activate luks devices # activate luks devices
activate_luks() activate_luks()
{ {
ACTIVATE_LUKS="" _ACTIVATE_LUKS=""
if [[ -e /usr/bin/cryptsetup ]]; then if [[ -e /usr/bin/cryptsetup ]]; then
DIALOG --infobox "Scanning for luks encrypted devices..." 0 0 DIALOG --infobox "Scanning for luks encrypted devices..." 0 0
if ${_LSBLK} FSTYPE | grep -q "crypto_LUKS"; then if ${_LSBLK} FSTYPE | grep -q "crypto_LUKS"; then
for PART in $(${_LSBLK} NAME,FSTYPE | grep " crypto_LUKS$" | cut -d' ' -f 1); do for part in $(${_LSBLK} NAME,FSTYPE | grep " crypto_LUKS$" | cut -d' ' -f 1); do
# skip already encrypted devices, device mapper! # skip already encrypted devices, device mapper!
if ! ${_LSBLK} TYPE "${PART}" | grep -q "crypt$"; then if ! ${_LSBLK} TYPE "${part}" | grep -q "crypt$"; then
RUN_LUKS="" _RUN_LUKS=""
DIALOG --yesno "Setup detected luks encrypted device, do you want to activate ${PART} ?" 0 0 && RUN_LUKS="1" DIALOG --yesno "Setup detected luks encrypted device, do you want to activate ${part} ?" 0 0 && _RUN_LUKS="1"
[[ "${RUN_LUKS}" == "1" ]] && _enter_luks_name && _enter_luks_passphrase && _opening_luks [[ "${_RUN_LUKS}" == "1" ]] && _enter_luks_name && _enter_luks_passphrase && _opening_luks
[[ "${RUN_LUKS}" == "" ]] && ACTIVATE_LUKS="no" [[ "${_RUN_LUKS}" == "" ]] && _ACTIVATE_LUKS="no"
else else
ACTIVATE_LUKS="no" _ACTIVATE_LUKS="no"
fi fi
done done
else else
ACTIVATE_LUKS="no" _ACTIVATE_LUKS="no"
fi fi
fi fi
} }
@ -303,11 +303,11 @@ activate_luks()
# run it more times if needed, it can be hidden by each other! # run it more times if needed, it can be hidden by each other!
activate_special_devices() activate_special_devices()
{ {
ACTIVATE_RAID="" _ACTIVATE_RAID=""
ACTIVATE_LUKS="" _ACTIVATE_LUKS=""
ACTIVATE_LVM2="" _ACTIVATE_LVM2=""
activate_dmraid activate_dmraid
while ! [[ "${ACTIVATE_LVM2}" == "no" && "${ACTIVATE_RAID}" == "no" && "${ACTIVATE_LUKS}" == "no" ]]; do while ! [[ "${_ACTIVATE_LVM2}" == "no" && "${_ACTIVATE_RAID}" == "no" && "${_ACTIVATE_LUKS}" == "no" ]]; do
activate_raid activate_raid
activate_lvm2 activate_lvm2
activate_luks activate_luks
@ -316,20 +316,20 @@ activate_special_devices()
# set device name scheme # set device name scheme
set_device_name_scheme() { set_device_name_scheme() {
NAME_SCHEME_PARAMETER="" _NAME_SCHEME_PARAMETER=""
NAME_SCHEME_LEVELS="" _NAME_SCHEME_LEVELS=""
MENU_DESC_TEXT="" _MENU_DESC_TEXT=""
## util-linux root=PARTUUID=/root=PARTLABEL= support - https://git.kernel.org/?p=utils/util-linux/util-linux.git;a=commitdiff;h=fc387ee14c6b8672761ae5e67ff639b5cae8f27c;hp=21d1fa53f16560dacba33fffb14ffc05d275c926 ## util-linux root=PARTUUID=/root=PARTLABEL= support - https://git.kernel.org/?p=utils/util-linux/util-linux.git;a=commitdiff;h=fc387ee14c6b8672761ae5e67ff639b5cae8f27c;hp=21d1fa53f16560dacba33fffb14ffc05d275c926
## mkinitcpio's init root=PARTUUID= support - https://projects.archlinux.org/mkinitcpio.git/tree/init_functions#n185 ## mkinitcpio's init root=PARTUUID= support - https://projects.archlinux.org/mkinitcpio.git/tree/init_functions#n185
if [[ "${_UEFI_BOOT}" == "1" ]]; then if [[ "${_UEFI_BOOT}" == "1" ]]; then
NAME_SCHEME_LEVELS="${NAME_SCHEME_LEVELS} PARTUUID PARTUUID=<partuuid> PARTLABEL PARTLABEL=<partlabel>" _NAME_SCHEME_LEVELS="${_NAME_SCHEME_LEVELS} PARTUUID PARTUUID=<partuuid> PARTLABEL PARTLABEL=<partlabel>"
MENU_DESC_TEXT="\nPARTUUID and PARTLABEL are specific to GPT disks.\nIn GPT disks, PARTUUID is recommended.\nIn MBR/msdos disks," _MENU_DESC_TEXT="\nPARTUUID and PARTLABEL are specific to GPT disks.\nIn GPT disks, PARTUUID is recommended.\nIn MBR/msdos disks,"
fi fi
NAME_SCHEME_LEVELS="${NAME_SCHEME_LEVELS} FSUUID UUID=<uuid> FSLABEL LABEL=<label> KERNEL /dev/<kernelname>" _NAME_SCHEME_LEVELS="${_NAME_SCHEME_LEVELS} FSUUID UUID=<uuid> FSLABEL LABEL=<label> KERNEL /dev/<kernelname>"
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select the device name scheme you want to use in config files. ${MENU_DESC_TEXT} FSUUID is recommended." 15 70 9 ${NAME_SCHEME_LEVELS} 2>"${_ANSWER}" || return 1 DIALOG --menu "Select the device name scheme you want to use in config files. ${_MENU_DESC_TEXT} FSUUID is recommended." 15 70 9 ${_NAME_SCHEME_LEVELS} 2>"${_ANSWER}" || return 1
NAME_SCHEME_PARAMETER=$(cat "${_ANSWER}") _NAME_SCHEME_PARAMETER=$(cat "${_ANSWER}")
NAME_SCHEME_PARAMETER_RUN="1" _NAME_SCHEME_PARAMETER_RUN="1"
} }
# Get a list of available disks for use in the "Available disks" dialogs. # Get a list of available disks for use in the "Available disks" dialogs.
@ -372,9 +372,9 @@ _umountall()
_stopmd() _stopmd()
{ {
if grep -q ^md /proc/mdstat 2>/dev/null; then if grep -q ^md /proc/mdstat 2>/dev/null; then
DISABLEMD="" _DISABLEMD=""
DIALOG --defaultno --yesno "Setup detected already running raid devices, do you want to disable them completely?" 0 0 && DISABLEMD="1" DIALOG --defaultno --yesno "Setup detected already running raid devices, do you want to disable them completely?" 0 0 && _DISABLEMD="1"
if [[ "${DISABLEMD}" == "1" ]]; then if [[ "${_DISABLEMD}" == "1" ]]; then
_umountall _umountall
DIALOG --infobox "Disabling all software raid devices..." 0 0 DIALOG --infobox "Disabling all software raid devices..." 0 0
# shellcheck disable=SC2013 # shellcheck disable=SC2013
@ -392,10 +392,10 @@ _stopmd()
done done
fi fi
fi fi
DISABLEMDSB="" _DISABLEMDSB=""
if ${_LSBLK} FSTYPE | grep -q "linux_raid_member"; then if ${_LSBLK} FSTYPE | grep -q "linux_raid_member"; then
DIALOG --defaultno --yesno "Setup detected superblock of raid devices, do you want to clean the superblock of them?" 0 0 && DISABLEMDSB="1" DIALOG --defaultno --yesno "Setup detected superblock of raid devices, do you want to clean the superblock of them?" 0 0 && _DISABLEMDSB="1"
if [[ "${DISABLEMDSB}" == "1" ]]; then if [[ "${_DISABLEMDSB}" == "1" ]]; then
_umountall _umountall
DIALOG --infobox "Cleaning superblocks of all software raid devices..." 0 0 DIALOG --infobox "Cleaning superblocks of all software raid devices..." 0 0
for i in $(${_LSBLK} NAME,FSTYPE | grep "linux_raid_member$" | cut -d' ' -f 1); do for i in $(${_LSBLK} NAME,FSTYPE | grep "linux_raid_member$" | cut -d' ' -f 1); do
@ -411,29 +411,29 @@ _stopmd()
# Disable all lvm devices # Disable all lvm devices
_stoplvm() _stoplvm()
{ {
DISABLELVM="" _DISABLELVM=""
DETECTED_LVM="" _DETECTED_LVM=""
LV_VOLUMES="$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)" _LV_VOLUMES="$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)"
LV_GROUPS="$(vgs -o vg_name --noheading 2>/dev/null)" _LV_GROUPS="$(vgs -o vg_name --noheading 2>/dev/null)"
LV_PHYSICAL="$(pvs -o pv_name --noheading 2>/dev/null)" _LV_PHYSICAL="$(pvs -o pv_name --noheading 2>/dev/null)"
! [[ "${LV_VOLUMES}" == "" ]] && DETECTED_LVM=1 ! [[ "${_LV_VOLUMES}" == "" ]] && _DETECTED_LVM=1
! [[ "${LV_GROUPS}" == "" ]] && DETECTED_LVM=1 ! [[ "${_LV_GROUPS}" == "" ]] && _DETECTED_LVM=1
! [[ "${LV_PHYSICAL}" == "" ]] && DETECTED_LVM=1 ! [[ "${_LV_PHYSICAL}" == "" ]] && _DETECTED_LVM=1
if [[ "${DETECTED_LVM}" == "1" ]]; then if [[ "${_DETECTED_LVM}" == "1" ]]; then
DIALOG --defaultno --yesno "Setup detected lvm volumes, volume groups or physical devices, do you want to remove them completely?" 0 0 && DISABLELVM="1" DIALOG --defaultno --yesno "Setup detected lvm volumes, volume groups or physical devices, do you want to remove them completely?" 0 0 && _DISABLELVM="1"
fi fi
if [[ "${DISABLELVM}" == "1" ]]; then if [[ "${_DISABLELVM}" == "1" ]]; then
_umountall _umountall
DIALOG --infobox "Removing logical volumes ..." 0 0 DIALOG --infobox "Removing logical volumes ..." 0 0
for i in ${LV_VOLUMES}; do for i in ${_LV_VOLUMES}; do
lvremove -f "/dev/mapper/${i}" 2>/dev/null> "${_LOG}" lvremove -f "/dev/mapper/${i}" 2>/dev/null> "${_LOG}"
done done
DIALOG --infobox "Removing logical groups ..." 0 0 DIALOG --infobox "Removing logical groups ..." 0 0
for i in ${LV_GROUPS}; do for i in ${_LV_GROUPS}; do
vgremove -f "${i}" 2>/dev/null > "${_LOG}" vgremove -f "${i}" 2>/dev/null > "${_LOG}"
done done
DIALOG --infobox "Removing physical volumes ..." 0 0 DIALOG --infobox "Removing physical volumes ..." 0 0
for i in ${LV_PHYSICAL}; do for i in ${_LV_PHYSICAL}; do
pvremove -f "${i}" 2>/dev/null > "${_LOG}" pvremove -f "${i}" 2>/dev/null > "${_LOG}"
done done
fi fi
@ -442,33 +442,33 @@ _stoplvm()
# Disable all luks encrypted devices # Disable all luks encrypted devices
_stopluks() _stopluks()
{ {
DISABLELUKS="" _DISABLELUKS=""
DETECTED_LUKS="" _DETECTED_LUKS=""
LUKSDEVICE="" _LUKSDEVICE=""
# detect already running luks devices # detect already running luks devices
LUKSDEVICE="$(${_LSBLK} NAME,TYPE | grep " crypt$" | cut -d' ' -f1)" _LUKSDEVICE="$(${_LSBLK} NAME,TYPE | grep " crypt$" | cut -d' ' -f1)"
[[ "${LUKSDEVICE}" == "" ]] || DETECTED_LUKS=1 [[ "${_LUKSDEVICE}" == "" ]] || _DETECTED_LUKS=1
if [[ "${DETECTED_LUKS}" == "1" ]]; then if [[ "${_DETECTED_LUKS}" == "1" ]]; then
DIALOG --defaultno --yesno "Setup detected running luks encrypted devices, do you want to remove them completely?" 0 0 && DISABLELUKS="1" DIALOG --defaultno --yesno "Setup detected running luks encrypted devices, do you want to remove them completely?" 0 0 && _DISABLELUKS="1"
fi fi
if [[ "${DISABLELUKS}" == "1" ]]; then if [[ "${_DISABLELUKS}" == "1" ]]; then
_umountall _umountall
DIALOG --infobox "Removing luks encrypted devices ..." 0 0 DIALOG --infobox "Removing luks encrypted devices ..." 0 0
for i in ${LUKSDEVICE}; do for i in ${_LUKSDEVICE}; do
LUKS_REAL_DEVICE="$(${_LSBLK} NAME,FSTYPE -s "${LUKSDEVICE}" | grep " crypto_LUKS$" | cut -d' ' -f1)" _LUKS_REAL_DEVICE="$(${_LSBLK} NAME,FSTYPE -s "${_LUKSDEVICE}" | grep " crypto_LUKS$" | cut -d' ' -f1)"
cryptsetup remove "${i}" > "${_LOG}" cryptsetup remove "${i}" > "${_LOG}"
# delete header from device # delete header from device
wipefs -a "${LUKS_REAL_DEVICE}" > "${_LOG}" 2>&1 wipefs -a "${_LUKS_REAL_DEVICE}" > "${_LOG}" 2>&1
done done
fi fi
DISABLELUKS="" _DISABLELUKS=""
DETECTED_LUKS="" _DETECTED_LUKS=""
# detect not running luks devices # detect not running luks devices
${_LSBLK} FSTYPE | grep -q "crypto_LUKS" && DETECTED_LUKS=1 ${_LSBLK} FSTYPE | grep -q "crypto_LUKS" && _DETECTED_LUKS=1
if [[ "${DETECTED_LUKS}" == "1" ]]; then if [[ "${_DETECTED_LUKS}" == "1" ]]; then
DIALOG --defaultno --yesno "Setup detected not running luks encrypted devices, do you want to remove them completely?" 0 0 && DISABLELUKS="1" DIALOG --defaultno --yesno "Setup detected not running luks encrypted devices, do you want to remove them completely?" 0 0 && _DISABLELUKS="1"
fi fi
if [[ "${DISABLELUKS}" == "1" ]]; then if [[ "${_DISABLELUKS}" == "1" ]]; then
DIALOG --infobox "Removing not running luks encrypted devices ..." 0 0 DIALOG --infobox "Removing not running luks encrypted devices ..." 0 0
for i in $(${_LSBLK} NAME,FSTYPE | grep "crypto_LUKS$" | cut -d' ' -f1); do for i in $(${_LSBLK} NAME,FSTYPE | grep "crypto_LUKS$" | cut -d' ' -f1); do
# delete header from device # delete header from device
@ -484,9 +484,9 @@ _dmraid_update()
printk off printk off
DIALOG --infobox "Deactivating dmraid devices ..." 0 0 DIALOG --infobox "Deactivating dmraid devices ..." 0 0
dmraid -an >/dev/null 2>&1 dmraid -an >/dev/null 2>&1
if [[ "${DETECTED_LVM}" == "1" || "${DETECTED_LUKS}" == "1" ]]; then if [[ "${_DETECTED_LVM}" == "1" || "${_DETECTED_LUKS}" == "1" ]]; then
DIALOG --defaultno --yesno "Setup detected running dmraid devices and/or running lvm2, luks encrypted devices. If you reduced/deleted partitions on your dmraid device a complete reset of devicemapper devices is needed. This will reset also your created lvm2 or encrypted devices. Are you sure you want to do this?" 0 0 && RESETDM="1" DIALOG --defaultno --yesno "Setup detected running dmraid devices and/or running lvm2, luks encrypted devices. If you reduced/deleted partitions on your dmraid device a complete reset of devicemapper devices is needed. This will reset also your created lvm2 or encrypted devices. Are you sure you want to do this?" 0 0 && _RESETDM="1"
if [[ "${RESETDM}" == "1" ]]; then if [[ "${_RESETDM}" == "1" ]]; then
DIALOG --infobox "Resetting devicemapper devices ..." 0 0 DIALOG --infobox "Resetting devicemapper devices ..." 0 0
dmsetup remove_all >/dev/null 2>&1 dmsetup remove_all >/dev/null 2>&1
fi fi
@ -558,80 +558,80 @@ storage is duplication." 0 0
# Create raid or raid_partition # Create raid or raid_partition
_raid() _raid()
{ {
MDFINISH="" _MDFINISH=""
while [[ "${MDFINISH}" != "DONE" ]]; do while [[ "${_MDFINISH}" != "DONE" ]]; do
activate_special_devices activate_special_devices
: >/tmp/.raid : >/tmp/.raid
: >/tmp/.raid-spare : >/tmp/.raid-spare
# check for devices # check for devices
# Remove all raid devices with children # Remove all raid devices with children
RAID_BLACKLIST="$(raid_devices;partitionable_raid_devices_partitions)" _RAID_BLACKLIST="$(raid_devices;partitionable_raid_devices_partitions)"
#shellcheck disable=SC2119 #shellcheck disable=SC2119
PARTS="$(for i in $(findpartitions); do _PARTS="$(for i in $(findpartitions); do
echo "${RAID_BLACKLIST}" | grep -qw "${i}" || echo "${i}" _ echo "${_RAID_BLACKLIST}" | grep -qw "${i}" || echo "${i}" _
done)" done)"
# break if all devices are in use # break if all devices are in use
if [[ "${PARTS}" == "" ]]; then if [[ "${_PARTS}" == "" ]]; then
DIALOG --msgbox "All devices in use. No more devices left for new creation." 0 0 DIALOG --msgbox "All devices in use. No more devices left for new creation." 0 0
return 1 return 1
fi fi
# enter raid device name # enter raid device name
RAIDDEVICE="" _RAIDDEVICE=""
while [[ "${RAIDDEVICE}" == "" ]]; do while [[ -z "${_RAIDDEVICE}" ]]; do
DIALOG --inputbox "Enter the node name for the raiddevice:\n/dev/md[number]\n/dev/md0\n/dev/md1\n\n" 12 50 "/dev/md0" 2>"${_ANSWER}" || return 1 DIALOG --inputbox "Enter the node name for the raiddevice:\n/dev/md[number]\n/dev/md0\n/dev/md1\n\n" 12 50 "/dev/md0" 2>"${_ANSWER}" || return 1
RAIDDEVICE=$(cat "${_ANSWER}") _RAIDDEVICE=$(cat "${_ANSWER}")
if grep -q "^${RAIDDEVICE//\/dev\//}" /proc/mdstat; then if grep -q "^${_RAIDDEVICE//\/dev\//}" /proc/mdstat; then
DIALOG --msgbox "ERROR: You have defined 2 identical node names! Please enter another name." 8 65 DIALOG --msgbox "ERROR: You have defined 2 identical node names! Please enter another name." 8 65
RAIDDEVICE="" _RAIDDEVICE=""
fi fi
done done
RAIDLEVELS="linear - raid0 - raid1 - raid4 - raid5 - raid6 - raid10 -" _RAIDLEVELS="linear - raid0 - raid1 - raid4 - raid5 - raid6 - raid10 -"
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select the raid level you want to use:" 14 50 7 ${RAIDLEVELS} 2>"${_ANSWER}" || return 1 DIALOG --menu "Select the raid level you want to use:" 14 50 7 ${_RAIDLEVELS} 2>"${_ANSWER}" || return 1
LEVEL=$(cat "${_ANSWER}") _LEVEL=$(cat "${_ANSWER}")
# raid5 and raid10 support parity parameter # raid5 and raid10 support parity parameter
PARITY="" _PARITY=""
if [[ "${LEVEL}" == "raid5" || "${LEVEL}" == "raid6" || "${LEVEL}" == "raid10" ]]; then if [[ "${_LEVEL}" == "raid5" || "${_LEVEL}" == "raid6" || "${_LEVEL}" == "raid10" ]]; then
PARITYLEVELS="left-asymmetric - left-symmetric - right-asymmetric - right-symmetric -" _PARITYLEVELS="left-asymmetric - left-symmetric - right-asymmetric - right-symmetric -"
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select the parity layout you want to use (default is left-symmetric):" 21 50 13 ${PARITYLEVELS} 2>"${_ANSWER}" || return 1 DIALOG --menu "Select the parity layout you want to use (default is left-symmetric):" 21 50 13 ${_PARITYLEVELS} 2>"${_ANSWER}" || return 1
PARITY=$(cat "${_ANSWER}") _PARITY=$(cat "${_ANSWER}")
fi fi
# show all devices with sizes # show all devices with sizes
DIALOG --cr-wrap --msgbox "DISKS:\n$(_getavaildisks)\n\nPARTITIONS:\n$(_getavailpartitions)" 0 0 DIALOG --cr-wrap --msgbox "DISKS:\n$(_getavaildisks)\n\nPARTITIONS:\n$(_getavailpartitions)" 0 0
# select the first device to use, no missing option available! # select the first device to use, no missing option available!
RAIDNUMBER=1 _RAIDNUMBER=1
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select device ${RAIDNUMBER}:" 21 50 13 ${PARTS} 2>"${_ANSWER}" || return 1 DIALOG --menu "Select device ${_RAIDNUMBER}:" 21 50 13 ${_PARTS} 2>"${_ANSWER}" || return 1
PART=$(cat "${_ANSWER}") _PART=$(cat "${_ANSWER}")
echo "${PART}" >>/tmp/.raid echo "${_PART}" >>/tmp/.raid
while [[ "${PART}" != "DONE" ]]; do while [[ "${_PART}" != "DONE" ]]; do
RAIDNUMBER=$((RAIDNUMBER + 1)) _RAIDNUMBER=$((_RAIDNUMBER + 1))
# clean loop from used partition and options # clean loop from used partition and options
PARTS="$(echo "${PARTS}" | sed -e "s#${PART}\ _##g" -e 's#MISSING\ _##g' -e 's#SPARE\ _##g')" _PARTS="$(echo "${_PARTS}" | sed -e "s#${_PART}\ _##g" -e 's#MISSING\ _##g' -e 's#SPARE\ _##g')"
# raid0 doesn't support missing devices # raid0 doesn't support missing devices
! [[ "${LEVEL}" == "raid0" || "${LEVEL}" == "linear" ]] && MDEXTRA="MISSING _" ! [[ "${_LEVEL}" == "raid0" || "${_LEVEL}" == "linear" ]] && _MDEXTRA="MISSING _"
# add more devices # add more devices
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select additional device ${RAIDNUMBER}:" 21 50 13 ${PARTS} ${MDEXTRA} DONE _ 2>"${_ANSWER}" || return 1 DIALOG --menu "Select additional device ${_RAIDNUMBER}:" 21 50 13 ${_PARTS} ${_MDEXTRA} DONE _ 2>"${_ANSWER}" || return 1
PART=$(cat "${_ANSWER}") _PART=$(cat "${_ANSWER}")
SPARE="" _SPARE=""
! [[ "${LEVEL}" == "raid0" || "${LEVEL}" == "linear" ]] && DIALOG --yesno --defaultno "Would you like to use ${PART} as spare device?" 0 0 && SPARE="1" ! [[ "${_LEVEL}" == "raid0" || "${_LEVEL}" == "linear" ]] && DIALOG --yesno --defaultno "Would you like to use ${_PART} as spare device?" 0 0 && _SPARE="1"
[[ "${PART}" == "DONE" ]] && break [[ "${_PART}" == "DONE" ]] && break
if [[ "${PART}" == "MISSING" ]]; then if [[ "${_PART}" == "MISSING" ]]; then
DIALOG --yesno "Would you like to create a degraded raid on ${RAIDDEVICE}?" 0 0 && DEGRADED="missing" DIALOG --yesno "Would you like to create a degraded raid on ${_RAIDDEVICE}?" 0 0 && _DEGRADED="missing"
echo "${DEGRADED}" >>/tmp/.raid echo "${_DEGRADED}" >>/tmp/.raid
else else
if [[ "${SPARE}" == "1" ]]; then if [[ "${_SPARE}" == "1" ]]; then
echo "${PART}" >>/tmp/.raid-spare echo "${_PART}" >>/tmp/.raid-spare
else else
echo "${PART}" >>/tmp/.raid echo "${_PART}" >>/tmp/.raid
fi fi
fi fi
done done
# final step ask if everything is ok? # final step ask if everything is ok?
# shellcheck disable=SC2028 # shellcheck disable=SC2028
DIALOG --yesno "Would you like to create ${RAIDDEVICE} like this?\n\nLEVEL:\n${LEVEL}\n\nDEVICES:\n$(while read -r i;do echo "${i}\n"; done < /tmp/.raid)\nSPARES:\n$(while read -r i;do echo "${i}\n"; done < tmp/.raid-spare)" 0 0 && MDFINISH="DONE" DIALOG --yesno "Would you like to create ${_RAIDDEVICE} like this?\n\nLEVEL:\n${_LEVEL}\n\nDEVICES:\n$(while read -r i;do echo "${i}\n"; done < /tmp/.raid)\nSPARES:\n$(while read -r i;do echo "${i}\n"; done < tmp/.raid-spare)" 0 0 && _MDFINISH="DONE"
done done
_umountall _umountall
_createraid _createraid
@ -640,38 +640,38 @@ _raid()
# create raid device # create raid device
_createraid() _createraid()
{ {
DEVICES="$(echo -n "$(cat /tmp/.raid)")" _DEVICES="$(echo -n "$(cat /tmp/.raid)")"
SPARES="$(echo -n "$(cat /tmp/.raid-spare)")" _SPARES="$(echo -n "$(cat /tmp/.raid-spare)")"
# combine both if spares are available, spares at the end! # combine both if spares are available, spares at the end!
[[ -n ${SPARES} ]] && DEVICES="${DEVICES} ${SPARES}" [[ -n ${_SPARES} ]] && _DEVICES="${_DEVICES} ${_SPARES}"
# get number of devices # get number of devices
RAID_DEVICES="$(wc -l < /tmp/.raid)" _RAID_DEVICES="$(wc -l < /tmp/.raid)"
SPARE_DEVICES="$(wc -l < /tmp/.raid-spare)" _SPARE_DEVICES="$(wc -l < /tmp/.raid-spare)"
# generate options for mdadm # generate options for mdadm
RAIDOPTIONS="--force --run --level=${LEVEL}" _RAIDOPTIONS="--force --run --level=${_LEVEL}"
! [[ "${RAID_DEVICES}" == "0" ]] && RAIDOPTIONS="${RAIDOPTIONS} --raid-devices=${RAID_DEVICES}" ! [[ "${_RAID_DEVICES}" == "0" ]] && _RAIDOPTIONS="${_RAIDOPTIONS} --raid-devices=${_RAID_DEVICES}"
! [[ "${SPARE_DEVICES}" == "0" ]] && RAIDOPTIONS="${RAIDOPTIONS} --spare-devices=${SPARE_DEVICES}" ! [[ "${_SPARE_DEVICES}" == "0" ]] && _RAIDOPTIONS="${_RAIDOPTIONS} --spare-devices=${_SPARE_DEVICES}"
! [[ "${PARITY}" == "" ]] && RAIDOPTIONS="${RAIDOPTIONS} --layout=${PARITY}" ! [[ "${_PARITY}" == "" ]] && _RAIDOPTIONS="${_RAIDOPTIONS} --layout=${_PARITY}"
DIALOG --infobox "Creating ${RAIDDEVICE}..." 0 0 DIALOG --infobox "Creating ${_RAIDDEVICE}..." 0 0
#shellcheck disable=SC2086 #shellcheck disable=SC2086
if mdadm --create ${RAIDDEVICE} ${RAIDOPTIONS} ${DEVICES} >"${_LOG}" 2>&1; then if mdadm --create ${_RAIDDEVICE} ${_RAIDOPTIONS} ${_DEVICES} >"${_LOG}" 2>&1; then
DIALOG --infobox "${RAIDDEVICE} created successfully.\n\nContinuing in 3 seconds..." 5 50 DIALOG --infobox "${_RAIDDEVICE} created successfully.\n\nContinuing in 3 seconds..." 5 50
sleep 3 sleep 3
else else
DIALOG --msgbox "Error creating ${RAIDDEVICE} (see ${_LOG} for details)." 0 0 DIALOG --msgbox "Error creating ${_RAIDDEVICE} (see ${_LOG} for details)." 0 0
return 1 return 1
fi fi
if [[ ${RAID_PARTITION} == "1" ]]; then if [[ ${_RAID_PARTITION} == "1" ]]; then
# switch for mbr usage # switch for mbr usage
set_guid set_guid
if [[ "${_GUIDPARAMETER}" == "0" ]]; then if [[ "${_GUIDPARAMETER}" == "0" ]]; then
DIALOG --msgbox "Now you'll be put into the cfdisk program where you can partition your raiddevice to your needs." 6 70 DIALOG --msgbox "Now you'll be put into the cfdisk program where you can partition your raiddevice to your needs." 6 70
cfdisk "${RAIDDEVICE}" cfdisk "${_RAIDDEVICE}"
else else
DISC="${RAIDDEVICE}" _DISC="${_RAIDDEVICE}"
RUN_CFDISK="1" _RUN_CFDISK="1"
CHECK_BIOS_BOOT_GRUB="" _CHECK_BIOS_BOOT_GRUB=""
CHECK_UEFISYS_PART="" _CHECK_UEFISYS_PART=""
check_gpt check_gpt
fi fi
fi fi
@ -702,55 +702,55 @@ to modify.\n\nThe basic building block of LVM are:\n
# Creates physical volume # Creates physical volume
_createpv() _createpv()
{ {
PVFINISH="" _PVFINISH=""
while [[ "${PVFINISH}" != "DONE" ]]; do while [[ "${_PVFINISH}" != "DONE" ]]; do
activate_special_devices activate_special_devices
: >/tmp/.pvs-create : >/tmp/.pvs-create
# Remove all lvm devices with children # Remove all lvm devices with children
LVM_BLACKLIST="$(for i in $(${_LSBLK} NAME,TYPE | grep " lvm$" | cut -d' ' -f1 | sort -u); do _LVM_BLACKLIST="$(for i in $(${_LSBLK} NAME,TYPE | grep " lvm$" | cut -d' ' -f1 | sort -u); do
echo "$(${_LSBLK} NAME "${i}")" _ echo "$(${_LSBLK} NAME "${i}")" _
done)" done)"
#shellcheck disable=SC2119 #shellcheck disable=SC2119
PARTS="$(for i in $(findpartitions); do _PARTS="$(for i in $(findpartitions); do
! echo "${LVM_BLACKLIST}" | grep -E "${i} _" && echo "${i}" _ ! echo "${_LVM_BLACKLIST}" | grep -E "${i} _" && echo "${i}" _
done)" done)"
# break if all devices are in use # break if all devices are in use
if [[ "${PARTS}" == "" ]]; then if [[ "${_PARTS}" == "" ]]; then
DIALOG --msgbox "No devices left for physical volume creation." 0 0 DIALOG --msgbox "No devices left for physical volume creation." 0 0
return 1 return 1
fi fi
# show all devices with sizes # show all devices with sizes
DIALOG --cr-wrap --msgbox "DISKS:\n$(_getavaildisks)\n\nPARTITIONS:\n$(_getavailpartitions)\n\n" 0 0 DIALOG --cr-wrap --msgbox "DISKS:\n$(_getavaildisks)\n\nPARTITIONS:\n$(_getavailpartitions)\n\n" 0 0
# select the first device to use # select the first device to use
DEVNUMBER=1 _DEVNUMBER=1
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select device number ${DEVNUMBER} for physical volume:" 15 50 12 ${PARTS} 2>"${_ANSWER}" || return 1 DIALOG --menu "Select device number ${_DEVNUMBER} for physical volume:" 15 50 12 ${_PARTS} 2>"${_ANSWER}" || return 1
PART=$(cat "${_ANSWER}") _PART=$(cat "${_ANSWER}")
echo "${PART}" >>/tmp/.pvs-create echo "${_PART}" >>/tmp/.pvs-create
while [[ "${PART}" != "DONE" ]]; do while [[ "${_PART}" != "DONE" ]]; do
DEVNUMBER="$((DEVNUMBER + 1))" _DEVNUMBER="$((_DEVNUMBER + 1))"
# clean loop from used partition and options # clean loop from used partition and options
PARTS="${PARTS//${PART}\ _/}" _PARTS="${_PARTS//${_PART}\ _/}"
# add more devices # add more devices
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select additional device number ${DEVNUMBER} for physical volume:" 15 60 12 ${PARTS} DONE _ 2>"${_ANSWER}" || return 1 DIALOG --menu "Select additional device number ${_DEVNUMBER} for physical volume:" 15 60 12 ${_PARTS} DONE _ 2>"${_ANSWER}" || return 1
PART=$(cat "${_ANSWER}") _PART=$(cat "${_ANSWER}")
[[ "${PART}" == "DONE" ]] && break [[ "${_PART}" == "DONE" ]] && break
echo "${PART}" >>/tmp/.pvs-create echo "${_PART}" >>/tmp/.pvs-create
done done
# final step ask if everything is ok? # final step ask if everything is ok?
DIALOG --yesno "Would you like to create physical volume on devices below?\n$(sed -e 's#$#\\n#g' /tmp/.pvs-create)" 0 0 && PVFINISH="DONE" DIALOG --yesno "Would you like to create physical volume on devices below?\n$(sed -e 's#$#\\n#g' /tmp/.pvs-create)" 0 0 && _PVFINISH="DONE"
done done
DIALOG --infobox "Creating physical volume on ${PART}..." 0 0 DIALOG --infobox "Creating physical volume on ${_PART}..." 0 0
PART="$(echo -n "$(cat /tmp/.pvs-create)")" _PART="$(echo -n "$(cat /tmp/.pvs-create)")"
#shellcheck disable=SC2028,SC2086 #shellcheck disable=SC2028,SC2086
_umountall _umountall
#shellcheck disable=SC2086 #shellcheck disable=SC2086
if pvcreate -y ${PART} >"${_LOG}" 2>&1; then if pvcreate -y ${_PART} >"${_LOG}" 2>&1; then
DIALOG --infobox "Creating physical volume on ${PART} successful.\n\nContinuing in 3 seconds..." 6 75 DIALOG --infobox "Creating physical volume on ${_PART} successful.\n\nContinuing in 3 seconds..." 6 75
sleep 3 sleep 3
else else
DIALOG --msgbox "Error creating physical volume on ${PART} (see ${_LOG} for details)." 0 0; return 1 DIALOG --msgbox "Error creating physical volume on ${_PART} (see ${_LOG} for details)." 0 0; return 1
fi fi
# run udevadm to get values exported # run udevadm to get values exported
udevadm trigger udevadm trigger
@ -811,59 +811,59 @@ getavailablevg()
# Creates volume group # Creates volume group
_createvg() _createvg()
{ {
VGFINISH="" _VGFINISH=""
while [[ "${VGFINISH}" != "DONE" ]]; do while [[ "${_VGFINISH}" != "DONE" ]]; do
: >/tmp/.pvs : >/tmp/.pvs
VGDEVICE="" _VGDEVICE=""
PVS=$(findpv _) _PVS=$(findpv _)
# break if all devices are in use # break if all devices are in use
if [[ "${PVS}" == "" ]]; then if [[ -z "${PVS}" ]]; then
DIALOG --msgbox "No devices left for Volume Group creation." 0 0 DIALOG --msgbox "No devices left for Volume Group creation." 0 0
return 1 return 1
fi fi
# enter volume group name # enter volume group name
VGDEVICE="" _VGDEVICE=""
while [[ "${VGDEVICE}" == "" ]]; do while [[ -z "${_VGDEVICE}" ]]; do
DIALOG --inputbox "Enter the Volume Group name:\nfoogroup\n<yourvolumegroupname>\n\n" 11 40 "foogroup" 2>"${_ANSWER}" || return 1 DIALOG --inputbox "Enter the Volume Group name:\nfoogroup\n<yourvolumegroupname>\n\n" 11 40 "foogroup" 2>"${_ANSWER}" || return 1
VGDEVICE=$(cat "${_ANSWER}") _VGDEVICE=$(cat "${_ANSWER}")
if vgs -o vg_name --noheading 2>/dev/null | grep -q "^ ${VGDEVICE}"; then if vgs -o vg_name --noheading 2>/dev/null | grep -q "^ ${_VGDEVICE}"; then
DIALOG --msgbox "ERROR: You have defined 2 identical Volume Group names! Please enter another name." 8 65 DIALOG --msgbox "ERROR: You have defined 2 identical Volume Group names! Please enter another name." 8 65
VGDEVICE="" _VGDEVICE=""
fi fi
done done
# show all devices with sizes, which are not in use # show all devices with sizes, which are not in use
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --cr-wrap --msgbox "Physical Volumes:\n$(getavailablepv)" 0 0 DIALOG --cr-wrap --msgbox "Physical Volumes:\n$(getavailablepv)" 0 0
# select the first device to use, no missing option available! # select the first device to use, no missing option available!
PVNUMBER=1 _PVNUMBER=1
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select Physical Volume ${PVNUMBER} for ${VGDEVICE}:" 13 50 10 ${PVS} 2>"${_ANSWER}" || return 1 DIALOG --menu "Select Physical Volume ${_PVNUMBER} for ${_VGDEVICE}:" 13 50 10 ${_PVS} 2>"${_ANSWER}" || return 1
PV=$(cat "${_ANSWER}") _PV=$(cat "${_ANSWER}")
echo "${PV}" >>/tmp/.pvs echo "${_PV}" >>/tmp/.pvs
while [[ "${PVS}" != "DONE" ]]; do while [[ "${_PVS}" != "DONE" ]]; do
PVNUMBER=$((PVNUMBER + 1)) _PVNUMBER=$((_PVNUMBER + 1))
# clean loop from used partition and options # clean loop from used partition and options
#shellcheck disable=SC2001,SC2086 #shellcheck disable=SC2001,SC2086
PVS="$(echo ${PVS} | sed -e "s#${PV} _##g")" _PVS="$(echo ${_PVS} | sed -e "s#${_PV} _##g")"
# add more devices # add more devices
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select additional Physical Volume ${PVNUMBER} for ${VGDEVICE}:" 13 50 10 ${PVS} DONE _ 2>"${_ANSWER}" || return 1 DIALOG --menu "Select additional Physical Volume ${_PVNUMBER} for ${_VGDEVICE}:" 13 50 10 ${_PVS} DONE _ 2>"${_ANSWER}" || return 1
PV=$(cat "${_ANSWER}") _PV=$(cat "${_ANSWER}")
[[ "${PV}" == "DONE" ]] && break [[ "${_PV}" == "DONE" ]] && break
echo "${PV}" >>/tmp/.pvs echo "${_PV}" >>/tmp/.pvs
done done
# final step ask if everything is ok? # final step ask if everything is ok?
DIALOG --yesno "Would you like to create Volume Group like this?\n\n${VGDEVICE}\n\nPhysical Volumes:\n$(sed -e 's#$#\\n#g' /tmp/.pvs)" 0 0 && VGFINISH="DONE" DIALOG --yesno "Would you like to create Volume Group like this?\n\n${_VGDEVICE}\n\nPhysical Volumes:\n$(sed -e 's#$#\\n#g' /tmp/.pvs)" 0 0 && _VGFINISH="DONE"
done done
DIALOG --infobox "Creating Volume Group ${VGDEVICE}..." 0 0 DIALOG --infobox "Creating Volume Group ${_VGDEVICE}..." 0 0
PV="$(echo -n "$(cat /tmp/.pvs)")" _PV="$(echo -n "$(cat /tmp/.pvs)")"
_umountall _umountall
#shellcheck disable=SC2086 #shellcheck disable=SC2086
if vgcreate ${VGDEVICE} ${PV} >"${_LOG}" 2>&1; then if vgcreate ${_VGDEVICE} ${_PV} >"${_LOG}" 2>&1; then
DIALOG --infobox "Creating Volume Group ${VGDEVICE} successful.\n\nContinuing in 3 seconds..." 5 50 DIALOG --infobox "Creating Volume Group ${_VGDEVICE} successful.\n\nContinuing in 3 seconds..." 5 50
sleep 3 sleep 3
else else
DIALOG --msgbox "Error creating Volume Group ${VGDEVICE} (see ${_LOG} for details)." 0 0 DIALOG --msgbox "Error creating Volume Group ${_VGDEVICE} (see ${_LOG} for details)." 0 0
return 1 return 1
fi fi
} }
@ -871,82 +871,82 @@ _createvg()
# Creates logical volume # Creates logical volume
_createlv() _createlv()
{ {
LVFINISH="" _LVFINISH=""
while [[ "${LVFINISH}" != "DONE" ]]; do while [[ "${_LVFINISH}" != "DONE" ]]; do
LVDEVICE="" _LVDEVICE=""
LV_SIZE_SET="" _LV_SIZE_SET=""
LVS=$(findvg _) _LVS=$(findvg _)
# break if all devices are in use # break if all devices are in use
if [[ "${LVS}" == "" ]]; then if [[ "${_LVS}" == "" ]]; then
DIALOG --msgbox "No Volume Groups with free space available for Logical Volume creation." 0 0 DIALOG --msgbox "No Volume Groups with free space available for Logical Volume creation." 0 0
return 1 return 1
fi fi
# show all devices with sizes, which are not 100% in use! # show all devices with sizes, which are not 100% in use!
DIALOG --cr-wrap --msgbox "Volume Groups:\n$(getavailablevg)" 0 0 DIALOG --cr-wrap --msgbox "Volume Groups:\n$(getavailablevg)" 0 0
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select Volume Group:" 11 50 5 ${LVS} 2>"${_ANSWER}" || return 1 DIALOG --menu "Select Volume Group:" 11 50 5 ${_LVS} 2>"${_ANSWER}" || return 1
LV=$(cat "${_ANSWER}") _LV=$(cat "${_ANSWER}")
# enter logical volume name # enter logical volume name
LVDEVICE="" _LVDEVICE=""
while [[ "${LVDEVICE}" == "" ]]; do while [[ -z "${LVDEVICE}" ]]; do
DIALOG --inputbox "Enter the Logical Volume name:\nfooname\n<yourvolumename>\n\n" 10 65 "fooname" 2>"${_ANSWER}" || return 1 DIALOG --inputbox "Enter the Logical Volume name:\nfooname\n<yourvolumename>\n\n" 10 65 "fooname" 2>"${_ANSWER}" || return 1
LVDEVICE=$(cat "${_ANSWER}") _LVDEVICE=$(cat "${_ANSWER}")
if lvs -o lv_name,vg_name --noheading 2>/dev/null | grep -q " ${LVDEVICE} ${LV}$"; then if lvs -o lv_name,vg_name --noheading 2>/dev/null | grep -q " ${_LVDEVICE} ${_LV}$"; then
DIALOG --msgbox "ERROR: You have defined 2 identical Logical Volume names! Please enter another name." 8 65 DIALOG --msgbox "ERROR: You have defined 2 identical Logical Volume names! Please enter another name." 8 65
LVDEVICE="" _LVDEVICE=""
fi fi
done done
while [[ "${LV_SIZE_SET}" == "" ]]; do while [[ -z "${_LV_SIZE_SET}" ]]; do
LV_ALL="" _LV_ALL=""
DIALOG --inputbox "Enter the size (MB) of your Logical Volume,\nMinimum value is > 0.\n\nVolume space left: $(vgs -o vg_free --noheading --units m "${LV}")B\n\nIf you enter no value, all free space left will be used." 10 65 "" 2>"${_ANSWER}" || return 1 DIALOG --inputbox "Enter the size (MB) of your Logical Volume,\nMinimum value is > 0.\n\nVolume space left: $(vgs -o vg_free --noheading --units m "${_LV}")B\n\nIf you enter no value, all free space left will be used." 10 65 "" 2>"${_ANSWER}" || return 1
LV_SIZE=$(cat "${_ANSWER}") _LV_SIZE=$(cat "${_ANSWER}")
if [[ "${LV_SIZE}" == "" ]]; then if [[ -z "${_LV_SIZE}" ]]; then
DIALOG --yesno "Would you like to create Logical Volume with no free space left?" 0 0 && LV_ALL="1" DIALOG --yesno "Would you like to create Logical Volume with no free space left?" 0 0 && _LV_ALL="1"
if ! [[ "${LV_ALL}" == "1" ]]; then if ! [[ "${_LV_ALL}" == "1" ]]; then
LV_SIZE=0 _LV_SIZE=0
fi fi
fi fi
if [[ "${LV_SIZE}" == "0" ]]; then if [[ "${_LV_SIZE}" == "0" ]]; then
DIALOG --msgbox "ERROR: You have entered a invalid size, please enter again." 0 0 DIALOG --msgbox "ERROR: You have entered a invalid size, please enter again." 0 0
else else
if [[ "${LV_SIZE}" -ge "$(vgs -o vg_free --noheading --units m | sed -e 's#m##g')" ]]; then if [[ "${_LV_SIZE}" -ge "$(vgs -o vg_free --noheading --units m | sed -e 's#m##g')" ]]; then
DIALOG --msgbox "ERROR: You have entered a too large size, please enter again." 0 0 DIALOG --msgbox "ERROR: You have entered a too large size, please enter again." 0 0
else else
LV_SIZE_SET=1 _LV_SIZE_SET=1
fi fi
fi fi
done done
#Contiguous doesn't work with +100%FREE #Contiguous doesn't work with +100%FREE
LV_CONTIGUOUS="" _LV_CONTIGUOUS=""
[[ "${LV_ALL}" == "" ]] && DIALOG --defaultno --yesno "Would you like to create Logical Volume as a contiguous partition, that means that your space doesn't get partitioned over one or more disks nor over non-contiguous physical extents.\n(usefull for swap space etc.)?" 0 0 && LV_CONTIGUOUS="1" [[ -z "${_LV_ALL}" ]] && DIALOG --defaultno --yesno "Would you like to create Logical Volume as a contiguous partition, that means that your space doesn't get partitioned over one or more disks nor over non-contiguous physical extents.\n(usefull for swap space etc.)?" 0 0 && _LV_CONTIGUOUS="1"
if [[ "${LV_CONTIGUOUS}" == "1" ]]; then if [[ "${_LV_CONTIGUOUS}" == "1" ]]; then
CONTIGUOUS=yes _CONTIGUOUS=yes
LV_EXTRA="-C y" _LV_EXTRA="-C y"
else else
CONTIGUOUS=no _CONTIGUOUS=no
LV_EXTRA="" _LV_EXTRA=""
fi fi
[[ "${LV_SIZE}" == "" ]] && LV_SIZE="All free space left" [[ "${_LV_SIZE}" == "" ]] && _LV_SIZE="All free space left"
# final step ask if everything is ok? # final step ask if everything is ok?
DIALOG --yesno "Would you like to create Logical Volume ${LVDEVICE} like this?\nVolume Group:\n${LV}\nVolume Size:\n${LV_SIZE}\nContiguous Volume:\n${CONTIGUOUS}" 0 0 && LVFINISH="DONE" DIALOG --yesno "Would you like to create Logical Volume ${_LVDEVICE} like this?\nVolume Group:\n${_LV}\nVolume Size:\n${_LV_SIZE}\nContiguous Volume:\n${_CONTIGUOUS}" 0 0 && _LVFINISH="DONE"
done done
_umountall _umountall
if [[ "${LV_ALL}" == "1" ]]; then if [[ "${_LV_ALL}" == "1" ]]; then
#shellcheck disable=SC2086 #shellcheck disable=SC2086
if lvcreate ${LV_EXTRA} -l +100%FREE ${LV} -n ${LVDEVICE} >"${_LOG}" 2>&1; then if lvcreate ${_LV_EXTRA} -l +100%FREE ${_LV} -n ${_LVDEVICE} >"${_LOG}" 2>&1; then
DIALOG --infobox "Creating Logical Volume ${LVDEVICE} successful.\n\nContinuing in 3 seconds..." 5 50 DIALOG --infobox "Creating Logical Volume ${_LVDEVICE} successful.\n\nContinuing in 3 seconds..." 5 50
sleep 3 sleep 3
else else
DIALOG --msgbox "Error creating Logical Volume ${LVDEVICE} (see ${_LOG} for details)." 0 0 DIALOG --msgbox "Error creating Logical Volume ${_LVDEVICE} (see ${_LOG} for details)." 0 0
return 1 return 1
fi fi
else else
#shellcheck disable=SC2086 #shellcheck disable=SC2086
if lvcreate ${LV_EXTRA} -L ${LV_SIZE} ${LV} -n ${LVDEVICE} >"${_LOG}" 2>&1; then if lvcreate ${_LV_EXTRA} -L ${_LV_SIZE} ${_LV} -n ${_LVDEVICE} >"${_LOG}" 2>&1; then
DIALOG --infobox "Creating Logical Volume ${LVDEVICE} successful.\n\nContinuing in 3 seconds..." 5 50 DIALOG --infobox "Creating Logical Volume ${_LVDEVICE} successful.\n\nContinuing in 3 seconds..." 5 50
sleep 3 sleep 3
else else
DIALOG --msgbox "Error creating Logical Volume ${LVDEVICE} (see ${_LOG} for details)." 0 0 DIALOG --msgbox "Error creating Logical Volume ${_LVDEVICE} (see ${_LOG} for details)." 0 0
return 1 return 1
fi fi
fi fi
@ -954,29 +954,29 @@ _createlv()
# enter luks name # enter luks name
_enter_luks_name() { _enter_luks_name() {
LUKSDEVICE="" _LUKSDEVICE=""
while [[ "${LUKSDEVICE}" == "" ]]; do while [[ -z "${_LUKSDEVICE}" ]]; do
DIALOG --inputbox "Enter the name for luks encrypted device ${PART}:\nfooname\n<yourname>\n\n" 10 65 "fooname" 2>"${_ANSWER}" || return 1 DIALOG --inputbox "Enter the name for luks encrypted device ${_PART}:\nfooname\n<yourname>\n\n" 10 65 "fooname" 2>"${_ANSWER}" || return 1
LUKSDEVICE=$(cat "${_ANSWER}") _LUKSDEVICE=$(cat "${_ANSWER}")
if ! cryptsetup status "${LUKSDEVICE}" | grep -q inactive; then if ! cryptsetup status "${_LUKSDEVICE}" | grep -q inactive; then
DIALOG --msgbox "ERROR: You have defined 2 identical luks encryption device names! Please enter another name." 8 65 DIALOG --msgbox "ERROR: You have defined 2 identical luks encryption device names! Please enter another name." 8 65
LUKSDEVICE="" _LUKSDEVICE=""
fi fi
done done
} }
# enter luks passphrase # enter luks passphrase
_enter_luks_passphrase () { _enter_luks_passphrase () {
LUKSPASSPHRASE="" _LUKSPASSPHRASE=""
while [[ "${LUKSPASSPHRASE}" == "" ]]; do while [[ -z "${LUKSPASSPHRASE}" ]]; do
DIALOG --insecure --passwordbox "Enter passphrase for luks encrypted device ${PART}:" 0 0 2>"${_ANSWER}" || return 1 DIALOG --insecure --passwordbox "Enter passphrase for luks encrypted device ${_PART}:" 0 0 2>"${_ANSWER}" || return 1
LUKSPASS=$(cat "${_ANSWER}") _LUKSPASS=$(cat "${_ANSWER}")
DIALOG --insecure --passwordbox "Retype passphrase for luks encrypted device ${PART}:" 0 0 2>"${_ANSWER}" || return 1 DIALOG --insecure --passwordbox "Retype passphrase for luks encrypted device ${_PART}:" 0 0 2>"${_ANSWER}" || return 1
LUKSPASS2=$(cat "${_ANSWER}") _LUKSPASS2=$(cat "${_ANSWER}")
if [[ -n "${LUKSPASS}" && -n "${LUKSPASS2}" && "${LUKSPASS}" == "${LUKSPASS2}" ]]; then if [[ -n "${_LUKSPASS}" && -n "${_LUKSPASS2}" && "${_LUKSPASS}" == "${_LUKSPASS2}" ]]; then
LUKSPASSPHRASE=${LUKSPASS} _LUKSPASSPHRASE=${_LUKSPASS}
echo "${LUKSPASSPHRASE}" > "/tmp/passphrase-${LUKSDEVICE}" echo "${_LUKSPASSPHRASE}" > "/tmp/passphrase-${_LUKSDEVICE}"
LUKSPASSPHRASE="/tmp/passphrase-${LUKSDEVICE}" _LUKSPASSPHRASE="/tmp/passphrase-${_LUKSDEVICE}"
else else
DIALOG --msgbox "Passphrases didn't match or was empty, please enter again." 0 0 DIALOG --msgbox "Passphrases didn't match or was empty, please enter again." 0 0
fi fi
@ -985,17 +985,17 @@ _enter_luks_passphrase () {
# opening luks # opening luks
_opening_luks() { _opening_luks() {
DIALOG --infobox "Opening encrypted ${PART}..." 0 0 DIALOG --infobox "Opening encrypted ${_PART}..." 0 0
luksOpen_success="0" _LUKSOPEN_SUCCESS=0
while [[ "${luksOpen_success}" == "0" ]]; do while [[ "${_LUKSOPEN_SUCCESS}" == "0" ]]; do
cryptsetup luksOpen "${PART}" "${LUKSDEVICE}" <"${LUKSPASSPHRASE}" >"${_LOG}" && luksOpen_success=1 cryptsetup luksOpen "${_PART}" "${_LUKSDEVICE}" <"${_LUKSPASSPHRASE}" >"${_LOG}" && _LUKSOPEN_SUCCESS=1
if [[ "${luksOpen_success}" == "0" ]]; then if [[ "${_LUKSOPEN_SUCCESS}" == "0" ]]; then
DIALOG --msgbox "Error: Passphrase didn't match, please enter again." 0 0 DIALOG --msgbox "Error: Passphrase didn't match, please enter again." 0 0
_enter_luks_passphrase || return 1 _enter_luks_passphrase || return 1
fi fi
done done
DIALOG --yesno "Would you like to save the passphrase of luks device in /etc/$(basename "${LUKSPASSPHRASE}")?\nName:${LUKSDEVICE}" 0 0 || LUKSPASSPHRASE="ASK" DIALOG --yesno "Would you like to save the passphrase of luks device in /etc/$(basename "${_LUKSPASSPHRASE}")?\nName:${_LUKSDEVICE}" 0 0 || _LUKSPASSPHRASE="ASK"
echo "${LUKSDEVICE}" "${PART}" "/etc/$(basename "${LUKSPASSPHRASE}")" >> /tmp/.crypttab echo "${_LUKSDEVICE}" "${_PART}" "/etc/$(basename "${_LUKSPASSPHRASE}")" >> /tmp/.crypttab
} }
# help for luks # help for luks
@ -1024,38 +1024,38 @@ are other ways to break into computers, while they are running." 0 0
# create luks device # create luks device
_luks() _luks()
{ {
NAME_SCHEME_PARAMETER_RUN="" _NAME_SCHEME_PARAMETER_RUN=""
LUKSFINISH="" _LUKSFINISH=""
while [[ "${LUKSFINISH}" != "DONE" ]]; do while [[ "${_LUKSFINISH}" != "DONE" ]]; do
activate_special_devices activate_special_devices
# Remove all crypt devices with children # Remove all crypt devices with children
CRYPT_BLACKLIST="$(for i in $(${_LSBLK} NAME,TYPE | grep " crypt$" | cut -d' ' -f1 | sort -u); do _CRYPT_BLACKLIST="$(for i in $(${_LSBLK} NAME,TYPE | grep " crypt$" | cut -d' ' -f1 | sort -u); do
${_LSBLK} NAME "${i}" ${_LSBLK} NAME "${i}"
done)" done)"
#shellcheck disable=SC2119 #shellcheck disable=SC2119
PARTS="$(for i in $(findpartitions); do _PARTS="$(for i in $(findpartitions); do
echo "${CRYPT_BLACKLIST}" | grep -wq "${i}" || echo "${i}" _; echo "${_CRYPT_BLACKLIST}" | grep -wq "${i}" || echo "${i}" _;
done)" done)"
# break if all devices are in use # break if all devices are in use
if [[ "${PARTS}" == "" ]]; then if [[ "${_PARTS}" == "" ]]; then
DIALOG --msgbox "No devices left for luks encryption." 0 0 DIALOG --msgbox "No devices left for luks encryption." 0 0
return 1 return 1
fi fi
# show all devices with sizes # show all devices with sizes
DIALOG --cr-wrap --msgbox "DISKS:\n$(_getavaildisks)\n\nPARTITIONS:\n$(_getavailpartitions)\n\n" 0 0 DIALOG --cr-wrap --msgbox "DISKS:\n$(_getavaildisks)\n\nPARTITIONS:\n$(_getavailpartitions)\n\n" 0 0
#shellcheck disable=SC2086 #shellcheck disable=SC2086
DIALOG --menu "Select device for luks encryption:" 15 50 12 ${PARTS} 2>"${_ANSWER}" || return 1 DIALOG --menu "Select device for luks encryption:" 15 50 12 ${_PARTS} 2>"${_ANSWER}" || return 1
PART=$(cat "${_ANSWER}") _PART=$(cat "${_ANSWER}")
# enter luks name # enter luks name
_enter_luks_name || return 1 _enter_luks_name || return 1
### TODO: offer more options for encrypt! ### TODO: offer more options for encrypt!
### defaults are used only ### defaults are used only
# final step ask if everything is ok? # final step ask if everything is ok?
DIALOG --yesno "Would you like to encrypt luks device below?\nName:${LUKSDEVICE}\nDevice:${PART}\n" 0 0 && LUKSFINISH="DONE" DIALOG --yesno "Would you like to encrypt luks device below?\nName:${_LUKSDEVICE}\nDevice:${_PART}\n" 0 0 && _LUKSFINISH="DONE"
done done
_enter_luks_passphrase || return 1 _enter_luks_passphrase || return 1
_umountall _umountall
DIALOG --infobox "Encrypting ${PART}..." 0 0 DIALOG --infobox "Encrypting ${_PART}..." 0 0
cryptsetup -q luksFormat "${PART}" <"${LUKSPASSPHRASE}" >"${_LOG}" cryptsetup -q luksFormat "${_PART}" <"${_LUKSPASSPHRASE}" >"${_LOG}"
_opening_luks _opening_luks
} }

View file

@ -320,7 +320,7 @@ EOF
do_efistub_parameters() { do_efistub_parameters() {
bootdev="" bootdev=""
FAIL_COMPLEX="" FAIL_COMPLEX=""
USE_DMRAID="" _USE_DMRAID=""
RAID_ON_LVM="" RAID_ON_LVM=""
UEFISYS_PATH="EFI/archlinux" UEFISYS_PATH="EFI/archlinux"
_bootdev="$(findmnt -vno SOURCE "${_DESTDIR}/boot")" _bootdev="$(findmnt -vno SOURCE "${_DESTDIR}/boot")"
@ -525,12 +525,12 @@ do_grub_common_before() {
## - Encryption is not recommended for grub(2) /boot! ## - Encryption is not recommended for grub(2) /boot!
bootdev="" bootdev=""
FAIL_COMPLEX="" FAIL_COMPLEX=""
USE_DMRAID="" _USE_DMRAID=""
RAID_ON_LVM="" RAID_ON_LVM=""
common_bootloader_checks common_bootloader_checks
abort_f2fs_bootpart || return 1 abort_f2fs_bootpart || return 1
if ! dmraid -r | grep -q ^no; then if ! dmraid -r | grep -q ^no; then
DIALOG --yesno "Setup detected dmraid device.\nDo you want to install grub on this device?" 6 50 && USE_DMRAID="1" DIALOG --yesno "Setup detected dmraid device.\nDo you want to install grub on this device?" 6 50 && _USE_DMRAID="1"
fi fi
if [[ ! -d "${_DESTDIR}/usr/lib/grub" ]]; then if [[ ! -d "${_DESTDIR}/usr/lib/grub" ]]; then
DIALOG --infobox "Installing grub ..." 0 0 DIALOG --infobox "Installing grub ..." 0 0