diff --git a/mxmount b/mxmount index 3cb1b66..887a1e3 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; @@ -31,7 +31,7 @@ $fullhostname = hostname(); DEFAULT_MOUNT_OPTIONS => '', DEFAULT_EXPORT_OPTIONS => '', DEFAULT_MOUNT_PREFIX => '/', - + SHORTHOST => $hostname, FULLHOST => $fullhostname, @@ -89,21 +89,21 @@ 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}); @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,20 +156,23 @@ sub parse_data { $D->{noexport} = 1; $D->{label} = $1; } - + if($D->{label} =~ /(.*):(.*)/) { $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/) { # M: decent software raid (mdadm) + $D->{mountpoint} = 'M/' . $D->{label}; + $D->{label} = lc($D->{label}); } elsif($D->{label} =~ /^data(.*)/) { $D->{mountpoint} = $1; } else { @@ -189,11 +192,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 +205,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 +241,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 +263,7 @@ sub read_file { $line=""; } } - + close F; return @lines; }