summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rwxr-xr-x[-rw-r--r--]usr/src/cmd/ypcmd/ypinit.sh209
-rw-r--r--usr/src/man/man1m/ypinit.1m19
2 files changed, 120 insertions, 108 deletions
diff --git a/usr/src/cmd/ypcmd/ypinit.sh b/usr/src/cmd/ypcmd/ypinit.sh
index a4c1652665..41dc12e955 100644..100755
--- a/usr/src/cmd/ypcmd/ypinit.sh
+++ b/usr/src/cmd/ypcmd/ypinit.sh
@@ -19,6 +19,7 @@
#
# CDDL HEADER END
#
+# Copyright 2014 Nexenta Systems, Inc. All rights reserved.
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
@@ -29,8 +30,6 @@
# Portions of this source code were derived from Berkeley 4.3 BSD
# under license from the Regents of the University of California.
-#ident "%Z%%M% %I% %E% SMI"
-
# set -xv
YPXFR=/usr/lib/netsvc/yp/ypxfr
MAKEPATH=/usr/ccs/bin
@@ -50,6 +49,7 @@ def_dom=""
master=""
got_host_list=F
first_time=T
+non_interactive=F
exit_on_error=F
errors_in_setup=F
@@ -84,12 +84,13 @@ export PATH
# To do cleanup
trap '/usr/bin/rm -f $hf' 0 1 2 3 15
+# Check out total number of arguments
case $# in
1) case $1 in
-c) clientp=T;;
-m) masterp=T;;
*) echo 'usage:'
- echo ' ypinit -c'
+ echo ' ypinit -c [server_name...]'
echo ' ypinit -m'
echo ' ypinit -s master_server'
echo ""
@@ -111,9 +112,13 @@ master_server must be an existing reachable yp server."
echo "server not found in $hosts_file or $hosts6_file"
exit 1
fi;;
-
+
+ # the case with more than one argument with the '-c' option
+ # is a subject to enter non-interactive mode
+ -c) clientp=T; non_interactive=T;
+ ;;
*) echo 'usage:'
- echo ' ypinit -c'
+ echo ' ypinit -c [server_name...]'
echo ' ypinit -m'
echo ' ypinit -s master_server'
echo ""
@@ -125,10 +130,14 @@ yp server data base, and -s is used for a slave data base."
master_server must be an existing reachable yp server."
exit 1;;
esac;;
-3) case $1 in
- -c) clientp=T;;
+*) case $1 in
+
+ # the case with more than one argument with the '-c' option
+ # is a subject to enter non-interactive mode
+ -c) clientp=T; non_interactive=T;
+ ;;
*) echo 'usage:'
- echo ' ypinit -c'
+ echo ' ypinit -c [server_name...]'
echo ' ypinit -m'
echo ' ypinit -s master_server'
echo ""
@@ -140,19 +149,6 @@ yp server data base, and -s is used for a slave data base."
master_server must be an existing reachable yp server."
exit 1;;
esac;;
-
-*) echo 'usage:'
- echo ' ypinit -c'
- echo ' ypinit -m'
- echo ' ypinit -s master_server'
- echo ""
- echo "\
-where -c is used to set up a yp client, -m is used to build a master "
- echo "\
-yp server data base, and -s is used for a slave data base."
- echo "\
-master_server must be an existing reachable yp server."
- exit 1;;
esac
if [ $? -ne 0 ]
@@ -222,97 +218,114 @@ fi
if [ $slavep = F ]
then
- while [ $got_host_list = F ]; do
- touch $hf # make sure file exists
- echo ""
- echo "\
+ if [ $non_interactive = F ]
+ then
+ while [ $got_host_list = F ]; do
+ touch $hf # make sure file exists
+ echo ""
+ echo "\
In order for NIS to operate sucessfully, we have to construct a list of the "
- echo "\
+ echo "\
NIS servers. Please continue to add the names for YP servers in order of"
- echo "\
+ echo "\
preference, one per line. When you are done with the list, type a <control D>"
- echo "\
+ echo "\
or a return on a line by itself."
- if [ $masterp = T ]
- then
- echo $host > $hf
- echo "\tnext host to add: $host"
- elif [ -f $binding_file ]
- then
- if [ $first_time = T ]
+ if [ $masterp = T ]
then
- for h in `cat $binding_file`
- do
- echo $h >> $hf
- echo "\tnext host to add: $h"
- done
+ echo $host > $hf
+ echo "\tnext host to add: $host"
+ elif [ -f $binding_file ]
+ then
+ if [ $first_time = T ]
+ then
+ for h in `cat $binding_file`
+ do
+ echo $h >> $hf
+ echo "\tnext host to add: $h"
+ done
+ fi
fi
- fi
- echo "\tnext host to add: \c"
+ echo "\tnext host to add: \c"
+
+ while read h ; test -n "$h"
+ do
+ #
+ # Host should be in the v4 or v6 hosts file or
+ # reasonably resemble an IP address. We'll do a
+ # sanity check that a v4 addr is one word consisting
+ # of only numbers and the "." character,
+ # which should guard against fully qualified
+ # hostnames and most malformed entries. IPv6
+ # addresses can be numbers, hex letters, and have
+ # at least one ":" character and possibly one or
+ # more "." characters for embedded v4 addresses
+ #
+ if ( grep $h $hosts_file $hosts6_file > /dev/null ) || \
+ ( test $clientp = T && `is_valid_ipaddr $h` )
+ then
+ echo $h >> $hf
+ echo "\tnext host to add: \c"
+ else
+ echo "host $h not found in $hosts_file or" \
+ "$hosts6_file.\nNot added to the list."
+ echo ""
+ echo "Do you wish to abort [y/n: y] \c"
+ read cont_ok
+
+ case $cont_ok in
+ n*) echo "\tnext host to add: \c";;
+ N*) echo "\tnext host to add: \c";;
+ *) exit 1;;
+ esac
+ fi
+ done
- while read h ; test -n "$h"
- do
- #
- # Host should be in the v4 or v6 hosts file or
- # reasonably resemble an IP address. We'll do a
- # sanity check that a v4 addr is one word consisting
- # of only numbers and the "." character,
- # which should guard against fully qualified
- # hostnames and most malformed entries. IPv6
- # addresses can be numbers, hex letters, and have
- # at least one ":" character and possibly one or
- # more "." characters for embedded v4 addresses
- #
- if ( grep $h $hosts_file $hosts6_file > /dev/null ) || \
- ( test $clientp = T && `is_valid_ipaddr $h` )
+ echo ""
+ if [ -s $hf ]
then
- echo $h >> $hf
- echo "\tnext host to add: \c"
+ echo "The current list of yp servers looks like this:"
+ echo ""
+ cat $hf
+ echo ""
+ echo "Is this correct? [y/n: y] \c"
else
- echo "host $h not found in $hosts_file or" \
- "$hosts6_file.\nNot added to the list."
+ echo "You have not added any server information."
echo ""
- echo "Do you wish to abort [y/n: y] \c"
- read cont_ok
-
- case $cont_ok in
- n*) echo "\tnext host to add: \c";;
- N*) echo "\tnext host to add: \c";;
- *) exit 1;;
- esac
+ echo "Do you still wish to exit? [y/n: y] \c"
fi
+ read hlist_ok
+
+ case $hlist_ok in
+ n*) got_host_list=F
+ first_time=F
+ rm $hf
+ echo "Let's try the whole thing again...";;
+ N*) got_host_list=F
+ first_time=F
+ rm $hf
+ echo "Let's try the whole thing again...";;
+ *) got_host_list=T;;
+ esac
done
-
- echo ""
- if [ -s $hf ]
- then
- echo "The current list of yp servers looks like this:"
- echo ""
- cat $hf
- echo ""
- echo "Is this correct? [y/n: y] \c"
- else
- echo "You have not added any server information."
- echo ""
- echo "Do you still wish to exit? [y/n: y] \c"
- fi
-
- read hlist_ok
-
- case $hlist_ok in
- n*) got_host_list=F
- first_time=F
- rm $hf
- echo "Let's try the whole thing again...";;
- N*) got_host_list=F
- first_time=F
- rm $hf
- echo "Let's try the whole thing again...";;
- *) got_host_list=T;;
- esac
- done
+ else
+ shift
+ > $hf
+ while [[ $# > 0 ]]; do
+ if ( grep $1 $hosts_file $hosts6_file > /dev/null ) || \
+ ( `is_valid_ipaddr $1` )
+ then
+ echo $1 >> $hf
+ else
+ echo "host $1 not found in $hosts_file or" \
+ "$hosts6_file.\nNot added to the list."
+ echo ""
+ fi
+ shift
+ done
+ fi
if [ -s $hf ]
then
diff --git a/usr/src/man/man1m/ypinit.1m b/usr/src/man/man1m/ypinit.1m
index 92b95dd064..6ba6a0f9f2 100644
--- a/usr/src/man/man1m/ypinit.1m
+++ b/usr/src/man/man1m/ypinit.1m
@@ -4,17 +4,19 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH YPINIT 1M "Dec 20, 2007"
+.\" Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+.TH YPINIT 1M "Dec 15, 2014"
.SH NAME
ypinit \- set up NIS client
.SH SYNOPSIS
.LP
.nf
-\fB/usr/sbin/ypinit\fR [\fB-c\fR] [\fB-m\fR] [\fB-s\fR \fImaster_server\fR]
+\fB/usr/sbin/ypinit\fR \fB-m\fR
+\fB/usr/sbin/ypinit\fR \fB-s\fR [\fImaster_server\fR]
+\fB/usr/sbin/ypinit\fR \fB-c\fR [\fIserver_name...\fR]
.fi
.SH DESCRIPTION
-.sp
.LP
\fBypinit\fR can be used to set up an \fBNIS\fR client system. You must be the
superuser to run this command. This script need not be used at all if
@@ -40,14 +42,15 @@ name.
\fB/var/yp/binding/\fIdomain\fR/ypservers\fR. This file is used by \fBypbind\fR
when run without the \fB-broadcast\fR option.
.SH OPTIONS
-.sp
.ne 2
.na
-\fB\fB-c\fR\fR
+\fB\fB-c\fR\fR [\fIserver_name...\fR]
.ad
.sp .6
.RS 4n
-Set up a \fBypclient\fR system.
+Set up a \fBypclient\fR system. If \fIserver_name\fR is specified, it will
+replace currently configured list of servers. \fIserver_name\fR could be
+represented by IPv4/v6 address as well as by hostname.
.RE
.sp
@@ -72,7 +75,6 @@ Slave data base. \fImaster_server\fR must be the same master configured in the
.RE
.SH FILES
-.sp
.ne 2
.na
\fB\fB/etc/hosts\fR\fR
@@ -93,12 +95,10 @@ Lists the servers to which the NIS client is allowed to bind.
.RE
.SH SEE ALSO
-.sp
.LP
\fBsvcs\fR(1), \fBypwhich\fR(1), \fBsvcadm\fR(1M), \fBypbind\fR(1M),
\fBsysinfo\fR(2), \fBhosts\fR(4), \fBattributes\fR(5), \fBsmf\fR(5)
.SH NOTES
-.sp
.LP
The \fBNIS client\fR service is managed by the service management facility,
\fBsmf\fR(5), under the service identifier:
@@ -116,7 +116,6 @@ Administrative actions on this service, such as enabling, disabling, or
requesting restart, can be performed using \fBsvcadm\fR(1M). The service's
status can be queried using the \fBsvcs\fR(1) command.
.SH BUGS
-.sp
.LP
\fBypinit\fR sets up the list of \fBNIS\fR servers only for the current domain
on the system when it is run, that is, the domain returned by the