1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

vgimportclone: replace awk with dumpconfig to generate temporary lvm.conf for vgimportclone

With current dumpconfig, we can generate lvm.conf easily - we can merge
current lvm.conf with the config given on cmd line:
  lvm dumpconfig --mergedconfig --config "..."

This is a bit simpler than using awk and it also avoids problems when some of
the configuration is missing in existing lvm.conf file and hardcoded defaults
are used instead. The dumpconfig handles this transparently.
This commit is contained in:
Peter Rajnoha 2014-12-10 13:25:23 +01:00
parent 5378a1a63e
commit 00b36ef06a
2 changed files with 12 additions and 11 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
Fix vgimportclone to properly override config if it is missing in lvm.conf.
Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
Add report/compact_output to lvm.conf to enable/disable compact report output.

View File

@ -242,17 +242,17 @@ export FILTER="filter=[ ${FILTER} \"r|.*|\" ]"
LVMCONF=${TMP_LVM_SYSTEM_DIR}/lvm.conf
# FIXME convert to cmdline override
"$LVM" dumpconfig ${LVM_OPTS} | \
"$AWK" -v DEV=${TMP_LVM_SYSTEM_DIR} -v CACHE=${TMP_LVM_SYSTEM_DIR}/.cache \
-v CACHE_DIR=${TMP_LVM_SYSTEM_DIR}/cache \
'/^[ \t]*filter[ \t]*=/{print ENVIRON["FILTER"];next} \
/^[ \t]*scan[ \t]*=/{print "scan = [ \"" DEV "\" ]";next} \
/^[ \t]*cache[ \t]*=/{print "cache = \"" CACHE "\"";next} \
/^[ \t]*use_lvmetad[ \t]*=/{print "use_lvmetad = 0";next} \
/^[ \t]*global_filter[ \t]*=/{print "global_filter = [ \"a|.*|\" ]";next} \
/^[ \t]*cache_dir[ \t]*=/{print "cache_dir = \"" CACHE_DIR "\"";next} \
{print $0}' > ${LVMCONF}
CMD_CONFIG_LINE="devices { \
scan = [ \"${TMP_LVM_SYSTEM_DIR}\" ] \
cache_dir = \"$TMP_LVM_SYSTEM_DIR}/cache\"
global_filter = [ \"a|.*|\" ] \
${FILTER}
} \
global { \
use_lvmetad = 0 \
}"
$LVM dumpconfig ${LVM_OPTS} --file ${LVMCONF} --mergedconfig --config "${CMD_CONFIG_LINE}"
checkvalue $? "Failed to generate ${LVMCONF}"
# Only keep TMP_LVM_SYSTEM_DIR if it contains something worth keeping