simplify getavailablepv

This commit is contained in:
Tobias Powalowski 2013-07-25 09:30:31 +02:00
parent c933cc2c8c
commit 8f2feb9a04

View file

@ -1102,18 +1102,14 @@ findpv()
getavailablepv() getavailablepv()
{ {
for i in "$(pvs -o pv_name,pv_size --noheading --units m)"; do for i in $(${_LSBLK} NAME,FSTYPE | grep " LVM2_member$" | cut -d' ' -f1); do
if [[ "$(echo ${i} | grep /dev/dm-)" ]]; then # exclude checks:
for k in $(ls /dev/mapper | grep -v control); do #- not part of running lvm2
if [[ -h /dev/mapper/${k} ]]; then # ! "$(${_LSBLK} TYPE ${i} | grep "lvm")"
pv="$(basename ${i})" #- not part of volume group
if [[ "$(readlink /dev/mapper/${k} | grep ${pv}$)" ]]; then # $(pvs -o vg_name --noheading ${i} | grep " $")
echo "${i}" | sed -e "s#/dev/dm-.* #/dev/mapper/${k} #g" | sed -e 's#$#\\n#' if [[ ! "$(${_LSBLK} TYPE ${i} | grep "lvm")" && $(pvs -o vg_name --noheading ${i} | grep " $") ]]; then
fi echo "$(${_LSBLK} NAME,SIZE ${i})"
fi
done
else
echo "${i}" | sed -e 's#$#\\n#'
fi fi
done done
} }
@ -1161,8 +1157,8 @@ _createvg()
VGDEVICE="" VGDEVICE=""
fi fi
done done
# show all devices with sizes # show all devices with sizes, which are not in use
DIALOG --msgbox "Physical Volumes:\n$(getavailablepv)\n\nPhysical Volumes that are not shown in next dialog, are already in use!" 0 0 DIALOG --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
DIALOG --menu "Select Physical Volume ${PVNUMBER} for ${VGDEVICE}" 21 50 13 ${PVS} 2>${ANSWER} || return 1 DIALOG --menu "Select Physical Volume ${PVNUMBER} for ${VGDEVICE}" 21 50 13 ${PVS} 2>${ANSWER} || return 1