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