summaryrefslogtreecommitdiffstats
path: root/contrib/amd/scripts/automount2amd.in
blob: e99c74b8dd9a8a232c459fe7b8b141b5858f51d8 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!@PERL@ -w
#
# Convert Sun automount map format to amd format
#
# Package:      am-utils-6.0
# Author:       Mike Walker <mike@tab00.larc.nasa.gov>
#		Erez Zadok <ezk@cs.columbia.edu>
#
# This program expects maps with the format
#
#   dir  [ -options ]  machine:/path [ # optional comment ]
#   ...
#
# and generates an equivalent amd map as follows:
#
#   # generated by automountamd on Fri May 21  9:16:56 1993
#
#   /defaults \
#     type:=nfs;opts:=rw,grpid,nosuid,utimeout=600
#
#   dir \
#     hostd==machine.larc.nasa.gov;type:=link;fs:=/path || \
#     domain==larc.nasa.gov;rhost:=machine;rfs:=/path || \
#     rhost:=machine.larc.nasa.gov;rfs:=/path
#   ...
#
# You should set the DOMAIN and DEFAULT variables to your preferences.
#
# $Id: automount2amd.in,v 1.1 1999/08/16 01:16:36 ezk Exp $
#

require "ctime.pl";

# amd domain name (doesn't have to be the DNS domain; isn't overloading great!)
# Should be what you will pass to amd via the -d command-line switch, if any.
$DOMAIN='';

# amd default settings; consult the docs for what you can/should do here.
# Note, in particular, that if your disk mount points follow a common scheme
# you can specify ``rfs:=/common/path/${key}'' and not have to insert that
# line (twice) in every entry below!
$DEFAULTS='type:=nfs;opts:=rw,grpid,nosuid,utimeout=600';


# print comment header and default string
printf "# generated by automount2amd on %s\n", &ctime(time);
printf "/defaults \\\n  %s\n\n", $DEFAULTS;

# loop through map
while (<>) {
    if (m,^(\w\S*)(\s+\-\w\S*\s+|\s+)(\w[^:]*):(\/\S*)\s*(.*),) {
	($dir, $options, $machine, $path, $rest) = ($1, $2, $3, $4, $5);
	print "#$rest\n" if ($rest =~ m/\w/);
	print "$dir \\\n";
	if ($options =~ m/-/) {
	    $options =~ s/\s//g;
	    $options =~ s/^-//g;
	    printf( "  -addopts:=$options \\\n");
	}
	if (defined($DOMAIN) && $DOMAIN ne "") {
	    printf("  hostd==%s.%s;type:=link;fs:=%s || \\\n",
		   $machine, $DOMAIN, $path);
	    printf("  domain==%s;rhost:=%s;rfs:=%s || \\\n",
		   $DOMAIN, $machine, $path);
	    printf "  rhost:=%s.%s;rfs:=%s\n\n", $machine, $DOMAIN, $path;
	} else {
	    printf("  host==%s;type:=link;fs:=%s \\\n",
		   $machine, $path);
	    printf "  rhost:=%s;rfs:=%s\n\n", $machine, $path;
	}
    }
}
OpenPOWER on IntegriCloud