|
|
da32ae |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
da32ae |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
da32ae |
Date: Wed, 2 Feb 2022 17:00:21 -0600
|
|
|
da32ae |
Subject: [PATCH] RH: add support to mpathconf for setting arbitrary default
|
|
|
da32ae |
options
|
|
|
da32ae |
|
|
|
da32ae |
mpathconf now supports --option <name>:[<value>] for setting, changing,
|
|
|
da32ae |
or removing options from the defaults section of multipath.conf.
|
|
|
da32ae |
|
|
|
da32ae |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
da32ae |
---
|
|
|
da32ae |
multipath/mpathconf | 58 ++++++++++++++++++++++++++++++++++++++++---
|
|
|
da32ae |
multipath/mpathconf.8 | 7 ++++++
|
|
|
da32ae |
2 files changed, 62 insertions(+), 3 deletions(-)
|
|
|
da32ae |
|
|
|
da32ae |
diff --git a/multipath/mpathconf b/multipath/mpathconf
|
|
|
da32ae |
index 0de6b121..6e33fb99 100644
|
|
|
da32ae |
--- a/multipath/mpathconf
|
|
|
da32ae |
+++ b/multipath/mpathconf
|
|
|
da32ae |
@@ -17,7 +17,7 @@
|
|
|
da32ae |
# This program was largely ripped off from lvmconf
|
|
|
da32ae |
#
|
|
|
da32ae |
|
|
|
da32ae |
-unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST
|
|
|
da32ae |
+unset ENABLE FIND FRIENDLY PROPERTY FOREIGN MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_PROPERTY HAVE_FOREIGN HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST HAVE_OPTION OPTION_NAME OPTION_VALUE
|
|
|
da32ae |
|
|
|
da32ae |
DEFAULT_CONFIG="# device-mapper-multipath configuration file
|
|
|
da32ae |
|
|
|
da32ae |
@@ -52,6 +52,7 @@ function usage
|
|
|
da32ae |
echo "Set find_multipaths (Default y): --find_multipaths <yes|no|strict|greedy|smart>"
|
|
|
da32ae |
echo "Set default property blacklist (Default n): --property_blacklist <y|n>"
|
|
|
da32ae |
echo "Set enable_foreign to show foreign devices (Default n): --enable_foreign <y|n>"
|
|
|
da32ae |
+ echo "Add/Change/Remove option in defaults section: --option <option_name>:<value>"
|
|
|
da32ae |
echo "Load the dm-multipath modules on enable (Default y): --with_module <y|n>"
|
|
|
da32ae |
echo "start/stop/reload multipathd (Default n): --with_multipathd <y|n>"
|
|
|
da32ae |
echo "select output file (Default /etc/multipath.conf): --outfile <FILE>"
|
|
|
da32ae |
@@ -162,6 +163,20 @@ function parse_args
|
|
|
da32ae |
exit 1
|
|
|
da32ae |
fi
|
|
|
da32ae |
;;
|
|
|
da32ae |
+ --option)
|
|
|
da32ae |
+ if [ -n "$2" ]; then
|
|
|
da32ae |
+ OPTION_NAME=$(echo $2 | cut -s -f1 -d:)
|
|
|
da32ae |
+ OPTION_VALUE=$(echo $2 | cut -s -f2 -d:)
|
|
|
da32ae |
+ if [ -z "$OPTION_NAME" ]; then
|
|
|
da32ae |
+ usage
|
|
|
da32ae |
+ exit 1
|
|
|
da32ae |
+ fi
|
|
|
da32ae |
+ shift 2
|
|
|
da32ae |
+ else
|
|
|
da32ae |
+ usage
|
|
|
da32ae |
+ exit 1
|
|
|
da32ae |
+ fi
|
|
|
da32ae |
+ ;;
|
|
|
da32ae |
--enable_foreign)
|
|
|
da32ae |
if [ -n "$2" ]; then
|
|
|
da32ae |
FOREIGN=$2
|
|
|
da32ae |
@@ -208,12 +223,15 @@ function parse_args
|
|
|
da32ae |
|
|
|
da32ae |
function validate_args
|
|
|
da32ae |
{
|
|
|
da32ae |
- if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" ]; then
|
|
|
da32ae |
+ if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$PROPERTY" -o -n "$MODULE" -o -n "$FOREIGN" -o -n "$OPTION_NAME" ]; then
|
|
|
da32ae |
echo "ignoring extra parameters on disable"
|
|
|
da32ae |
FRIENDLY=""
|
|
|
da32ae |
FIND=""
|
|
|
da32ae |
PROPERTY=""
|
|
|
da32ae |
MODULE=""
|
|
|
da32ae |
+ FOREIGN=""
|
|
|
da32ae |
+ OPTION_NAME=""
|
|
|
da32ae |
+ OPTION_VALUE=""
|
|
|
da32ae |
fi
|
|
|
da32ae |
if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then
|
|
|
da32ae |
echo "--user_friendly_names must be either 'y' or 'n'"
|
|
|
da32ae |
@@ -235,7 +253,19 @@ function validate_args
|
|
|
da32ae |
echo "--enable_foreign must be either 'y' or 'n'"
|
|
|
da32ae |
exit 1
|
|
|
da32ae |
fi
|
|
|
da32ae |
- if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" ]; then
|
|
|
da32ae |
+ if [ -n "$OPTION_NAME" ]; then
|
|
|
da32ae |
+ if [[ $OPTION_NAME =~ [[:space:]]|#|\"|!|\{|\} ]]; then
|
|
|
da32ae |
+ echo "--option name \"$OPTION_NAME\" is invalid"
|
|
|
da32ae |
+ exit 1
|
|
|
da32ae |
+ elif [[ $OPTION_VALUE =~ \"|#|!|\{|\} ]]; then
|
|
|
da32ae |
+ echo "--option value \"$OPTION_VALUE\" is invalid"
|
|
|
da32ae |
+ exit 1
|
|
|
da32ae |
+ fi
|
|
|
da32ae |
+ if [[ $OPTION_VALUE =~ [[:space:]] ]]; then
|
|
|
da32ae |
+ OPTION_VALUE=\"$OPTION_VALUE\"
|
|
|
da32ae |
+ fi
|
|
|
da32ae |
+ fi
|
|
|
da32ae |
+ if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" -a -z "$PROPERTY" -a -z "$FOREIGN" -a -z "$OPTION_NAME" ]; then
|
|
|
da32ae |
SHOW_STATUS=1
|
|
|
da32ae |
fi
|
|
|
da32ae |
if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then
|
|
|
da32ae |
@@ -348,6 +378,13 @@ if [ "$HAVE_DEFAULTS" = "1" ]; then
|
|
|
da32ae |
elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*enable_foreign" ; then
|
|
|
da32ae |
HAVE_FOREIGN=3
|
|
|
da32ae |
fi
|
|
|
da32ae |
+ if [ -n "$OPTION_NAME" ]; then
|
|
|
da32ae |
+ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q '^[[:space:]]*'"$OPTION_NAME"'[[:space:]][[:space:]]*'"$OPTION_VALUE" ; then
|
|
|
da32ae |
+ HAVE_OPTION=1
|
|
|
da32ae |
+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q '^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$' ; then
|
|
|
da32ae |
+ HAVE_OPTION=0
|
|
|
da32ae |
+ fi
|
|
|
da32ae |
+ fi
|
|
|
da32ae |
fi
|
|
|
da32ae |
|
|
|
da32ae |
if [ "$HAVE_EXCEPTIONS" = "1" ]; then
|
|
|
da32ae |
@@ -532,6 +569,21 @@ elif [ "$FOREIGN" = "y" ]; then
|
|
|
da32ae |
fi
|
|
|
da32ae |
fi
|
|
|
da32ae |
|
|
|
da32ae |
+if [ -n "$OPTION_NAME" -a -n "$OPTION_VALUE" ]; then
|
|
|
da32ae |
+ if [ -z "$HAVE_OPTION" ]; then
|
|
|
da32ae |
+ sed -i '/^defaults[[:space:]]*{/ a\
|
|
|
da32ae |
+ '"$OPTION_NAME"' '"$OPTION_VALUE"'
|
|
|
da32ae |
+' $TMPFILE
|
|
|
da32ae |
+ CHANGED_CONFIG=1
|
|
|
da32ae |
+ elif [ "$HAVE_OPTION" = 0 ]; then
|
|
|
da32ae |
+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$/ '"$OPTION_NAME"' '"$OPTION_VALUE"'/' $TMPFILE
|
|
|
da32ae |
+ CHANGED_CONFIG=1
|
|
|
da32ae |
+ fi
|
|
|
da32ae |
+elif [ -n "$OPTION_NAME" -a -n "$HAVE_OPTION" ]; then
|
|
|
da32ae |
+ sed -i '/^defaults[[:space:]]*{/,/^}/{/^[[:space:]]*'"$OPTION_NAME"'\([[:space:]].*\)\?$/d}' $TMPFILE
|
|
|
da32ae |
+ CHANGED_CONFIG=1
|
|
|
da32ae |
+fi
|
|
|
da32ae |
+
|
|
|
da32ae |
if [ -f "$OUTPUTFILE" ]; then
|
|
|
da32ae |
cp $OUTPUTFILE $OUTPUTFILE.old
|
|
|
da32ae |
if [ $? != 0 ]; then
|
|
|
da32ae |
diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8
|
|
|
da32ae |
index a14d831e..496383b7 100644
|
|
|
da32ae |
--- a/multipath/mpathconf.8
|
|
|
da32ae |
+++ b/multipath/mpathconf.8
|
|
|
da32ae |
@@ -101,6 +101,13 @@ to the
|
|
|
da32ae |
defaults section. if set to \fBn\fP, this removes the line, if present. This
|
|
|
da32ae |
command can be used along with any other command.
|
|
|
da32ae |
.TP
|
|
|
da32ae |
+.B --option \fB<option_name>:[<value>]\fP
|
|
|
da32ae |
+Sets the defaults section option \fB<option_name>\fP to \fB<value>\fP. If the
|
|
|
da32ae |
+option was not previously set in the defaults section, it is added. If it was
|
|
|
da32ae |
+set, its value is changed to \fB<value>\fP. If \fB<value>\fP is left blank,
|
|
|
da32ae |
+then the option is removed from the defaults section, if was set there. This
|
|
|
da32ae |
+command can be used along with any other command.
|
|
|
da32ae |
+.TP
|
|
|
da32ae |
.B --outfile \fB<filename>\fP
|
|
|
da32ae |
Write the resulting multipath configuration to \fB<filename>\fP instead of
|
|
|
da32ae |
\fB/etc/multipath.conf\fP.
|