Skip to content

Commit

Permalink
mxmount: Expand host groups by hostconfig
Browse files Browse the repository at this point in the history
When /etc/mxmounts uses the netgroup syntax to export to a list of
clients (usually @amd), expand the list using hostconfig to a list of
hosts. This is one step for us to get rid of NIS.

We could expand

    /filesystem @group(opts)

to

    /filesystem host1(opts) hosts2(opts) host3(opts) host4(opts)...

but because our opts are about 50 characters and we have about 540 hosts
on @amd, we save about 27000 characters per line by converting to

    /filesystem -opts host1 host2 host3...

Notes:

* `hostconfig --list` does not only accept single tag (=group) names,
but complex boolean expressions. We could export to @1 (=allways true,
any known host) or @testing&!desktop. It is suggested, not to use this
as a feature.

* We need some mechnism to trigger a regeneration of the exports by
mxmount when the groups are modified.
  • Loading branch information
donald committed Nov 19, 2018
1 parent c2626f3 commit 50e8224
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions mxmount/mxmount
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,18 @@ sub create_exports {

foreach my $mp (@$allmp) {
next if($mp->{noexport});
@CMD = ($mp->{mountpoint}, $mp->{exportopts});

print join " ", "$exports: ", @CMD, "\n";
print EXPORTS join " ", @CMD, "\n";

my ($mountpoint,$exportopts)=($mp->{mountpoint}, $mp->{exportopts}); # '/amd/theinternet/1','@amd(sync,rw,...)'
my ($hostspec,$optspec)=$exportopts=~/^([^(]+)(.*)/; # '@amd','(sync,rw,...)'
my ($opts)=$optspec=~/\((.*)\)/; # 'sync,rw,...'
my $hosts='';
warn "export $mountpoint to $hostspec opts $opts\n";
if (my ($group) = $hostspec=~/^@(.+)/) {
$hosts=`hostconfig --list $group`; # expanded group
$hosts or warn "group $group is empty\n";
} else {
$hosts=$hostspec; # single host
}
$hosts and printf EXPORTS "%s -%s %s\n",$mountpoint,$opts,$hosts;
}
close EXPORTS;
}
Expand Down

0 comments on commit 50e8224

Please sign in to comment.