Merge from vendor branch TCPDUMP:
[dragonfly.git] / contrib / amd / scripts / automount2amd.in
1 #!@PERL@ -w
2 #
3 # Convert Sun automount map format to amd format
4 #
5 # Package:      am-utils-6.0
6 # Author:       Mike Walker <mike@tab00.larc.nasa.gov>
7 #               Erez Zadok <ezk@cs.columbia.edu>
8 #
9 # This program expects maps with the format
10 #
11 #   dir  [ -options ]  machine:/path [ # optional comment ]
12 #   ...
13 #
14 # and generates an equivalent amd map as follows:
15 #
16 #   # generated by automountamd on Fri May 21  9:16:56 1993
17 #
18 #   /defaults \
19 #     type:=nfs;opts:=rw,grpid,nosuid,utimeout=600
20 #
21 #   dir \
22 #     hostd==machine.larc.nasa.gov;type:=link;fs:=/path || \
23 #     domain==larc.nasa.gov;rhost:=machine;rfs:=/path || \
24 #     rhost:=machine.larc.nasa.gov;rfs:=/path
25 #   ...
26 #
27 # You should set the DOMAIN and DEFAULT variables to your preferences.
28 #
29 # $Id: automount2amd.in,v 1.1 1999/08/16 01:16:36 ezk Exp $
30 #
31
32 require "ctime.pl";
33
34 # amd domain name (doesn't have to be the DNS domain; isn't overloading great!)
35 # Should be what you will pass to amd via the -d command-line switch, if any.
36 $DOMAIN='';
37
38 # amd default settings; consult the docs for what you can/should do here.
39 # Note, in particular, that if your disk mount points follow a common scheme
40 # you can specify ``rfs:=/common/path/${key}'' and not have to insert that
41 # line (twice) in every entry below!
42 $DEFAULTS='type:=nfs;opts:=rw,grpid,nosuid,utimeout=600';
43
44
45 # print comment header and default string
46 printf "# generated by automount2amd on %s\n", &ctime(time);
47 printf "/defaults \\\n  %s\n\n", $DEFAULTS;
48
49 # loop through map
50 while (<>) {
51     if (m,^(\w\S*)(\s+\-\w\S*\s+|\s+)(\w[^:]*):(\/\S*)\s*(.*),) {
52         ($dir, $options, $machine, $path, $rest) = ($1, $2, $3, $4, $5);
53         print "#$rest\n" if ($rest =~ m/\w/);
54         print "$dir \\\n";
55         if ($options =~ m/-/) {
56             $options =~ s/\s//g;
57             $options =~ s/^-//g;
58             printf( "  -addopts:=$options \\\n");
59         }
60         if (defined($DOMAIN) && $DOMAIN ne "") {
61             printf("  hostd==%s.%s;type:=link;fs:=%s || \\\n",
62                    $machine, $DOMAIN, $path);
63             printf("  domain==%s;rhost:=%s;rfs:=%s || \\\n",
64                    $DOMAIN, $machine, $path);
65             printf "  rhost:=%s.%s;rfs:=%s\n\n", $machine, $DOMAIN, $path;
66         } else {
67             printf("  host==%s;type:=link;fs:=%s \\\n",
68                    $machine, $path);
69             printf "  rhost:=%s;rfs:=%s\n\n", $machine, $path;
70         }
71     }
72 }