lvm2/collect_lvm

38 lines
921 B
Bash

#!/bin/sh
PVNAME=$1
/sbin/lvm pvs --config "devices {filter = [ \"a|$PVNAME|\", \"r/.*/\" ]}" --partial -o vg_name,vg_attr,pv_uuid,vg_uuid --ignorelockingfailure --noheadings $PVNAME 2>/dev/null | while read vgname vgattr pvuuid vguuid; do
if [[ $vgattr =~ mode. ]]; then
continue
fi
if [[ $vgattr =~ .....c ]]; then
exit 1
fi
pvlist=$(/sbin/lvm vgdisplay --config "devices {filter = [ \"a|$PVNAME|\", \"r/.*/\" ]}" --partial -v $vgname 2>/dev/null | while read str1 str2 val; do
if [[ $str1 =~ PV && $str2 =~ UUID ]]; then
echo $val
fi
done)
echo PVUUID=$pvuuid
echo VGUUID=$vguuid
echo VGNAME=$vgname
collected=0
for pv in $pvlist; do
if [[ ! -h /dev/disk/by-id/lvm2-pvuuid-$pv ]]; then
echo COLLECT=1
collected=1
break
fi
done
if [[ $collected == 0 ]]; then
echo COLLECT=0
fi
# /lib/udev/collect $vguuid $pvuuid $pvlist
# echo COLLECT=$?
done