From 24b66dcf3dbac9d15f6f2f6c1d8379e66bfda78a Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 22 Nov 2018 12:25:43 +0100 Subject: [PATCH] mxmount: Add option --reexport-only Calling mxmount with --reexport-only will not try to mount filesystems, but just rewrite /etc/exports and call exportfs -ra. This is supposed to be done by clusterd, when the export groups in /etc/hostconfig were changed. --- mxmount/mxmount | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mxmount/mxmount b/mxmount/mxmount index 9f897b2..11e3056 100755 --- a/mxmount/mxmount +++ b/mxmount/mxmount @@ -3,6 +3,7 @@ use strict; use warnings; use Sys::Hostname; +use Getopt::Long; my $configfile = "/etc/mxmounts"; my $exports = "/etc/exports"; @@ -16,6 +17,13 @@ my @exports; my %V; my %D; +our $USAGE=<<"_EOF_"; +usage: $0 + $0 --reexport-only +_EOF_ + +our ($opt_reexport_only); + $fullhostname = hostname(); ($hostname) = $fullhostname =~ /^(.*?)\./; @@ -40,9 +48,15 @@ foreach(@lines) { } add_data0_if_not_present(); -mount_all(); -create_exports(); +my %options; +GetOptions ( + 'reexport-only' => \$opt_reexport_only, +) or die $USAGE; +@ARGV and die $USAGE; + +mount_all() unless $opt_reexport_only; +create_exports(); system("exportfs -ra"); sub safe_qx { open my $pipe,'-|',@_; return join('',<$pipe>) }