File collect_lvm of Package lvm2

#!/bin/sh
PVNAME=$1

source /etc/sysconfig/lvm

/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	 

  lvlist=$(/sbin/lvm lvs --config "devices {filter = [ \"a|$PVNAME|\", \"r/.*/\" ]}" --partial -o lv_name,lv_attr --ignorelockingfailure --noheadings $vgname 2>/dev/null | while read lvname lvattr; do
    if [[ $lvattr =~ mode. ]] ; then
      continue
    fi
    if [[ $lvattr =~ ....-. ]]; then
      echo -n $lvname
    fi
  done)

  if [ -z "$lvlist" ] ; 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

  if [[ -n $LVM_VGS_ACTIVATED_ON_BOOT ]]; then
    found=0
    for autovg in $LVM_VGS_ACTIVATED_ON_BOOT; do
      if [[ $vgname == $autovg ]]; then
        found=1
        break
      fi
    done
    if [[ $found == 0 ]]; then
      echo COLLECT=1
      exit 0
    fi
  fi

  collected=0
  for pv in $pvlist; do
    if [[ x$pv = x$pvuuid ]]; then
	  continue
	fi
    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

openSUSE Build Service is sponsored by