xref: /netbsd-src/external/bsd/am-utils/dist/scripts/amd2sun.in (revision a53f50b9b44dc9467ccc9c464999b1d1c509cb0c)
1*a53f50b9Schristos#!@PERL@
2*a53f50b9Schristos# convert amd maps to Sun automount maps
3*a53f50b9Schristos# usage: amd2sun file
4*a53f50b9Schristos#
5*a53f50b9Schristos# Package:	am-utils-6.x
6*a53f50b9Schristos# Author:	"Mark D. Baushke" <mdb@cisco.com>
7*a53f50b9Schristos
8*a53f50b9Schristosprint "# file created by amd2sun
9*a53f50b9Schristos#
10*a53f50b9Schristos# DO NOT EDIT THIS FILE AT ALL
11*a53f50b9Schristos# It is automatically generated from the amd mount map - edit that instead
12*a53f50b9Schristos#
13*a53f50b9Schristos";
14*a53f50b9Schristoswhile (<>) {
15*a53f50b9Schristos  print, next if /^#/;
16*a53f50b9Schristos  chop;
17*a53f50b9Schristos  $line = $_;
18*a53f50b9Schristos  while ($line =~ /\\$/) {
19*a53f50b9Schristos    chop $line;
20*a53f50b9Schristos    $line2 = <>;
21*a53f50b9Schristos    $line2 =~ s/^\s*//;
22*a53f50b9Schristos    $line .= $line2;
23*a53f50b9Schristos    chop $line;
24*a53f50b9Schristos  }
25*a53f50b9Schristos
26*a53f50b9Schristos  next unless $line =~ /^([^\s]+)\s+(.*)$/;
27*a53f50b9Schristos
28*a53f50b9Schristos  $fs = $1; $rest=$2;
29*a53f50b9Schristos
30*a53f50b9Schristos  if ($fs =~ /^\/defaults/) {
31*a53f50b9Schristos    ($defopts = $rest) =~ s/^.*[\s;]opts:=([^;\s]+)[;\s]*.*$/\1/;
32*a53f50b9Schristos    next;
33*a53f50b9Schristos  }
34*a53f50b9Schristos
35*a53f50b9Schristos  $opts=$defopts;
36*a53f50b9Schristos
37*a53f50b9Schristos  if ($rest =~ /opts:=([^;\s]+)[;\s]/) {
38*a53f50b9Schristos    $opts = $1;
39*a53f50b9Schristos  }
40*a53f50b9Schristos
41*a53f50b9Schristos  $opts =~ s/,ping=[-\d]+//g;
42*a53f50b9Schristos
43*a53f50b9Schristos  ($rhost = $rest) =~ s/^.*[\s;]rhost:=([^;\s]+)[;\s]*.*$/\1/;
44*a53f50b9Schristos  ($rfs   = $rest) =~ s/^.*[\s;]rfs:=([^;\s]+)[;\s]*.*$/\1/;
45*a53f50b9Schristos
46*a53f50b9Schristos  if ($rest =~ /sublink:=([^;\s]+)[;\s]/ ) {
47*a53f50b9Schristos    $rfs .= "/$1";
48*a53f50b9Schristos  }
49*a53f50b9Schristos
50*a53f50b9Schristos  print "$fs	-$opts	$rhost:$rfs\n";
51*a53f50b9Schristos}
52