Commit 01cb077d authored by Bernhard Landauer's avatar Bernhard Landauer
Browse files

luks/lvm functions more logical order

parent 86b38b7e
...@@ -454,20 +454,25 @@ make_swap() { ...@@ -454,20 +454,25 @@ make_swap() {
ini mount.swap "${PARTITION}" ini mount.swap "${PARTITION}"
} }
# Had to write it in this way due to (bash?) bug(?), as if/then statements in a single luks_menu() {
# "create LUKS" function for default and "advanced" modes were interpreted as commands, LUKS_OPT=""
# not mere string statements. Not happy with it, but it works...
luks_password() {
DIALOG " $_PrepLUKS " --clear --insecure --passwordbox "\n$_LuksPassBody\n " 0 0 2> ${ANSWER} || return 0
PASSWD=$(cat ${ANSWER})
DIALOG " $_PrepLUKS " --clear --insecure --passwordbox "\n$_PassReEntBody\n " 0 0 2> ${ANSWER} || return 0 DIALOG " $_PrepLUKS " --menu "\n$_LuksMenuBody$_LuksMenuBody2$_LuksMenuBody3\n " 0 0 4 \
PASSWD2=$(cat ${ANSWER}) "$_LuksOpen" "cryptsetup open --type luks" \
"$_LuksEncrypt" "cryptsetup -q luksFormat" \
"$_LuksEncryptAdv" "cryptsetup -q -s -c luksFormat" \
"$_Back" "-" 2>${ANSWER}
if [[ $PASSWD != $PASSWD2 ]]; then case $(cat ${ANSWER}) in
DIALOG " $_ErrTitle " --msgbox "\n$_PassErrBody\n " 0 0 "$_LuksOpen") luks_open
luks_password ;;
fi "$_LuksEncrypt") luks_setup && luks_default && luks_show
;;
"$_LuksEncryptAdv") luks_setup && luks_key_define && luks_show
;;
*) return 0
;;
esac
} }
luks_open() { luks_open() {
...@@ -501,6 +506,22 @@ luks_open() { ...@@ -501,6 +506,22 @@ luks_open() {
DIALOG " $_DevShowOpt " --textbox /tmp/.devlist 0 0 DIALOG " $_DevShowOpt " --textbox /tmp/.devlist 0 0
} }
# Had to write it in this way due to (bash?) bug(?), as if/then statements in a single
# "create LUKS" function for default and "advanced" modes were interpreted as commands,
# not mere string statements. Not happy with it, but it works...
luks_password() {
DIALOG " $_PrepLUKS " --clear --insecure --passwordbox "\n$_LuksPassBody\n " 0 0 2> ${ANSWER} || return 0
PASSWD=$(cat ${ANSWER})
DIALOG " $_PrepLUKS " --clear --insecure --passwordbox "\n$_PassReEntBody\n " 0 0 2> ${ANSWER} || return 0
PASSWD2=$(cat ${ANSWER})
if [[ $PASSWD != $PASSWD2 ]]; then
DIALOG " $_ErrTitle " --msgbox "\n$_PassErrBody\n " 0 0
luks_password
fi
}
luks_setup() { luks_setup() {
modprobe -a dm-mod dm_crypt modprobe -a dm-mod dm_crypt
INCLUDE_PART='part\|lvm' INCLUDE_PART='part\|lvm'
...@@ -549,25 +570,31 @@ luks_show() { ...@@ -549,25 +570,31 @@ luks_show() {
DIALOG " $_LuksEncrypt " --textbox /tmp/.devlist 0 0 DIALOG " $_LuksEncrypt " --textbox /tmp/.devlist 0 0
} }
luks_menu() { lvm_menu() {
LUKS_OPT="" declare -i loopmenu=1
while ((loopmenu)); do
DIALOG " $_PrepLVM $_PrepLVM2 " --infobox "\n$_PlsWaitBody\n " 0 0
sleep 1
lvm_detect
DIALOG " $_PrepLUKS " --menu "\n$_LuksMenuBody$_LuksMenuBody2$_LuksMenuBody3\n " 0 0 4 \ DIALOG " $_PrepLVM $_PrepLVM2 " --menu "\n$_LvmMenu\n " 0 0 4 \
"$_LuksOpen" "cryptsetup open --type luks" \ "$_LvmCreateVG" "vgcreate -f, lvcreate -L -n" \
"$_LuksEncrypt" "cryptsetup -q luksFormat" \ "$_LvmDelVG" "vgremove -f" \
"$_LuksEncryptAdv" "cryptsetup -q -s -c luksFormat" \ "$_LvMDelAll" "lvrmeove, vgremove, pvremove -f" \
"$_Back" "-" 2>${ANSWER} "$_Back" "-" 2>${ANSWER}
case $(cat ${ANSWER}) in case $(cat ${ANSWER}) in
"$_LuksOpen") luks_open "$_LvmCreateVG") lvm_create
;; ;;
"$_LuksEncrypt") luks_setup && luks_default && luks_show "$_LvmDelVG") lvm_del_vg
;; ;;
"$_LuksEncryptAdv") luks_setup && luks_key_define && luks_show "$_LvMDelAll") lvm_del_all
;; ;;
*) return 0 *) loopmenu=0
;; return 0
esac ;;
esac
done
} }
lvm_detect() { lvm_detect() {
...@@ -584,15 +611,6 @@ lvm_detect() { ...@@ -584,15 +611,6 @@ lvm_detect() {
fi fi
} }
lvm_show_vg() {
VG_LIST=""
vg_list=$(lvs --noheadings | awk '{print $2}' | uniq)
for i in ${vg_list}; do
VG_LIST="${VG_LIST} ${i} $(vgdisplay ${i} | grep -i "vg size" | awk '{print $3$4}')"
done
}
# Create Volume Group and Logical Volumes # Create Volume Group and Logical Volumes
lvm_create() { lvm_create() {
# Find LVM appropriate partitions. # Find LVM appropriate partitions.
...@@ -781,6 +799,15 @@ lvm_del_vg() { ...@@ -781,6 +799,15 @@ lvm_del_vg() {
fi fi
} }
lvm_show_vg() {
VG_LIST=""
vg_list=$(lvs --noheadings | awk '{print $2}' | uniq)
for i in ${vg_list}; do
VG_LIST="${VG_LIST} ${i} $(vgdisplay ${i} | grep -i "vg size" | awk '{print $3$4}')"
done
}
lvm_del_all() { lvm_del_all() {
# check if VG exist at all # check if VG exist at all
if [[ $(lvs) == "" ]]; then if [[ $(lvs) == "" ]]; then
...@@ -814,33 +841,6 @@ lvm_del_all() { ...@@ -814,33 +841,6 @@ lvm_del_all() {
fi fi
} }
lvm_menu() {
declare -i loopmenu=1
while ((loopmenu)); do
DIALOG " $_PrepLVM $_PrepLVM2 " --infobox "\n$_PlsWaitBody\n " 0 0
sleep 1
lvm_detect
DIALOG " $_PrepLVM $_PrepLVM2 " --menu "\n$_LvmMenu\n " 0 0 4 \
"$_LvmCreateVG" "vgcreate -f, lvcreate -L -n" \
"$_LvmDelVG" "vgremove -f" \
"$_LvMDelAll" "lvrmeove, vgremove, pvremove -f" \
"$_Back" "-" 2>${ANSWER}
case $(cat ${ANSWER}) in
"$_LvmCreateVG") lvm_create
;;
"$_LvmDelVG") lvm_del_vg
;;
"$_LvMDelAll") lvm_del_all
;;
*) loopmenu=0
return 0
;;
esac
done
}
mount_partitions() { mount_partitions() {
# Warn users that they CAN mount partitions without formatting them! # Warn users that they CAN mount partitions without formatting them!
DIALOG " $_PrepMntPart " --msgbox "\n$_WarnMount1 '$_FSSkip' $_WarnMount2\n " 0 0 DIALOG " $_PrepMntPart " --msgbox "\n$_WarnMount1 '$_FSSkip' $_WarnMount2\n " 0 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment