master - vgimportclone.sh: use well defined tests
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ef4506069a1a29cd005...
Commit: ef4506069a1a29cd00532e36c24df9a01cd32600
Parent: 8dc29d7cc7e86295116a4fb401315896b6793fa8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 20:35:34 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
vgimportclone.sh: use well defined tests
Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
---
scripts/vgimportclone.sh | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index ac52f01..7d3118f 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -95,8 +95,7 @@ function cleanup {
SCRIPTNAME=$("$BASENAME" "$0")
-if [ "$UID" != "0" -a "$EUID" != "0" ]
-then
+if [ "$UID" != 0 ] && [ "$EUID" != 0 ]; then
die 3 "${SCRIPTNAME} must be run as root."
fi
@@ -183,14 +182,13 @@ do
done
# turn on DEBUG (special case associated with -v use)
-if [ -z "$DEBUG" -a $VERBOSE_COUNT -gt 3 ]; then
+if [ -z "$DEBUG" ] && [ "$VERBOSE_COUNT" -gt 3 ]; then
DEBUG="-d"
set -x
fi
# setup LVM_OPTS
-if [ -n "${DEBUG}" -o -n "${VERBOSE}" ]
-then
+if [ -n "$DEBUG" ] || [ -n "$VERBOSE" ]; then
LVM_OPTS="${LVM_OPTS} ${DEBUG} ${VERBOSE}"
fi
6 years, 9 months
master - vgimportclone.sh: drop extra $
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8dc29d7cc7e86295116...
Commit: 8dc29d7cc7e86295116a4fb401315896b6793fa8
Parent: 16a38dede95cbcd7bfd80bb2124ce205a20c5a2f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 20:31:09 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
vgimportclone.sh: drop extra $
$/${} is unnecessary on arithmetic variables.
---
scripts/vgimportclone.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index 48ac6ce..ac52f01 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -50,7 +50,7 @@ function getvgname {
while [[ "${VGLIST}" =~ ":${NAME}:" ]]
do
- I=$(($I+1))
+ I=$(( I + 1 ))
NAME="${BNAME}$I"
done
echo "${NAME}"
@@ -201,7 +201,7 @@ do
then
ln -s "$ARG" "${TMP_LVM_SYSTEM_DIR}/vgimport${DEVNO}"
DISKS="${DISKS} ${TMP_LVM_SYSTEM_DIR}/vgimport${DEVNO}"
- DEVNO=$((${DEVNO}+1))
+ DEVNO=$(( DEVNO + 1 ))
else
die 3 "$ARG is not a block device."
fi
6 years, 9 months
master - vgimportclone.sh: add -r to read
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=16a38dede95cbcd7bfd...
Commit: 16a38dede95cbcd7bfd80bb2124ce205a20c5a2f
Parent: 588b12e71d7f050ca14e6f9332e7a0ec6b66a4b8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 20:26:23 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
vgimportclone.sh: add -r to read
read without -r will mangle backslashes.
---
scripts/vgimportclone.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index 26e4c1f..48ac6ce 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -259,7 +259,7 @@ NOVGDEVLIST=$("$LVM" pvs -a -o pv_name --select vg_name="" --noheadings)
checkvalue $? "Failed to collect information for PV check"
if [ -n "${NOVGDEVLIST}" ]; then
FOLLOWLIST=""
- while read PVNAME; do
+ while read -r PVNAME; do
FOLLOW=$("$READLINK" "$PVNAME")
FOLLOWLIST="$FOLLOWLIST $FOLLOW"
done <<< "$(echo "$NOVGDEVLIST")"
@@ -272,7 +272,7 @@ fi
VGLIST=$("$LVM" vgs -o vg_name,vg_exported,vg_missing_pv_count --noheadings --binary)
checkvalue $? "Failed to collect VG information"
-while read VGNAME VGEXPORTED VGMISSINGPVCOUNT; do
+while read -r VGNAME VGEXPORTED VGMISSINGPVCOUNT; do
if [ "$VGMISSINGPVCOUNT" -gt 0 ]; then
echo "Volume Group ${VGNAME} has unknown PV(s), skipping."
echo "- Were all associated PV(s) supplied as arguments?"
6 years, 9 months
master - vgimportclone.sh: avoid legacy syntax
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=588b12e71d7f050ca14...
Commit: 588b12e71d7f050ca14e6f9332e7a0ec6b66a4b8
Parent: d745593e8929bd2ebf928e897a4b7d549ea46cf1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 20:20:15 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
vgimportclone.sh: avoid legacy syntax
Use $(..) instead of legacy `..`.
---
scripts/vgimportclone.sh | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index f621f99..26e4c1f 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -92,7 +92,7 @@ function cleanup {
fi
}
-SCRIPTNAME=`"$BASENAME" $0`
+SCRIPTNAME=$("$BASENAME" "$0")
if [ "$UID" != "0" -a "$EUID" != "0" ]
@@ -104,7 +104,7 @@ LVM_OPTS=""
TEST_OPT=""
DISKS=""
# for compatibility: using mktemp -t rather than --tmpdir
-TMP_LVM_SYSTEM_DIR=`"$MKTEMP" -d -t snap.XXXXXXXX`
+TMP_LVM_SYSTEM_DIR=$("$MKTEMP" -d -t snap.XXXXXXXX)
KEEP_TMP_LVM_SYSTEM_DIR=0
CHANGES_MADE=0
IMPORT=0
@@ -122,9 +122,9 @@ trap cleanup 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18
#####################################################################
### Get and check arguments
#####################################################################
-OPTIONS=`"$GETOPT" -o n:dhitv \
+OPTIONS=$("$GETOPT" -o n:dhitv \
-l basevgname:,debug,help,import,quiet,test,verbose,version \
- -n "${SCRIPTNAME}" -- "$@"`
+ -n "${SCRIPTNAME}" -- "$@")
[ $? -ne 0 ] && usage
eval set -- "$OPTIONS"
@@ -219,7 +219,7 @@ fi
### :vgname1:vgname2:...:vgnameN:
#####################################################################
-OLDVGS=":`"${LVM}" vgs ${LVM_OPTS} -o name --noheadings --rows --separator : --config 'log{prefix=""}'`:"
+OLDVGS=":$("$LVM" vgs ${LVM_OPTS} -o name --noheadings --rows --separator : --config 'log{prefix=""}'):"
checkvalue $? "Current VG names could not be collected without errors"
#####################################################################
@@ -255,21 +255,21 @@ export LVM_SYSTEM_DIR=${TMP_LVM_SYSTEM_DIR}
# Check if there are any PVs that don't belong to any VG
# or even if there are disks which are not PVs at all.
-NOVGDEVLIST=`${LVM} pvs -a -o pv_name --select vg_name="" --noheadings`
+NOVGDEVLIST=$("$LVM" pvs -a -o pv_name --select vg_name="" --noheadings)
checkvalue $? "Failed to collect information for PV check"
if [ -n "${NOVGDEVLIST}" ]; then
FOLLOWLIST=""
while read PVNAME; do
- FOLLOW=`$READLINK $PVNAME`
+ FOLLOW=$("$READLINK" "$PVNAME")
FOLLOWLIST="$FOLLOWLIST $FOLLOW"
- done <<< "`echo "${NOVGDEVLIST}"`"
+ done <<< "$(echo "$NOVGDEVLIST")"
die 8 "Specified devices don't belong to a VG:$FOLLOWLIST"
fi
#####################################################################
### Rename the VG(s) and change the VG and PV UUIDs.
#####################################################################
-VGLIST=`${LVM} vgs -o vg_name,vg_exported,vg_missing_pv_count --noheadings --binary`
+VGLIST=$("$LVM" vgs -o vg_name,vg_exported,vg_missing_pv_count --noheadings --binary)
checkvalue $? "Failed to collect VG information"
while read VGNAME VGEXPORTED VGMISSINGPVCOUNT; do
@@ -292,7 +292,7 @@ while read VGNAME VGEXPORTED VGMISSINGPVCOUNT; do
"$LVM" pvchange ${LVM_OPTS} ${TEST_OPT} --uuid --config 'global{activation=0}' --select "vg_name=${VGNAME}"
checkvalue $? "Unable to change all PV uuids in VG ${VGNAME}"
- NEWVGNAME=`getvgname "${OLDVGS}" "${VGNAME}" "${NEWVG}"`
+ NEWVGNAME=$(getvgname "$OLDVGS" "$VGNAME" "$NEWVG")
"$LVM" vgchange ${LVM_OPTS} ${TEST_OPT} --uuid --config 'global{activation=0}' "$VGNAME"
checkvalue $? "Unable to change VG uuid for ${VGNAME}"
@@ -305,7 +305,7 @@ while read VGNAME VGEXPORTED VGMISSINGPVCOUNT; do
fi
CHANGES_MADE=1
-done <<< "`echo "${VGLIST}"`"
+done <<< "$(echo "$VGLIST")"
#####################################################################
### Restore the old environment
6 years, 9 months
master - vgimportclone.sh: cannot trap signal 9
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d745593e8929bd2ebf9...
Commit: d745593e8929bd2ebf928e897a4b7d549ea46cf1
Parent: 275eeb4631657fcb43d27d6cd309f690869c4e2e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 20:06:59 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
vgimportclone.sh: cannot trap signal 9
---
scripts/vgimportclone.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index 23181ea..f621f99 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -117,7 +117,7 @@ if [ -n "${LVM_SYSTEM_DIR}" ]; then
export ORIG_LVM_SYS_DIR="${LVM_SYSTEM_DIR}"
fi
-trap cleanup 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
+trap cleanup 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18
#####################################################################
### Get and check arguments
6 years, 9 months
master - vgimportclone.sh: double quote
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=275eeb4631657fcb43d...
Commit: 275eeb4631657fcb43d27d6cd309f690869c4e2e
Parent: 96a2e0024070ee35d68cf0beeeed283bf74318ab
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 20:05:42 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
vgimportclone.sh: double quote
---
scripts/vgimportclone.sh | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index da79591..23181ea 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# Copyright (C) 2009 Chris Procter All rights reserved.
-# Copyright (C) 2009-2015 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2009-2017 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -30,7 +30,7 @@ LVM="${LVM_BINARY:-lvm}"
die() {
code=$1; shift
echo "Fatal:" "$@" 1>&2
- exit $code
+ exit "$code"
}
"$LVM" version >& /dev/null || die 2 "Could not run lvm binary '$LVM'"
@@ -59,9 +59,8 @@ function getvgname {
function checkvalue {
### check return value and error if non zero
- if [ $1 -ne 0 ]
- then
- die $1 "$2, error: $1"
+ if [ "$1" -ne 0 ]; then
+ die "$1" "$2, error: $1"
fi
}
@@ -86,7 +85,7 @@ function cleanup {
#set to use old lvm.conf
LVM_SYSTEM_DIR=${ORIG_LVM_SYS_DIR}
- if [ $KEEP_TMP_LVM_SYSTEM_DIR -eq 1 ]; then
+ if [ "$KEEP_TMP_LVM_SYSTEM_DIR" -eq 1 ]; then
echo "${SCRIPTNAME}: LVM_SYSTEM_DIR (${TMP_LVM_SYSTEM_DIR}) must be cleaned up manually."
else
"$RM" -rf -- "${TMP_LVM_SYSTEM_DIR}"
@@ -200,7 +199,7 @@ for ARG
do
if [ -b "$ARG" ]
then
- ln -s "$ARG" ${TMP_LVM_SYSTEM_DIR}/vgimport${DEVNO}
+ ln -s "$ARG" "${TMP_LVM_SYSTEM_DIR}/vgimport${DEVNO}"
DISKS="${DISKS} ${TMP_LVM_SYSTEM_DIR}/vgimport${DEVNO}"
DEVNO=$((${DEVNO}+1))
else
@@ -245,7 +244,7 @@ CMD_CONFIG_LINE="devices { \
use_lvmetad = 0 \
}"
-$LVM dumpconfig ${LVM_OPTS} --file ${LVMCONF} --mergedconfig --config "${CMD_CONFIG_LINE}"
+$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
@@ -274,7 +273,7 @@ VGLIST=`${LVM} vgs -o vg_name,vg_exported,vg_missing_pv_count --noheadings --bin
checkvalue $? "Failed to collect VG information"
while read VGNAME VGEXPORTED VGMISSINGPVCOUNT; do
- if [ $VGMISSINGPVCOUNT -gt 0 ]; then
+ if [ "$VGMISSINGPVCOUNT" -gt 0 ]; then
echo "Volume Group ${VGNAME} has unknown PV(s), skipping."
echo "- Were all associated PV(s) supplied as arguments?"
continue
@@ -295,7 +294,7 @@ while read VGNAME VGEXPORTED VGMISSINGPVCOUNT; do
NEWVGNAME=`getvgname "${OLDVGS}" "${VGNAME}" "${NEWVG}"`
- "$LVM" vgchange ${LVM_OPTS} ${TEST_OPT} --uuid --config 'global{activation=0}' ${VGNAME}
+ "$LVM" vgchange ${LVM_OPTS} ${TEST_OPT} --uuid --config 'global{activation=0}' "$VGNAME"
checkvalue $? "Unable to change VG uuid for ${VGNAME}"
## if the name isn't going to get changed dont even try.
@@ -325,7 +324,7 @@ if [ ${CHANGES_MADE} -eq 1 ]
then
# get global/use_lvmetad config and if set also notify lvmetad about changes
# since we were running LVM commands above with use_lvmetad=0
- eval $(${LVM} dumpconfig ${LVM_OPTS} global/use_lvmetad)
+ eval "$("$LVM" dumpconfig ${LVM_OPTS} global/use_lvmetad)"
if [ "$use_lvmetad" = "1" ]
then
echo "Notifying lvmetad about changes since it was disabled temporarily."
6 years, 9 months
master - vgimportclone.sh: no mixing string and array
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=96a2e0024070ee35d68...
Commit: 96a2e0024070ee35d68cf0beeeed283bf74318ab
Parent: 4d34bc65dd05beb734c8ae65b86a11b37c3c2c94
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 19:40:34 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
vgimportclone.sh: no mixing string and array
Argument mixes string and array. Use * or separate argument.
---
scripts/vgimportclone.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index d5b62a8..da79591 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -29,7 +29,7 @@ LVM="${LVM_BINARY:-lvm}"
die() {
code=$1; shift
- echo "Fatal: $@" 1>&2
+ echo "Fatal:" "$@" 1>&2
exit $code
}
6 years, 9 months
master - lvm2_cluster_activation_red_hat.sh: double quote
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4d34bc65dd05beb734c...
Commit: 4d34bc65dd05beb734c8ae65b86a11b37c3c2c94
Parent: 051c7f88cf8968feab241604cb09547e23a79599
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 22:12:23 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
lvm2_cluster_activation_red_hat.sh: double quote
---
scripts/lvm2_cluster_activation_red_hat.sh.in | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/scripts/lvm2_cluster_activation_red_hat.sh.in b/scripts/lvm2_cluster_activation_red_hat.sh.in
index abea026..04d2cc6 100644
--- a/scripts/lvm2_cluster_activation_red_hat.sh.in
+++ b/scripts/lvm2_cluster_activation_red_hat.sh.in
@@ -2,30 +2,30 @@
sbindir=@sbindir@
-lvm_vgchange=${sbindir}/vgchange
-lvm_vgscan=${sbindir}/vgscan
-lvm_vgs=${sbindir}/vgs
-lvm_lvm=${sbindir}/lvm
+lvm_vgchange="${sbindir}/vgchange"
+lvm_vgscan="${sbindir}/vgscan"
+lvm_vgs="${sbindir}/vgs"
+lvm_lvm="${sbindir}/lvm"
clustered_vgs() {
- ${lvm_vgs} --noheadings -o vg_name -S 'vg_clustered=1' 2>/dev/null
+ "${lvm_vgs}" --noheadings -o vg_name -S 'vg_clustered=1' 2>/dev/null
}
activate() {
- eval local $(${lvm_lvm} dumpconfig devices/obtain_device_list_from_udev 2>/dev/null) 2>/dev/null
+ eval local "$("${lvm_lvm}" dumpconfig devices/obtain_device_list_from_udev 2>/dev/null)" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Warning: expected single couple of key=value in output of dumpconfig"
fi
- if [ -z $obtain_device_list_from_udev -o $obtain_device_list_from_udev -ne 1 ]; then
+ if [ -z "$obtain_device_list_from_udev" ] || [ "$obtain_device_list_from_udev" -ne 1 ]; then
echo -n "lvm.conf option obtain_device_list_from_udev!=1: Executing vgscan"
- ${lvm_vgscan} > /dev/null 2>&1
+ "${lvm_vgscan}" > /dev/null 2>&1
fi
echo -n "Activating ${LVM_VGS:-"all VG(s)"}: "
# Respect activation/auto_activation_volume_list!
# Call "-aay" which is equal to "-aly" but respects this list.
- ${lvm_vgchange} -aay $LVM_VGS || return 1
+ "${lvm_vgchange}" -aay $LVM_VGS || return 1
return 0
}
@@ -35,10 +35,10 @@ deactivate()
# NOTE: following section will be replaced by blkdeactivate script
# with option supporting request to deactivate all clustered volume
# groups in the system
- [ -z $LVM_VGS ] && LVM_VGS="$(clustered_vgs)"
+ [ -z "$LVM_VGS" ] && LVM_VGS="$(clustered_vgs)"
if [ -n "$LVM_VGS" ]; then
echo -n "Deactivating clustered VG(s): "
- ${lvm_vgchange} -anl $LVM_VGS || return 1
+ "${lvm_vgchange}" -anl $LVM_VGS || return 1
fi
return 0
@@ -59,4 +59,4 @@ case "$1" in
;;
esac
-exit $rtrn
+exit "$rtrn"
6 years, 9 months
master - lvmconf_lockingtype2: double quote
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=051c7f88cf8968feab2...
Commit: 051c7f88cf8968feab241604cb09547e23a79599
Parent: ef8691a2d22e6a7afabdcdde93676b562a5fcfa1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 21:13:52 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
lvmconf_lockingtype2: double quote
---
scripts/lvmconf_lockingtype2.sh | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/scripts/lvmconf_lockingtype2.sh b/scripts/lvmconf_lockingtype2.sh
index 225b41d..52929d3 100644
--- a/scripts/lvmconf_lockingtype2.sh
+++ b/scripts/lvmconf_lockingtype2.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
#
# This file is part of the lvm2-cluster package.
#
@@ -34,7 +34,7 @@ function usage
function parse_args
{
while [ -n "$1" ]; do
- case $1 in
+ case "$1" in
--enable-cluster)
LOCKING_TYPE=2
shift
@@ -135,19 +135,19 @@ have_dir=1
have_library=1
have_global=1
-grep -q '^[[:blank:]]*locking_type[[:blank:]]*=' $CONFIGFILE
+grep -q '^[[:blank:]]*locking_type[[:blank:]]*=' "$CONFIGFILE"
have_type=$?
-grep -q '^[[:blank:]]*library_dir[[:blank:]]*=' $CONFIGFILE
+grep -q '^[[:blank:]]*library_dir[[:blank:]]*=' "$CONFIGFILE"
have_dir=$?
-grep -q '^[[:blank:]]*locking_library[[:blank:]]*=' $CONFIGFILE
+grep -q '^[[:blank:]]*locking_library[[:blank:]]*=' "$CONFIGFILE"
have_library=$?
# Those options are in section "global {" so we must have one if any are present.
if [ "$have_type" = "0" ] || [ "$have_dir" = "0" ] || [ "$have_library" = "0" ]; then
# See if we can find it...
- grep -q '^[[:blank:]]*global[[:blank:]]*{' $CONFIGFILE
+ grep -q '^[[:blank:]]*global[[:blank:]]*{' "$CONFIGFILE"
have_global=$?
if [ "$have_global" = "1" ]
@@ -171,7 +171,7 @@ then
LOCKING_TYPE=1
fi
if [ "$LOCKING_TYPE" = "2" ]; then
- cat $CONFIGFILE - <<EOF > $TMPFILE
+ cat "$CONFIGFILE" - <<EOF > $TMPFILE
global {
# Enable locking for cluster LVM
locking_type = $LOCKING_TYPE
@@ -230,8 +230,8 @@ else
fi
fi
- echo -e $SEDCMD > $SCRIPTFILE
- sed <$CONFIGFILE >$TMPFILE -f $SCRIPTFILE
+ echo -e "$SEDCMD" > "$SCRIPTFILE"
+ sed <"$CONFIGFILE" >"$TMPFILE" -f "$SCRIPTFILE"
if [ $? != 0 ]
then
echo "sed failed, $CONFIGFILE not updated"
@@ -242,18 +242,18 @@ fi
# Now we have a suitably editted config file in a temp place,
# backup the original and copy our new one into place.
-cp $CONFIGFILE $CONFIGFILE.lvmconfold
+cp "$CONFIGFILE" "$CONFIGFILE.lvmconfold"
if [ $? != 0 ]
then
echo "failed to backup old config file, $CONFIGFILE not updated"
exit 2
fi
-cp $TMPFILE $CONFIGFILE
+cp "$TMPFILE" "$CONFIGFILE"
if [ $? != 0 ]
then
echo "failed to copy new config file into place, check $CONFIGFILE is still OK"
exit 3
fi
-rm -f $SCRIPTFILE $TMPFILE
+rm -f "$SCRIPTFILE" "$TMPFILE"
6 years, 9 months
master - lvmconf_lockingtype2: preferable syntax
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ef8691a2d22e6a7afab...
Commit: ef8691a2d22e6a7afabdcdde93676b562a5fcfa1
Parent: 030912ec03f4ad1874351dbfb2048fa73477d914
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 21:09:52 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
lvmconf_lockingtype2: preferable syntax
Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
---
scripts/lvmconf_lockingtype2.sh | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/lvmconf_lockingtype2.sh b/scripts/lvmconf_lockingtype2.sh
index 395ef07..225b41d 100644
--- a/scripts/lvmconf_lockingtype2.sh
+++ b/scripts/lvmconf_lockingtype2.sh
@@ -110,8 +110,10 @@ function validate_args
fi
- if [ "$LOCKING_TYPE" = "1" ] && [ -n "$LOCKINGLIBDIR" -o -n "$LOCKINGLIB" ]; then
- echo "Superfluous locking lib parameter, ignoring"
+ if [ "$LOCKING_TYPE" = "1" ] ; then
+ if [ -n "$LOCKINGLIBDIR" ] || [ -n "$LOCKINGLIB" ]; then
+ echo "Superfluous locking lib parameter, ignoring"
+ fi
fi
}
@@ -143,9 +145,7 @@ grep -q '^[[:blank:]]*locking_library[[:blank:]]*=' $CONFIGFILE
have_library=$?
# Those options are in section "global {" so we must have one if any are present.
-if [ "$have_type" = "0" -o "$have_dir" = "0" -o "$have_library" = "0" ]
-then
-
+if [ "$have_type" = "0" ] || [ "$have_dir" = "0" ] || [ "$have_library" = "0" ]; then
# See if we can find it...
grep -q '^[[:blank:]]*global[[:blank:]]*{' $CONFIGFILE
have_global=$?
6 years, 9 months