xref: /titanic_44/usr/src/cmd/ypcmd/multi.sh (revision 4eaa471005973e11a6110b69fe990530b3b95a38)
1#!/bin/sh
2#
3# CDDL HEADER START
4#
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.
9#
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.
14#
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]
20#
21# CDDL HEADER END
22#
23#
24#ident	"%Z%%M%	%I%	%E% SMI"
25#
26# Copyright (c) 1996, by Sun Microsystems, Inc.
27# All rights reserved.
28#
29# Script to examine hosts file and make "magic" entries for
30# those hosts that have multiple IP addresses.
31#
32#
33
34MAKEDBM=/usr/sbin/makedbm
35STDHOSTS=/usr/lib/netsvc/yp/stdhosts
36MULTIAWK=/usr/lib/netsvc/yp/multi.awk
37MAP="hosts.byname"
38
39USAGE="Usage: multi [-b] [-l] [-s] [-n] [hosts file]
40Where:
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
45
46	hosts file defaults to /etc/hosts"
47
48while getopts blsn c
49do
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
58done
59
60if [ "$NFLAG" = "-n" ]
61then
62	MAP="ipnodes.byname"
63fi
64
65shift `expr $OPTIND - 1`
66
67if [ "$1" ]
68then
69    HOSTS=$1
70elif [ "$NFLAG" = "-n" ]
71then
72    HOSTS=/etc/inet/ipnodes
73else
74    HOSTS=/etc/hosts
75fi
76
77if [ "$HOSTS" = "-" ]
78then
79    unset HOSTS
80fi
81
82cd /var/yp/`domainname` && \
83    sed -e '/^[ 	]*$/d' -e '/^#/d' -e 's/#.*$//' $HOSTS | \
84    $STDHOSTS $NFLAG | \
85    $MULTIAWK - | \
86    $MAKEDBM $BFLAG $LFLAG $SFLAG - $MAP
87