summaryrefslogtreecommitdiffstats
path: root/contrib/amd/scripts/amd2sun.in
blob: df69b09739cd987aa0c1fb3179d3c4c75bd44e0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!@PERL@
# convert amd maps to Sun automount maps
# usage: amd2sun file
#
# Package:	am-utils-6.0
# Author:	"Mark D. Baushke" <mdb@cisco.com>

print "# file created by amd2sun
#
# DO NOT EDIT THIS FILE AT ALL
# It is automatically generated from the amd mount map - edit that instead
#
";
while (<>) {
  print, next if /^#/;
  chop;
  $line = $_;
  while ($line =~ /\\$/) {
    chop $line;
    $line2 = <>;
    $line2 =~ s/^\s*//;
    $line .= $line2;
    chop $line;
  }

  next unless $line =~ /^([^\s]+)\s+(.*)$/;

  $fs = $1; $rest=$2;

  if ($fs =~ /^\/defaults/) {
    ($defopts = $rest) =~ s/^.*[\s;]opts:=([^;\s]+)[;\s]*.*$/\1/;
    next;
  }

  $opts=$defopts;

  if ($rest =~ /opts:=([^;\s]+)[;\s]/) {
    $opts = $1;
  }

  $opts =~ s/,ping=[-\d]+//g;

  ($rhost = $rest) =~ s/^.*[\s;]rhost:=([^;\s]+)[;\s]*.*$/\1/;
  ($rfs   = $rest) =~ s/^.*[\s;]rfs:=([^;\s]+)[;\s]*.*$/\1/;

  if ($rest =~ /sublink:=([^;\s]+)[;\s]/ ) {
    $rfs .= "/$1";
  }

  print "$fs	-$opts	$rhost:$rfs\n";
}
OpenPOWER on IntegriCloud