151292Sobrien#!@PERL@ -w 251292Sobrien# 351292Sobrien# Convert Sun automount map format to amd format 451292Sobrien# 5174294Sobrien# Package: am-utils-6.x 651292Sobrien# Author: Mike Walker <mike@tab00.larc.nasa.gov> 751292Sobrien# Erez Zadok <ezk@cs.columbia.edu> 851292Sobrien# 951292Sobrien# This program expects maps with the format 1051292Sobrien# 1151292Sobrien# dir [ -options ] machine:/path [ # optional comment ] 1251292Sobrien# ... 1351292Sobrien# 1451292Sobrien# and generates an equivalent amd map as follows: 1551292Sobrien# 1651292Sobrien# # generated by automountamd on Fri May 21 9:16:56 1993 1751292Sobrien# 1851292Sobrien# /defaults \ 1951292Sobrien# type:=nfs;opts:=rw,grpid,nosuid,utimeout=600 2051292Sobrien# 2151292Sobrien# dir \ 2251292Sobrien# hostd==machine.larc.nasa.gov;type:=link;fs:=/path || \ 2351292Sobrien# domain==larc.nasa.gov;rhost:=machine;rfs:=/path || \ 2451292Sobrien# rhost:=machine.larc.nasa.gov;rfs:=/path 2551292Sobrien# ... 2651292Sobrien# 2751292Sobrien# You should set the DOMAIN and DEFAULT variables to your preferences. 2851292Sobrien# 29174294Sobrien# $Id: automount2amd.in,v 1.2 2002/01/15 18:25:25 ezk Exp $ 3051292Sobrien# 3151292Sobrien 3251292Sobrienrequire "ctime.pl"; 3351292Sobrien 3451292Sobrien# amd domain name (doesn't have to be the DNS domain; isn't overloading great!) 3551292Sobrien# Should be what you will pass to amd via the -d command-line switch, if any. 3651292Sobrien$DOMAIN=''; 3751292Sobrien 3851292Sobrien# amd default settings; consult the docs for what you can/should do here. 3951292Sobrien# Note, in particular, that if your disk mount points follow a common scheme 4051292Sobrien# you can specify ``rfs:=/common/path/${key}'' and not have to insert that 4151292Sobrien# line (twice) in every entry below! 4251292Sobrien$DEFAULTS='type:=nfs;opts:=rw,grpid,nosuid,utimeout=600'; 4351292Sobrien 4451292Sobrien 4551292Sobrien# print comment header and default string 4651292Sobrienprintf "# generated by automount2amd on %s\n", &ctime(time); 4751292Sobrienprintf "/defaults \\\n %s\n\n", $DEFAULTS; 4851292Sobrien 4951292Sobrien# loop through map 5051292Sobrienwhile (<>) { 5151292Sobrien if (m,^(\w\S*)(\s+\-\w\S*\s+|\s+)(\w[^:]*):(\/\S*)\s*(.*),) { 5251292Sobrien ($dir, $options, $machine, $path, $rest) = ($1, $2, $3, $4, $5); 5351292Sobrien print "#$rest\n" if ($rest =~ m/\w/); 5451292Sobrien print "$dir \\\n"; 5551292Sobrien if ($options =~ m/-/) { 5651292Sobrien $options =~ s/\s//g; 5751292Sobrien $options =~ s/^-//g; 5851292Sobrien printf( " -addopts:=$options \\\n"); 5951292Sobrien } 6051292Sobrien if (defined($DOMAIN) && $DOMAIN ne "") { 6151292Sobrien printf(" hostd==%s.%s;type:=link;fs:=%s || \\\n", 6251292Sobrien $machine, $DOMAIN, $path); 6351292Sobrien printf(" domain==%s;rhost:=%s;rfs:=%s || \\\n", 6451292Sobrien $DOMAIN, $machine, $path); 6551292Sobrien printf " rhost:=%s.%s;rfs:=%s\n\n", $machine, $DOMAIN, $path; 6651292Sobrien } else { 6751292Sobrien printf(" host==%s;type:=link;fs:=%s \\\n", 6851292Sobrien $machine, $path); 6951292Sobrien printf " rhost:=%s;rfs:=%s\n\n", $machine, $path; 7051292Sobrien } 7151292Sobrien } 7251292Sobrien} 73