Skip to content

Commit

Permalink
New code using 'awk' + fixed is_disk_a_pv() function
Browse files Browse the repository at this point in the history
  • Loading branch information
rmetrich committed Aug 10, 2018
1 parent c5e4e79 commit c260234
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Expand Up @@ -28,7 +28,7 @@ fi
# Create a new PV.
create_lvmdev() {
local lvmdev vgrp device uuid junk
read lvmdev vgrp device uuid junk < <(grep -w "^lvmdev.*${1#pv:}" "$LAYOUT_FILE")
read lvmdev vgrp device uuid junk < <(awk "\$1 == \"lvmdev\" && \$3 == \"${1#pv:}\" { print }" "$LAYOUT_FILE")

local vg=${vgrp#/dev/}

Expand Down Expand Up @@ -126,7 +126,7 @@ fi
EOF
fi

local -a devices=($(grep "^lvmdev $vgrp " "$LAYOUT_FILE" | cut -d " " -f 3))
local -a devices=($(awk "\$1 == \"lvmdev\" && \$2 == \"$vgrp\" { print \$3 }" "$LAYOUT_FILE"))

cat >> "$LAYOUT_CODE" <<EOF
if [ \$create_volume_group -eq 1 ] ; then
Expand Down
9 changes: 4 additions & 5 deletions usr/share/rear/lib/layout-functions.sh
Expand Up @@ -637,11 +637,10 @@ blkid_label_of_device() {
# Returns 0 otherwise or if the device doesn't exists
is_disk_a_pv() {
disk=$1
if grep -qw "^lvmdev .* ${disk}" $LAYOUT_FILE ; then
return 0
else
return 1
fi

# exit 0 == not a PV, so fallthrough
awk "\$1 == \"lvmdev\" && \$3 == \"${disk}\" { exit 1 }" "$LAYOUT_FILE" >/dev/null || return 1
return 0
}

function is_multipath_path {
Expand Down

0 comments on commit c260234

Please sign in to comment.