Merge commit 'a058d1cc571af5fbcfe7f1d719df1abbfdb722f3' into merges
[unleashed.git] / usr / src / cmd / ypcmd / multi.sh
blob9286bd6dec35d5371fa6e761c3cf9896702bd5e1
1 #!/bin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
24 #ident "%Z%%M% %I% %E% SMI"
26 # Copyright (c) 1996, by Sun Microsystems, Inc.
27 # All rights reserved.
29 # Script to examine hosts file and make "magic" entries for
30 # those hosts that have multiple IP addresses.
34 MAKEDBM=/usr/sbin/makedbm
35 STDHOSTS=/usr/lib/netsvc/yp/stdhosts
36 MULTIAWK=/usr/lib/netsvc/yp/multi.awk
37 MAP="hosts.byname"
39 USAGE="Usage: multi [-b] [-l] [-s] [-n] [hosts file]
40 Where:
41 -b Add YP_INTERDOMAIN flag to hosts map
42 -l Convert keys to lower case before creating map
43 -s Add YP_SECURE flag to hosts map
44 -n Add IPv6 and IPv4 host addresses to ipnodes map
46 hosts file defaults to /etc/hosts"
48 while getopts blsn c
50 case $c in
51 b) BFLAG=-b;;
52 l) LFLAG=-l;;
53 s) SFLAG=-s;;
54 n) NFLAG=-n;;
55 \?) echo "$USAGE"
56 exit 2;;
57 esac
58 done
60 if [ "$NFLAG" = "-n" ]
61 then
62 MAP="ipnodes.byname"
65 shift `expr $OPTIND - 1`
67 if [ "$1" ]
68 then
69 HOSTS=$1
70 elif [ "$NFLAG" = "-n" ]
71 then
72 HOSTS=/etc/inet/ipnodes
73 else
74 HOSTS=/etc/hosts
77 if [ "$HOSTS" = "-" ]
78 then
79 unset HOSTS
82 cd /var/yp/`domainname` && \
83 sed -e '/^[ ]*$/d' -e '/^#/d' -e 's/#.*$//' $HOSTS | \
84 $STDHOSTS $NFLAG | \
85 $MULTIAWK - | \
86 $MAKEDBM $BFLAG $LFLAG $SFLAG - $MAP