Add a -l argument to ypinit that allows adding servers in the format

server1,server2,server3 on the command line.  This allows the user to
optionally avoid the interactive mode of ypinit.  If the -l flag is not
supplied, the old behavior is retained.

This allows users to do things like rsh out creation of YP clients, and
sushi to generate yp clients/servers/slaves.
This commit is contained in:
garbled 2001-08-01 07:01:03 +00:00
parent 1b56a92cf9
commit 3815ce799a
2 changed files with 75 additions and 48 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ypinit.8,v 1.7 1999/03/07 11:58:26 mycroft Exp $
.\" $NetBSD: ypinit.8,v 1.8 2001/08/01 07:01:03 garbled Exp $
.\"
.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -34,7 +34,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd January 4, 1997
.Dd July 31, 2001
.Dt YPINIT 8
.Os
.Sh NAME
@ -44,13 +44,16 @@
.Nm ""
.Fl c
.Op Ar domainname
.Op Fl l Ar server1,...,serverN
.Nm ""
.Fl m
.Op Ar domainname
.Op Fl l Ar server1,...,serverN
.Nm ""
.Fl s
.Ar master_server
.Op Ar domainname
.Op Fl l Ar server1,...,serverN
.Sh DESCRIPTION
.Nm
initialises the files and directories that are required for a
@ -74,6 +77,10 @@ Initialises
to contain a list of ypservers for
.Xr ypbind 8
to connect to.
.It Fl l Ar server1,...,serverN
Set the list of client servers from the command line rather than
prompting for them interactively. The format is a comma separated list
of server names with no spaces.
.It Fl m
Create a master
.Tn YP

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: ypinit.sh,v 1.9 2001/06/18 11:21:54 lukem Exp $
# $NetBSD: ypinit.sh,v 1.10 2001/08/01 07:01:03 garbled Exp $
#
# ypinit.sh - setup a master or slave YP server
#
@ -30,7 +30,7 @@ if [ `${ID} -u` != 0 ]; then
exit 1
fi
args=`getopt cms: $*`
args=`getopt cl:ms: $*`
if [ $? -eq 0 ]; then
set -- $args
for i; do
@ -49,6 +49,12 @@ if [ $? -eq 0 ]; then
shift
shift
;;
"-l")
noninteractive=yes
serverlist=${2}
shift
shift
;;
"--")
shift
break
@ -66,9 +72,9 @@ fi
if [ -z ${servertype} ]; then
cat 1>&2 << __usage
usage: ${progname} -c [domainname]
${progname} -m [domainname]
${progname} -s master_server [domainname]
usage: ${progname} -c [domainname] [-l server1,...,serverN]
${progname} -m [domainname] [-l server1,...,serverN]
${progname} -s master_server [domainname] [-l server1,...,serverN]
The \`-c' flag sets up a YP client, the \`-m' flag builds a master YP
server, and the \`-s' flag builds a slave YP server. When building a
@ -129,60 +135,74 @@ __no_dir
exit 1
fi
cat << __client_setup
if [ -z "${noninteractive}" ]; then
cat << __client_setup
A YP client needs a list of YP servers to bind to.
Whilst ypbind supports -broadcast, its use is not recommended.
__client_setup
done=
while [ -z "${done}" ]; do
> ${tmpfile}
cat <<__list_of_servers
done=
while [ -z "${done}" ]; do
> ${tmpfile}
cat <<__list_of_servers
Please enter a list of YP servers, in order of preference.
When finished, press RETURN on a blank line or enter EOF.
__list_of_servers
if [ "${servertype}" != "client" ]; then
echo ${host} >> ${tmpfile}
echo " next host: ${host}";
fi
echo -n " next host: ";
while read nextserver ; test -n "${nextserver}"
do
echo ${nextserver} >> ${tmpfile}
echo -n " next host: ";
done
if [ -s ${tmpfile} ]; then
echo ""
echo "The current servers are:"
echo ""
cat ${tmpfile}
echo ""
echo -n "Is this correct? [y/n: n] "
read DONE
case ${DONE} in
y*|Y*)
done=yes
;;
esac
else
echo ""
echo "You have not supplied any servers."
fi
if [ -z "${done}" ]; then
echo -n "Do you wish to abort? [y/n: n] "
read ABORT
case ${ABORT} in
y*|Y*)
exit 0
;;
esac
fi
done
else # interacive
if [ "${servertype}" != "client" ]; then
echo ${host} >> ${tmpfile}
echo " next host: ${host}";
fi
echo -n " next host: ";
while read nextserver ; test -n "${nextserver}"
do
echo ${nextserver} >> ${tmpfile}
echo -n " next host: ";
done
if [ -s ${tmpfile} ]; then
echo ""
echo "The current servers are:"
echo ""
cat ${tmpfile}
echo ""
echo -n "Is this correct? [y/n: n] "
read DONE
case ${DONE} in
y*|Y*)
done=yes
;;
esac
else
echo ""
echo "You have not supplied any servers."
fi
if [ -z "${done}" ]; then
echo -n "Do you wish to abort? [y/n: n] "
read ABORT
case ${ABORT} in
y*|Y*)
exit 0
;;
esac
fi
done
echo "${serverlist}" | sed -e 's/,/\
/g' >> ${tmpfile}
#the above newline is required
echo ""
echo "The current servers are:"
echo ""
cat ${tmpfile}
echo ""
fi # interactive
if [ -s ${tmpfile} ]; then
${INSTALL} -c -m 0444 ${tmpfile} ${binding_dir}/${domain}.ypservers