blob: 471ff0932384d082d10f5d1d364ad338b1916a93 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From b0b4cca566e3e0c3a232b3754555c41d4e0c1273 Mon Sep 17 00:00:00 2001
Brad Bishop19323692019-04-05 15:28:33 -04002From: Changqing Li <changqing.li@windriver.com>
3Date: Mon, 26 Nov 2018 09:55:12 +0800
4Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep 17
5 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Thu, 16
6 Oct 2014 15:49:01 -0500 Subject: [PATCH] RH: add mpathconf
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08007
8mpathconf is a program (largely based on lvmcomf) to help users
9configure /etc/multipath.conf and enable or disable multipathing. It
10has a couple of built-in options that can be set directly from the
11command line. But, mostly it is used to get a multipath.conf file
12with the OS defaults, and to enable and disable multipathing via
13a single command.
14
15Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Brad Bishop19323692019-04-05 15:28:33 -040016
17Upstream-Status: Pending
18
19update this patch to new version
20
21Signed-off-by: Changqing Li <changqing.li@windriver.com>
Andrew Geissler517393d2023-01-13 08:55:19 -060022[OP: Rebase to 0.9.3]
23Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080024---
25 libmultipath/config.c | 1 +
Andrew Geissler517393d2023-01-13 08:55:19 -060026 multipath/Makefile | 4 +
27 multipath/mpathconf | 464 ++++++++++++++++++++++++++++++++++++++++++
28 multipath/mpathconf.8 | 101 +++++++++
29 4 files changed, 570 insertions(+)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080030 create mode 100644 multipath/mpathconf
31 create mode 100644 multipath/mpathconf.8
32
33diff --git a/libmultipath/config.c b/libmultipath/config.c
Andrew Geissler517393d2023-01-13 08:55:19 -060034index 31894810..af59dd3c 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080035--- a/libmultipath/config.c
36+++ b/libmultipath/config.c
Andrew Geissler517393d2023-01-13 08:55:19 -060037@@ -969,6 +969,7 @@ int _init_config (const char *file, struct config *conf)
38 validate_pctable(conf->overrides, 0, file);
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080039 } else {
40 condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
41+ condlog(0, "You can run /sbin/mpathconf to create or modify /etc/multipath.conf");
42 if (conf->blist_devnode == NULL) {
43 conf->blist_devnode = vector_alloc();
44 if (!conf->blist_devnode) {
45diff --git a/multipath/Makefile b/multipath/Makefile
Andrew Geissler517393d2023-01-13 08:55:19 -060046index 8482de6a..780b1b73 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080047--- a/multipath/Makefile
48+++ b/multipath/Makefile
Andrew Geissler517393d2023-01-13 08:55:19 -060049@@ -21,6 +21,7 @@ $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080050 install:
51 $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
52 $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
53+ $(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/
54 $(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir)
55 $(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir)
Andrew Geissler517393d2023-01-13 08:55:19 -060056 $(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)$(udevrulesdir)/62-multipath.rules
57@@ -32,6 +33,7 @@ install:
58 $(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080059 $(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
Andrew Geissler517393d2023-01-13 08:55:19 -060060 $(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5 $(DESTDIR)$(man5dir)
61+ $(INSTALL_PROGRAM) -m 644 mpathconf.8 $(DESTDIR)$(man8dir)
62 ifneq ($(SCSI_DH_MODULES_PRELOAD),)
63 $(INSTALL_PROGRAM) -m 644 scsi_dh.conf $(DESTDIR)$(modulesloaddir)/scsi_dh.conf
64 for _x in $(SCSI_DH_MODULES_PRELOAD); do echo "$$_x"; done \
65@@ -44,8 +46,10 @@ uninstall:
66 $(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf
67 $(RM) $(DESTDIR)$(modulesloaddir)/scsi_dh.conf
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080068 $(RM) $(DESTDIR)$(libudevdir)/rules.d/62-multipath.rules
69+ $(RM) $(DESTDIR)$(bindir)/mpathconf
Andrew Geissler517393d2023-01-13 08:55:19 -060070 $(RM) $(DESTDIR)$(man8dir)/$(EXEC).8
71 $(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5
72+ $(RM) $(DESTDIR)$(man8dir)/mpathconf.8
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080073
74 clean: dep_clean
Andrew Geissler517393d2023-01-13 08:55:19 -060075 $(RM) core *.o $(EXEC) multipath.rules tmpfiles.conf
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080076diff --git a/multipath/mpathconf b/multipath/mpathconf
77new file mode 100644
Andrew Geissler517393d2023-01-13 08:55:19 -060078index 00000000..e8391347
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080079--- /dev/null
80+++ b/multipath/mpathconf
81@@ -0,0 +1,464 @@
82+#!/bin/bash
83+#
84+# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
85+#
86+# This file is part of the device-mapper-multipath package.
87+#
88+# This copyrighted material is made available to anyone wishing to use,
89+# modify, copy, or redistribute it subject to the terms and conditions
90+# of the GNU General Public License v.2.
91+#
92+# You should have received a copy of the GNU General Public License
93+# along with this program; if not, write to the Free Software Foundation,
94+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
95+
96+#
97+# Simple editting of /etc/multipath.conf
98+# This program was largely ripped off from lvmconf
99+#
100+
101+unset ENABLE FIND FRIENDLY MODULE MULTIPATHD HAVE_DISABLE HAVE_WWID_DISABLE HAVE_FIND HAVE_BLACKLIST HAVE_EXCEPTIONS HAVE_DEFAULTS HAVE_FRIENDLY HAVE_MULTIPATHD HAVE_MODULE HAVE_OUTFILE SHOW_STATUS CHANGED_CONFIG WWID_LIST
102+
103+DEFAULT_CONFIG="# device-mapper-multipath configuration file
104+
105+# For a complete list of the default configuration values, run either:
106+# # multipath -t
107+# or
108+# # multipathd show config
109+
110+# For a list of configuration options with descriptions, see the
111+# multipath.conf man page.
112+
113+defaults {
114+ user_friendly_names yes
115+ find_multipaths yes
116+}
117+
118+blacklist_exceptions {
119+ property \"(SCSI_IDENT_|ID_WWN)\"
120+}"
121+
122+CONFIGFILE="/etc/multipath.conf"
123+OUTPUTFILE="/etc/multipath.conf"
124+MULTIPATHDIR="/etc/multipath"
125+TMPFILE="/etc/multipath/.multipath.conf.tmp"
126+WWIDS=0
127+
128+function usage
129+{
130+ echo "usage: $0 <command>"
131+ echo ""
132+ echo "Commands:"
133+ echo "Enable: --enable "
134+ echo "Disable: --disable"
135+ echo "Only allow certain wwids (instead of enable): --allow <WWID>"
136+ echo "Set user_friendly_names (Default y): --user_friendly_names <y|n>"
137+ echo "Set find_multipaths (Default y): --find_multipaths <y|n>"
138+ echo "Load the dm-multipath modules on enable (Default y): --with_module <y|n>"
139+ echo "start/stop/reload multipathd (Default n): --with_multipathd <y|n>"
140+ echo "select output file (Default /etc/multipath.conf): --outfile <FILE>"
141+ echo ""
142+}
143+
144+function add_wwid
145+{
146+ INDEX=0
147+ while [ "$INDEX" -lt "$WWIDS" ] ; do
148+ if [ "$1" = "${WWID_LIST[$INDEX]}" ] ; then
149+ return
150+ fi
151+ ((INDEX++))
152+ done
153+ WWID_LIST[$WWIDS]="$1"
154+ ((WWIDS++))
155+}
156+
157+function get_dm_deps
158+{
159+ shift 3
160+ while [ -n "$1" -a -n "$2" ]; do
161+ MAJOR=$(echo $1 | tr -d '(,')
162+ MINOR=$(echo $2 | tr -d ')')
163+ UUID=`dmsetup info -c --noheadings -o uuid -j $MAJOR -m $MINOR 2> /dev/null`
164+ if [ -n "$UUID" ] ; then
165+ set_dm_wwid $UUID
166+ fi
167+ shift 2
168+ done
169+}
170+
171+function set_dm_wwid
172+{
173+ if [[ "$1" =~ ^part[[:digit:]]+-mpath- ]] ; then
174+ add_wwid "${1##part*-mpath-}"
175+ elif [[ "$1" =~ ^mpath- ]] ; then
176+ add_wwid "${1##mpath-}"
177+ else
178+ get_dm_deps `dmsetup deps -u $1`
179+ fi
180+}
181+
182+function set_wwid
183+{
184+ UUID=""
185+ if [[ "$1" =~ ^[[:digit:]]+:[[:digit:]]+$ ]] ; then
186+ MAJOR=${1%%:*}
187+ MINOR=${1##*:}
188+ UUID=`dmsetup info -c --noheadings -o uuid -j $MAJOR -m $MINOR 2> /dev/null`
189+ else
190+ UUID=`dmsetup info -c --noheadings -o uuid $1 2> /dev/null`
191+ fi
192+ if [ -n "$UUID" ] ; then
193+ set_dm_wwid $UUID
194+ else
195+ add_wwid "$1"
196+ fi
197+}
198+
199+function parse_args
200+{
201+ while [ -n "$1" ]; do
202+ case $1 in
203+ --enable)
204+ ENABLE=1
205+ shift
206+ ;;
207+ --disable)
208+ ENABLE=0
209+ shift
210+ ;;
211+ --allow)
212+ ENABLE=2
213+ if [ -n "$2" ]; then
214+ set_wwid $2
215+ shift 2
216+ else
217+ usage
218+ exit 1
219+ fi
220+ ;;
221+ --user_friendly_names)
222+ if [ -n "$2" ]; then
223+ FRIENDLY=$2
224+ shift 2
225+ else
226+ usage
227+ exit 1
228+ fi
229+ ;;
230+ --find_multipaths)
231+ if [ -n "$2" ]; then
232+ FIND=$2
233+ shift 2
234+ else
235+ usage
236+ exit 1
237+ fi
238+ ;;
239+ --with_module)
240+ if [ -n "$2" ]; then
241+ MODULE=$2
242+ shift 2
243+ else
244+ usage
245+ exit 1
246+ fi
247+ ;;
248+ --with_multipathd)
249+ if [ -n "$2" ]; then
250+ MULTIPATHD=$2
251+ shift 2
252+ else
253+ usage
254+ exit 1
255+ fi
256+ ;;
257+ --outfile)
258+ if [ -n "$2" ]; then
259+ OUTPUTFILE=$2
260+ HAVE_OUTFILE=1
261+ shift 2
262+ else
263+ usage
264+ exit 1
265+ fi
266+ ;;
267+ *)
268+ usage
269+ exit
270+ esac
271+ done
272+}
273+
274+function validate_args
275+{
276+ if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" -o -n "$MODULE" ]; then
277+ echo "ignoring extra parameters on disable"
278+ FRIENDLY=""
279+ FIND=""
280+ MODULE=""
281+ fi
282+ if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then
283+ echo "--user_friendly_names must be either 'y' or 'n'"
284+ exit 1
285+ fi
286+ if [ -n "$FIND" ] && [ "$FIND" != "y" -a "$FIND" != "n" ]; then
287+ echo "--find_multipaths must be either 'y' or 'n'"
288+ exit 1
289+ fi
290+ if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" ]; then
291+ SHOW_STATUS=1
292+ fi
293+ if [ -n "$MODULE" ] && [ "$MODULE" != "y" -a "$MODULE" != "n" ]; then
294+ echo "--with_module must be either 'y' or 'n'"
295+ exit 1
296+ fi
297+ if [ -n "$MULTIPATHD" ] && [ "$MULTIPATHD" != "y" -a "$MULTIPATHD" != "n" ]; then
298+ echo "--with_multipathd must be either 'y' or 'n'"
299+ exit 1
300+ fi
301+ if [ "$ENABLE" = 2 -a -z "$HAVE_OUTFILE" ]; then
302+ echo "Because --allow makes changes that cannot be automatically reversed,"
303+ echo "you must set --outfile when you set --allow"
304+ exit 1
305+ fi
306+}
307+
308+function add_blacklist_exceptions
309+{
310+ INDEX=0
311+ while [ "$INDEX" -lt "$WWIDS" ] ; do
312+ sed -i '/^blacklist_exceptions[[:space:]]*{/ a\
313+ wwid '"\"${WWID_LIST[$INDEX]}\""'
314+' $TMPFILE
315+ ((INDEX++))
316+ done
317+}
318+
319+umask 0077
320+
321+parse_args "$@"
322+
323+validate_args
324+
325+if [ ! -d "$MULTIPATHDIR" ]; then
326+ echo "/etc/multipath/ does not exist. failing"
327+ exit 1
328+fi
329+
330+rm $TMPFILE 2> /dev/null
331+echo "$DEFAULT_CONFIG" > $TMPFILE
332+if [ -f "$CONFIGFILE" ]; then
333+ cp $CONFIGFILE $TMPFILE
334+fi
335+
336+if grep -q "^blacklist[[:space:]]*{" $TMPFILE ; then
337+ HAVE_BLACKLIST=1
338+fi
339+
340+if grep -q "^blacklist_exceptions[[:space:]]*{" $TMPFILE ; then
341+ HAVE_EXCEPTIONS=1
342+fi
343+
344+if grep -q "^defaults[[:space:]]*{" $TMPFILE ; then
345+ HAVE_DEFAULTS=1
346+fi
347+
348+if [ -z "$MODULE" -o "$MODULE" = "y" ]; then
349+ if lsmod | grep -q "dm_multipath" ; then
350+ HAVE_MODULE=1
351+ else
352+ HAVE_MODULE=0
353+ fi
354+fi
355+
356+if [ "$MULTIPATHD" = "y" ]; then
357+ if /bin/systemctl status multipathd.service > /dev/null 2>&1 ; then
358+ HAVE_MULTIPATHD=1
359+ else
360+ HAVE_MULTIPATHD=0
361+ fi
362+fi
363+
364+if [ "$HAVE_BLACKLIST" = "1" ]; then
365+ if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode \"\.\?\*\"" ; then
366+ HAVE_DISABLE=1
367+ elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"" ; then
368+ HAVE_DISABLE=0
369+ fi
370+fi
371+
372+if [ "$HAVE_BLACKLIST" = "1" ]; then
373+ if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*wwid \"\.\?\*\"" ; then
374+ HAVE_WWID_DISABLE=1
375+ elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"" ; then
376+ HAVE_WWID_DISABLE=0
377+ fi
378+fi
379+
380+if [ "$HAVE_DEFAULTS" = "1" ]; then
381+ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)" ; then
382+ HAVE_FIND=1
383+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)" ; then
384+ HAVE_FIND=0
385+ fi
386+ if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then
387+ HAVE_FRIENDLY=1
388+ elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)" ; then
389+ HAVE_FRIENDLY=0
390+ fi
391+fi
392+
393+if [ -n "$SHOW_STATUS" ]; then
394+ if [ -z "$HAVE_DISABLE" -o "$HAVE_DISABLE" = 0 ]; then
395+ echo "multipath is enabled"
396+ else
397+ echo "multipath is disabled"
398+ fi
399+ if [ -z "$HAVE_FIND" -o "$HAVE_FIND" = 0 ]; then
400+ echo "find_multipaths is disabled"
401+ else
402+ echo "find_multipaths is enabled"
403+ fi
404+ if [ -z "$HAVE_FRIENDLY" -o "$HAVE_FRIENDLY" = 0 ]; then
405+ echo "user_friendly_names is disabled"
406+ else
407+ echo "user_friendly_names is enabled"
408+ fi
409+ if [ -n "$HAVE_MODULE" ]; then
410+ if [ "$HAVE_MODULE" = 1 ]; then
411+ echo "dm_multipath module is loaded"
412+ else
413+ echo "dm_multipath module is not loaded"
414+ fi
415+ fi
416+ if [ -z "$HAVE_MULTIPATHD" ]; then
417+ if /bin/systemctl status multipathd.service > /dev/null 2>&1 ; then
418+ HAVE_MULTIPATHD=1
419+ else
420+ HAVE_MULTIPATHD=0
421+ fi
422+ fi
423+ if [ "$HAVE_MULTIPATHD" = 1 ]; then
424+ echo "multipathd is running"
425+ else
426+ echo "multipathd is not running"
427+ fi
428+ exit 0
429+fi
430+
431+if [ -z "$HAVE_BLACKLIST" ]; then
432+ cat >> $TMPFILE <<- _EOF_
433+
434+blacklist {
435+}
436+_EOF_
437+fi
438+
439+if [ -z "$HAVE_DEFAULTS" ]; then
440+ cat >> $TMPFILE <<- _EOF_
441+
442+defaults {
443+}
444+_EOF_
445+fi
446+
447+if [ "$ENABLE" = 2 ]; then
448+ if [ "$HAVE_DISABLE" = 1 ]; then
449+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
450+ fi
451+ if [ -z "$HAVE_WWID_DISABLE" ]; then
452+ sed -i '/^blacklist[[:space:]]*{/ a\
453+ wwid ".*"
454+' $TMPFILE
455+ elif [ "$HAVE_WWID_DISABLE" = 0 ]; then
456+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*wwid \"\.\?\*\"/ wwid ".*"/' $TMPFILE
457+ fi
458+ if [ "$HAVE_EXCEPTIONS" = 1 ]; then
459+ sed -i '/^blacklist_exceptions[[:space:]]*{/,/^}/ {/^[[:space:]]*wwid/ d}' $TMPFILE
460+ else
461+ cat >> $TMPFILE <<- _EOF_
462+
463+blacklist_exceptions {
464+}
465+_EOF_
466+ fi
467+ add_blacklist_exceptions
468+elif [ "$ENABLE" = 1 ]; then
469+ if [ "$HAVE_DISABLE" = 1 ]; then
470+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
471+ fi
472+elif [ "$ENABLE" = 0 ]; then
473+ if [ -z "$HAVE_DISABLE" ]; then
474+ sed -i '/^blacklist[[:space:]]*{/ a\
475+ devnode ".*"
476+' $TMPFILE
477+ elif [ "$HAVE_DISABLE" = 0 ]; then
478+ sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[[:space:]]*devnode \"\.\?\*\"/ devnode ".*"/' $TMPFILE
479+ fi
480+fi
481+
482+if [ "$FIND" = "n" ]; then
483+ if [ "$HAVE_FIND" = 1 ]; then
484+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)/ find_multipaths no/' $TMPFILE
485+ CHANGED_CONFIG=1
486+ fi
487+elif [ "$FIND" = "y" ]; then
488+ if [ -z "$HAVE_FIND" ]; then
489+ sed -i '/^defaults[[:space:]]*{/ a\
490+ find_multipaths yes
491+' $TMPFILE
492+ CHANGED_CONFIG=1
493+ elif [ "$HAVE_FIND" = 0 ]; then
494+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)/ find_multipaths yes/' $TMPFILE
495+ CHANGED_CONFIG=1
496+ fi
497+fi
498+
499+if [ "$FRIENDLY" = "n" ]; then
500+ if [ "$HAVE_FRIENDLY" = 1 ]; then
501+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)/ user_friendly_names no/' $TMPFILE
502+ CHANGED_CONFIG=1
503+ fi
504+elif [ "$FRIENDLY" = "y" ]; then
505+ if [ -z "$HAVE_FRIENDLY" ]; then
506+ sed -i '/^defaults[[:space:]]*{/ a\
507+ user_friendly_names yes
508+' $TMPFILE
509+ CHANGED_CONFIG=1
510+ elif [ "$HAVE_FRIENDLY" = 0 ]; then
511+ sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)/ user_friendly_names yes/' $TMPFILE
512+ CHANGED_CONFIG=1
513+ fi
514+fi
515+
516+if [ -f "$OUTPUTFILE" ]; then
517+ cp $OUTPUTFILE $OUTPUTFILE.old
518+ if [ $? != 0 ]; then
519+ echo "failed to backup old config file, $OUTPUTFILE not updated"
520+ exit 1
521+ fi
522+fi
523+
524+cp $TMPFILE $OUTPUTFILE
525+if [ $? != 0 ]; then
526+ echo "failed to copy new config file into place, check $OUTPUTFILE is still OK"
527+ exit 1
528+fi
529+
530+rm -f $TMPFILE
531+
532+if [ "$ENABLE" = 1 ]; then
533+ if [ "$HAVE_MODULE" = 0 ]; then
534+ modprobe dm_multipath
535+ fi
536+ if [ "$HAVE_MULTIPATHD" = 0 ]; then
537+ systemctl start multipathd.service
538+ fi
539+elif [ "$ENABLE" = 0 ]; then
540+ if [ "$HAVE_MULTIPATHD" = 1 ]; then
541+ systemctl stop multipathd.service
542+ fi
543+elif [ -n "$CHANGED_CONFIG" -a "$HAVE_MULTIPATHD" = 1 ]; then
544+ systemctl reload multipathd.service
545+fi
546diff --git a/multipath/mpathconf.8 b/multipath/mpathconf.8
547new file mode 100644
Andrew Geissler517393d2023-01-13 08:55:19 -0600548index 00000000..4cd32672
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800549--- /dev/null
550+++ b/multipath/mpathconf.8
551@@ -0,0 +1,101 @@
552+.TH MPATHCONF 8 "June 2010" "" "Linux Administrator's Manual"
553+.SH NAME
554+mpathconf - A tool for configuring device-mapper-multipath
555+.SH SYNOPSIS
556+.B mpathconf
557+.RB [\| commands \|]
558+.RB [\| options \|]
559+.SH DESCRIPTION
560+.B mpathconf
561+is a utility that creates or modifies
562+.B /etc/multipath.conf.
563+It can enable or disable multipathing and configure some common options.
564+.B mpathconf
565+can also load the
566+.B dm_multipath
567+module, start and stop the
568+.B multipathd
569+daemon, and configure the
570+.B multipathd
571+service to start automatically or not. If
572+.B mpathconf
573+is called with no commands, it will display the current configuration.
574+
575+The default options for mpathconf are
576+.B --with_module
577+The
578+.B --with_multipathd
579+option is not set by default. Enabling multipathing will load the
580+.B dm_multipath
581+module but it will not immediately start it. This is so
582+that users can manually edit their config file if necessary, before starting
583+.B multipathd.
584+
585+If
586+.B /etc/multipath.conf
587+already exists, mpathconf will edit it. If it does not exist, mpathconf will
588+create a default file with
589+.B user_friendly_names
590+and
591+.B find_multipaths
592+set. To disable these, use the
593+.B --user_friendly_names n
594+and
595+.B --find_multipaths n
596+options
597+.SH COMMANDS
598+.TP
599+.B --enable
600+Removes any line that blacklists all device nodes from the
601+.B /etc/multipath.conf
602+blacklist section.
603+.TP
604+.B --disable
605+Adds a line that blacklists all device nodes to the
606+.B /etc/multipath.conf
607+blacklist section. If no blacklist section exists, it will create one.
608+.TP
609+.B --user_friendly_name \fP { \fBy\fP | \fBn\fP }
610+If set to \fBy\fP, this adds the line
611+.B user_friendly_names yes
612+to the
613+.B /etc/multipath.conf
614+defaults section. If set to \fBn\fP, this removes the line, if present. This
615+command can be used along with any other command.
616+.TP
617+.B --find_multipaths\fP { \fBy\fP | \fBn\fP }
618+If set to \fBy\fP, this adds the line
619+.B find_multipaths yes
620+to the
621+.B /etc/multipath.conf
622+defaults section. If set to \fBn\fP, this removes the line, if present. This
623+command can be used aldong with any other command.
624+.SH OPTIONS
625+.TP
626+.B --with_module\fP { \fBy\fP | \fBn\fP }
627+If set to \fBy\fP, this runs
628+.B modprobe dm_multipath
629+to install the multipath modules. This option only works with the
630+.B --enable
631+command. This option is set to \fBy\fP by default.
632+.TP
633+.B --with_multipathd { \fBy\fP | \fBn\fP }
634+If set to \fBy\fP, this runs
635+.B service multipathd start
636+to start the multipathd daemon on \fB--enable\fP,
637+.B service multipathd stop
638+to stop the multipathd daemon on \fB--disable\fP, and
639+.B service multipathd reload
640+to reconfigure multipathd on \fB--user_frindly_names\fP and
641+\fB--find_multipaths\fP.
642+This option is set to \fBn\fP by default.
643+.SH FILES
644+.BR /etc/multipath.conf
645+.SH "SEE ALSO"
646+.BR multipath.conf (5),
647+.BR modprobe (8),
648+.BR multipath (8),
649+.BR multipathd (8),
650+.BR service (8),
651+.SH AUTHOR
652+Benjamin Marzinski <bmarzins@redhat.com>
653--
Andrew Geissler517393d2023-01-13 08:55:19 -06006542.38.1
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800655