ypsetup.sh
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· Shell 代码 · 共 1,039 行 · 第 1/2 页
SH
1,039 行
#! /bin/sh# @(#)ypsetup.sh 4.3 (ULTRIX) 9/7/90# # Copyright (c) 1986 by # Digital Equipment Corporation, Maynard, MA # All rights reserved. # # This software is furnished under a license and may be used and # copied only in accordance with the terms of such license and # with the inclusion of the above copyright notice. This # software or any other copies thereof may not be provided or # otherwise made available to any other person. No title to and # ownership of the software is hereby transferred. # # The information in this software is subject to change without # notice and should not be construed as a commitment by Digital # Equipment Corporation. # # Digital assumes no responsibility for the use or reliability # of its software on equipment which is not supplied by Digital. ## Purpose: Set up Yellow Pages# Usage: ypsetup [ {domainname} client [ {file} ] ]# Environment: Bourne shell script# Date: 6/30/86# Author: Fred L. Templin# # Remarks:# Sets up files:# /etc/rc.local# /usr/lib/crontab# /etc/yp/{domainname}/*# /etc/svcorder### Modification History## 9/06/90 -- terry# Added message to remind user that master files should be# in the directory /var/yp/src.# Modified yppasswdd information to use /var/yp/src instead# of /etc.## 7/17/90 -- terry# Added -X option (initial bind) to ypbind.## 12/1/89 -- terry# Added code to remove /etc/yp/src/passwd.tmp on boot if it# exists. ## 10/17/89 -- terry# Added -S option to ypbind.## 07/24/89 -- sue# Added message to tell user to edit the $SVC file.## 11/10/88 -- logcher# Updated with V3.0 changes.## 08/29/88 -- logcher# Added "local" to svcorder file for consistency## 06/13/88 -- logcher# Changed silent client adding to take the root directory# pathname and modify /etc files rc.local and svcorder# relatively, on the client.## 04/18/88 -- logcher# Modified yp check in /etc/svcorder file for ^yp and ^YP## 02/24/88 -- fglover# Modify editorial text for /etc/svcorder file## 01/26/88 -- fglover# Add support for /etc/svcorder file### Set up interrupt handlers:#QUIT=' if [ -r $YPTMP ] then rm $YPTMP fi if [ -r $RCTMP ] then rm $RCTMP fi if [ -r $CRTMP ] then rm $CRTMP fi echo "Ypsetup terminated with no installations made." exit 1'QMSG=' echo "Please clean up ${YPDIR}/${ypdomain} !!" eval "$QUIT"'## Trap ^c signal, etc.#trap 'eval "$QUIT"' 1 2 3 15# filesYPTMP=/tmp/ypsetup.yp.$$RCTMP=/tmp/ypsetup.rc.$$CRTMP=/tmp/ypsetup.cr.$$HOSTS=/etc/hostsYPDIR=/etc/ypYPLOG=ypxfr.logRCFILE=/etc/rc.localCRFILE=/usr/lib/crontabNULL=/dev/nullSVCORDER=/etc/svcorderSVCSETUP=/usr/etc/svcsetupSVC=/etc/svc.confCLIENTROOT=""# commandsMAKE="make -f /etc/yp/Makefile"MAKEDBM=/etc/yp/makedbmYPXFR=/etc/yp/ypxfrYPSETUP=/etc/ypsetup# definesLOCAL_KEY="echo -n 'local daemons:'"YPSTART_KEY="# %YPSTART% - Yellow Pages daemons added by \"ypsetup\""YPEND_KEY="# %YPEND%"NFSSTART_KEY="# %NFSSTART% - NFS daemons added by \"nfssetup\""PATH=$PATH:$YPDIRexport PATHDEFMAPS="group.bygid group.byname hosts.byaddr hosts.byname \mail.aliases netgroup netgroup.byuser netgroup.byhost networks.byaddr \networks.byname passwd.byname passwd.byuid protocols.byname protocols.bynumber \services.byname ypservers"S_OPT=""ypdomain=""startup=""flavor=""verbose=yfirst_time=yscratch_maps=y## PHASE ONE: Gather data!!#if [ $1 ]then # # Run fast and silent for DMS client setup. # ypdomain=$1 if [ $2 ] && [ $2 = "client" ] then verbose="" flavor=c if [ $3 ] then CLIENTROOT=$3 fi # # Require it to be run by root # if [ \! -w $CLIENTROOT$RCFILE ] then exit 1 fi # # Run it multi-user # hname=`hostname` if [ $? -ne 0 ] || [ \! -d $YPDIR ] then exit 1 fi # # See if this is a re-install # egrep -s "$YPSTART_KEY" $CLIENTROOT$RCFILE if [ $? -eq 0 ] then egrep -s "$YPEND_KEY" $CLIENTROOT$RCFILE if [ $? -ne 0 ] then exit 1 fi first_time="" fi else echo "usage: ypsetup [ {domainname} client [ {file} ] ]" eval "$QUIT" fifiif [ $verbose ]then # # Require it to be run by root # if [ \! -w $CLIENTROOT$RCFILE ] then echo "Please su to root first." eval "$QUIT" fi # # Be sure network has already been set up, and this baby has a name!! # hname=`hostname` if [ $? -ne 0 ] || [ \! -d $YPDIR ] then echo "Please bring the system to multi-user mode before running ypsetup." eval "$QUIT" fi # # # See if this is a re-install # egrep -s "$YPSTART_KEY" $CLIENTROOT$RCFILE if [ $? -eq 0 ] then egrep -s "$YPEND_KEY" $CLIENTROOT$RCFILE if [ $? -ne 0 ] then echo "The Yellow Pages environment for this host has already been installedbut can not be reconfigured automatically. To change the current YPconfiguration, edit the file $RCFILE to remove the old YP environmentand run ypsetup again." eval "$QUIT" fi echo "The Yellow Pages environment for this host has already been installed.Would you like to change the current YP configuration?" again=y while [ $again ] do again="" echo -n "Enter \"y\" or \"n\" [no default]: " read ans case $ans in [yY]*) first_time="" ;; [nN]*) eval "$QUIT" ;; *) again=y ;; esac done fi if [ $first_time ] then echo -n "The ypsetup command configures the Yellow Pages (YP) environmentfor your system. Yellow Pages provides a distributed data lookupservice for sharing information between systems on the network.Information is kept in database files known as YP maps. These mapsare organized in YP domains which are collections of maps locatedon certain systems on the network known as servers. For each domain,there are three flavors of systems on the network: - a master YP server is a system which is responsible for maintaining the master copy of the domain's database. There should be ONLY ONE master server for a domain. - a slave YP server is a system which periodically receives updated versions of the master server's maps. The slave server can look up and return information in its private collection of maps, and can take over for the master server in the event of a failure. - a YP client is a system which has no local copies of the domain's database, but can look up database information by requesting service from a master or slave server.[ Press the RETURN key to continue ] : " read junk fi echo "ypsetup will take you through a configuration process to set thedefault YP domain name of your system, determine the flavor ofyour Yellow Pages environment and construct the default YP mapfiles for this YP domain. Default answers are shown in squarebrackets ([]). To use a default answer, press the RETURN key." # # did he specify a new domainname? # if [ -n "$ypdomain" ] then echo "Using \"$ypdomain\" as the default YP domain name for this system." else # # Ask him for a name... # again=y echo "In order to use the Yellow Pages service, your host must have adefault YP domain name." while [ $again ] do echo -n "Please enter a name to be used as the default YP domain name : " read ypdomain case $ypdomain in "") ;; *) again="" ;; esac done fi # # Set domain name # domainname $ypdomain prompt=y echo "Will you be configuring your system as a master YP server,slave YP server, or YP client for the domain \"${ypdomain}\" ?" while [ $prompt ] do prompt="" echo -n "Enter \"m\" for MASTER, \"s\" for SLAVE, or \"c\" for CLIENT [c]: " read flavor case $flavor in [mM]*) echo "Before configuring your system as a master YP server, youmust first be sure that NO OTHER SYSTEM ON THE NETWORK ISCONFIGURED AS A MASTER SERVER FOR THIS DOMAIN!! If a masterYP server is already configured, or you are unsure, pleaseexit ypsetup now." chk=y while [ $chk ] do chk="" echo -n "Enter \"e\" to EXIT or \"c\" to CONTINUE [no default]: " read query case $query in [eE]*) eval "$QUIT" ;; [cC]*) ;; *) chk=y ;; esac done echo "As the master YP server for the domain ${ypdomain}, you may chooseto run the yppasswdd(8yp) server daemon to allow remote passwordupdates to the master copy of the passwd file (/var/yp/src/passwd). " run_yppasswdd=n chk=y while [ $chk ] do chk="" echo -n "Would you like to run the yppasswdd daemon [n]? " read query case $query in [yY]*) run_yppasswdd=y ;; [nN]*|"") ;; *) chk=y ;; esac done if [ -d $YPDIR/$ypdomain ] then echo "The YP maps have already been initialized for the domain\"${ypdomain}\". If you are changing your current YP config-uration from a slave server or a client to a master server,the YP maps MUST be remade! Please be sure that the YP filesthat you will be distributing are in the directory /var/yp/src.Would you like ypsetup to remake the maps in the ${YPDIR}/${ypdomain} directory? " again=y while [ $again ] do again="" echo -n "Enter \"y\", \"n\", or \"e\" to EXIT ypsetup [no default]: " read ans case $ans in [yY]*) scratch_maps=y ;; [eE]*) eval "$QUIT" ;; [nN]*) scratch_maps="" ;; *) again=y ;; esac done fi if [ $scratch_maps ] then echo "You will now be asked to list the names of other hosts which willbe configured as servers for maps in this YP domain. (This hostis included in the list by default). This list will be used to namethe recipients of any updates to your hosts YP maps. Enter only thenames of known hosts which have been initialized in the /etc/hostsfile and press the RETURN key to terminate the list:" not_done=y while [ $not_done ] do query=y # # Enter this host first... # echo $hname > $YPTMP while [ $query ] do echo -n " Name of host: " read servname if [ $servname ] then good=`cat $HOSTS | awk " BEGIN { found = 0 } /[ \t]${servname}[ \t]/ { found = 1; print \"y\" } END { if ( found == 0 ) print \"n\" }"` # # had to put this in to recognize hostnames followed by EOL # good1=`cat $HOSTS | awk " BEGIN { found = 0 } /[ \t]${servname}$/ { found = 1; print \"y\" } END { if ( found == 0 ) print \"n\" }"` if [ $good = y ] || [ $good1 = y ] then if [ $servname = $hname ] then echo " Can't name this host!" echo "" else echo $servname >> $YPTMP fi else echo " \"$servname\" NOT a known host!" echo "" fi else query="" fi done # # Ask for verification... # echo "The list of Yellow Pages servers is:" awk ' { printf "\t%s\n", $0 }' $YPTMP echo "You may now redo this list, exit the setup procedure, or continue.If you choose to continue, the default set of YP maps for your hostwill now be initialized. Please be sure that the YP files that you will be distributing are in the /var/yp/src directory.THIS PROCEDURE TAKES TIME!!" query=y while [ $query ] do echo -n "Enter \"r\" to REDO the servers list, \"e\" to EXIT ypsetupprocedure, or \"c\" to CONTINUE [no default]: " read resp case $resp in [cC]*) not_done="" query="" ;; [rR]*) query="" ;; [eE]*) eval "$QUIT" ;; *) ;; esac done done trap 'eval "$QMSG"' 1 2 3 15
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?