From f3f825be736ca7eb774cf48ed9d15d38d340a872 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 16 Feb 2017 10:48:57 +0100 Subject: [PATCH 1/4] mxmount: removed some whitespace clutter --- mxmount | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/mxmount b/mxmount index 3cb1b66..5c7213e 100755 --- a/mxmount +++ b/mxmount @@ -31,7 +31,7 @@ $fullhostname = hostname(); DEFAULT_MOUNT_OPTIONS => '', DEFAULT_EXPORT_OPTIONS => '', DEFAULT_MOUNT_PREFIX => '/', - + SHORTHOST => $hostname, FULLHOST => $fullhostname, @@ -98,12 +98,12 @@ 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"; - + } - + close EXPORTS; } @@ -112,11 +112,11 @@ sub mount_all { my $allmp = $D{$hostname}; my @CMD; foreach my $mp (sort { $a->{mountpoint} cmp $b->{mountpoint} } @$allmp) { - + @CMD = (); - + push @CMD, 'mount', "LABEL=$mp->{label}", $mp->{mountpoint}; - + if($mp->{fs}) { push @CMD, '-t', $mp->{fs}; } @@ -133,7 +133,7 @@ sub parse_data { my @lines = @_; my @invalid = (); my @data; - + my $rest; foreach(@lines) { @@ -145,7 +145,7 @@ sub parse_data { } my $D = {}; - + $D->{line} = $_; $D->{host} = $data[0]; @@ -156,7 +156,7 @@ sub parse_data { $D->{noexport} = 1; $D->{label} = $1; } - + if($D->{label} =~ /(.*):(.*)/) { $D->{label} = $1; $D->{mountpoint} = $2; @@ -189,11 +189,11 @@ sub parse_data { } $D->{exportopts} = $data[3] ? $data[3] : $V{DEFAULT_EXPORT_OPTIONS}; - + foreach(qw(host label mountpoint fs mountopts exportopts )) { $D->{$_} = expand_variables($D->{$_}); } - + push @{$D{$D->{host}}}, $D; } @@ -202,11 +202,11 @@ sub parse_data { sub expand_variables { my $s = shift; - + foreach my $k (keys %V) { $s =~ s/$k/$V{$k}/g; } - + return $s; } @@ -238,13 +238,13 @@ sub read_file { while() { chomp; next if(/^\s*#/ or /^\s*$/); - + $cont=0; - + s/#.*$//; # remove comments.. - + $_ = $line . $_; - + if(s/\\\s*$//) { # line continous in next line.. $cont=1; @@ -260,7 +260,7 @@ sub read_file { $line=""; } } - + close F; return @lines; } From 2937a002ea7b3e52fafbaec5d57bb3bba93e607a Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 16 Feb 2017 11:08:44 +0100 Subject: [PATCH 2/4] mxmount: renamed tag to exportstag, removed the funny note for donald Changes should help reading the code. --- mxmount | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mxmount b/mxmount index 5c7213e..4e57625 100755 --- a/mxmount +++ b/mxmount @@ -13,7 +13,7 @@ my $exports = "/etc/exports"; ######################################## -my $tag = "# DO NOT EDIT BELOW THIS LINE # created by /usr/bin/mxmount #"; +my $exportstag = "# DO NOT EDIT BELOW THIS LINE # created by /usr/bin/mxmount #"; my $fullhostname; my $hostname; @@ -89,11 +89,11 @@ sub create_exports { foreach my $exp (@exports) { chomp($exp); next if($exp =~ /^\s*$/); - last if($exp eq $tag); + last if($exp eq $exportstag); print EXPORTS "$exp\n"; } - print EXPORTS "\n$tag\n\n# auch du nicht, donald 8)\n\n"; + print EXPORTS "\n$exportstag\n\n"; foreach my $mp (@$allmp) { next if($mp->{noexport}); From 6e04723b8045b939d6ef94c1856a438e2721bfe7 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 16 Feb 2017 11:20:00 +0100 Subject: [PATCH 3/4] mxmount: added mount option for M-labels --- mxmount | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mxmount b/mxmount index 4e57625..736da0f 100755 --- a/mxmount +++ b/mxmount @@ -170,6 +170,9 @@ sub parse_data { if (!$data[3]) { $D->{noexport} = 1; } + } elsif($D->{label} =~ /^M/) { + $D->{mountpoint} = 'M/' . $D->{label}; + $D->{label} = lc($D->{label}); } elsif($D->{label} =~ /^data(.*)/) { $D->{mountpoint} = $1; } else { From 3eabfd1cf7431cd3c92cc480b49d5829f5788f89 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 16 Feb 2017 11:21:53 +0100 Subject: [PATCH 4/4] mxmount: commented the various raid labels --- mxmount | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mxmount b/mxmount index 736da0f..887a1e3 100755 --- a/mxmount +++ b/mxmount @@ -161,16 +161,16 @@ sub parse_data { $D->{label} = $1; $D->{mountpoint} = $2; } else { - if($D->{label} =~ /^X/) { + if($D->{label} =~ /^X/) { # X: decent controller based raid $D->{mountpoint} = 'X/' . $D->{label}; $D->{label} = lc($D->{label}); - } elsif($D->{label} =~ /^C/) { + } elsif($D->{label} =~ /^C/) { # C: controller based raid, confidential $D->{mountpoint} = 'C/' . $D->{label}; $D->{label} = lc($D->{label}); if (!$data[3]) { $D->{noexport} = 1; } - } elsif($D->{label} =~ /^M/) { + } elsif($D->{label} =~ /^M/) { # M: decent software raid (mdadm) $D->{mountpoint} = 'M/' . $D->{label}; $D->{label} = lc($D->{label}); } elsif($D->{label} =~ /^data(.*)/) {