ypsetup.sh
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· Shell 代码 · 共 1,039 行 · 第 1/2 页
SH
1,039 行
# # Create Yellow Pages Domain # if [ $scratch_maps ] then rm -rf $YPDIR/$ypdomain fi mkdir $YPDIR/$ypdomain if [ $? -ne 0 ] then echo "Couldn't create the Yellow Pages directory: ${YPDIR}/${ypdomain}." eval "$QUIT" fi # # Make default maps... # echo "Making default YP maps. Please wait..." $MAKEDBM $YPTMP $YPDIR/$ypdomain/ypservers if [ $? -ne 0 ] then echo "Couldn't make the \"ypservers\" map" eval "$QMSG" fi (cd $YPDIR/$ypdomain; $MAKE NOPUSH=1) if [ $? -ne 0 ] then echo "Couldn't make the default YP maps" eval "$QMSG" fi echo "Installation of default maps complete..." fi ;; [sS]*) 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 master server or a client to a slave server,the YP maps MUST be remade! Would you like ypsetup to remakethe 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 "Before configuring your system as a slave YP server, you mustfirst know the name of the master YP server for domain \"${ypdomain}\"and be sure that it is up. If no master YP server is configured,you will not be able to retrieve a set of YP maps for your system." answer=y while [ $answer ] do echo -n "Enter \"e\" to EXIT or \"c\" to CONTINUE [no default] ? " read ans case $ans in [cC]*) answer="" ;; [eE]*) eval "$QUIT" ;; *) ;; esac done # # get master server's name. # answer=y while [ $answer ] do echo -n "Please enter the name of the master YP server for domain \"${ypdomain}\": " read master if [ $master ] then good=`cat $HOSTS | awk " BEGIN { found = 0 } /[ \t]${master}[ \t]/ { found = 1; print \"y\" } END { if ( found == 0 ) print \"n\" }"` good1=`cat $HOSTS | awk " BEGIN { found = 0 } /[ \t]${master}$/ { found = 1; print \"y\" } END { if ( found == 0 ) print \"n\" }"` if [ $good = y ] || [ $good1 = y ] then if [ $master = $hname ] then echo " Can't name this host!" echo "" else answer="" fi else echo " \"${master}\" NOT a known host!" echo "" fi fi done trap 'eval "$QMSG"' 1 2 3 15 # # Create Yellow Pages Domain # if [ $scratch_maps ] then rm -rf $YPDIR/$ypdomain fi mkdir $YPDIR/$ypdomain if [ $? -ne 0 ] then echo "Couldn't create the Yellow Pages directory: ${YPDIR}/${ypdomain}." eval "$QUIT" fi # # Copy master's maps to slave # echo "Copying YP maps for this domain from host \"${master}\".THIS PROCEDURE TAKES TIME!!" noerrs=y for mname in $DEFMAPS do $YPXFR -h $master -c -d $ypdomain $mname 2>> $YPDIR/$YPLOG if [ $? -ne 0 ] then echo " Couldn't transfer map \"${mname}\"" noerrs=n fi done if [ $noerrs = n ] then echo "Some YP maps were not initialized. See the file \"/etc/yp/ypxfr.log\"for reasons." fi fi ;; [cC]*|"") # echo "Before configuring your system as a YP client, you shouldfirst be sure that there IS at least one system on thenetwork configured as either a master or slave YP serverfor this domain!! If no server is configured, you will notbe able to access the YP maps!" answer=y while [ $answer ] do echo -n "Enter \"e\" to EXIT or \"c\" to CONTINUE [no default] ? " read ans case $ans in [cC]*) answer="" ;; [eE]*) eval "$QUIT" ;; *) ;; esac done ;; *) # # Bad response... # prompt=y ;; esac done # # Security (-S) option # echo "The -S option locks the domain name and servers list. A single domain name followed by up to four servers can be specified.Once this option is run the machine will not switch domainsand will only use the servers specified. All the specifiedservers must be in the /etc/hosts file." okay=y while [ $okay ] do okay="" echo -n " Would you like to add the -S option to ypbind [n] ? " read s_option case $s_option in [yY]*) S_OPT="-S $ypdomain" bad=y while [ $bad ] do bad="" echo -n "How many servers do you wish to specify [1] ? " read num_serv case $num_serv in "") num_serv=1 ;; [1-4]) ;; *) bad=y ;; esac done orig=`expr $num_serv + 1` while [ $num_serv -gt 0 ] do echo -n " Server `expr $orig - $num_serv` name: " read serv_name S_OPT=${S_OPT},$serv_name num_serv=`expr $num_serv - 1` done ;; [nN]*|"") ;; *) okay=y ;; esac done # # Initial Bind Option (-X) # echo "The Initial Bind option (-X) binds YP to a server at boot time. YP will exit after several minutes if this initial binding fails. If the Initial Bind option is not specified, your system may hangon boot or login if a YP server is not available." okay=y while [ $okay ] do okay="" echo -n " Would you like to use the Initial Bind option with ypbind [n] ?" read s_option case $s_option in [yY]*) X_OPT="-X " ;; [nN]*|"") ;; *) okay=y ;; esac donefi## PHASE TWO... Update files!!#trap "" 1 2 3 15if [ $verbose ]then echo "Installing Yellow Page daemons..."fi## See if the port mapper is already there...#egrep -s '[ ]*/etc/portmap' $CLIENTROOT$RCFILEif [ $? -ne 0 ]then # # Not there... put it in!! # echo "# RPC portmap daemonecho -n 'RPC port mapper:' >/dev/console[ -f /etc/portmap ] && { /etc/portmap ; echo ' portmap.' >/dev/console}" >> $RCTMP startup=`echo $startup "/etc/portmap ; " | cat`fi## Banner, domainname, and ypbind...#echo $YPSTART_KEY >> $RCTMPecho "/bin/domainname ${ypdomain}" >> $RCTMPcase $flavor in[mM]*) echo "echo -n 'YP daemons:' >/dev/console[ -f /etc/portmap -a -f /usr/etc/ypserv ] && { /usr/etc/ypserv ; echo -n ' ypserv' >/dev/console}[ -f /etc/portmap -a -f /etc/ypbind ] && { /etc/ypbind $S_OPT $X_OPT; echo -n ' ypbind $S_OPT $X_OPT' >/dev/console}" >> $RCTMP startup=`echo $startup "/usr/etc/ypserv ; /etc/ypbind $S_OPT $X_OPT; " | cat` if [ $run_yppasswdd = y ] then echo "[ -s /etc/yp/src/passwd -a -f /etc/yp/src/passwd.tmp ] && { rm -f /etc/yp/src/passwd.tmp}[ -f /etc/portmap -a -f /usr/etc/rpc.yppasswdd ] && { /usr/etc/rpc.yppasswdd /var/yp/src/passwd -m passwd \\ DIR=/var/yp/src ; echo -n ' yppasswdd' >/dev/console}" >> $RCTMP startup=`echo $startup "/usr/etc/rpc.yppasswdd /var/yp/src/passwd -m passwd DIR=/var/yp/src ; " | cat` fi ;;[sS]*) echo "echo -n 'YP daemons:' >/dev/console[ -f /etc/portmap -a -f /usr/etc/ypserv ] && { /usr/etc/ypserv ; echo -n ' ypserv' >/dev/console}[ -f /etc/portmap -a -f /etc/ypbind ] && { /etc/ypbind $S_OPT $X_OPT; echo -n ' ypbind $S_OPT $X_OPT' >/dev/console}" >> $RCTMP startup=`echo $startup "/usr/etc/ypserv ; /etc/ypbind $S_OPT $X_OPT" | cat` # # Set updating entries into crontab. (Don't add these for a re-install # of a slave server. # egrep -s '/etc/yp/ypxfr' $CRFILE if [ $? -ne 0 ] then echo "# Local Yellow Pages environment30 * * * * sh /etc/yp/ypxfr_1perhour31 1,13 * * * sh /etc/yp/ypxfr_2perday32 1 * * * sh /etc/yp/ypxfr_1perday" >> $CRTMP fi ;;[cC]*|"") echo "echo -n 'YP daemons:' >/dev/console[ -f /etc/portmap -a -f /etc/ypbind ] && { /etc/ypbind $S_OPT $X_OPT; echo -n ' ypbind $S_OPT $X_OPT ' >/dev/console}" >> $RCTMP startup=`echo $startup "/etc/ypbind $S_OPT $X_OPT; " | cat` ;;esacecho "echo '.' >/dev/console" >> $RCTMPecho $YPEND_KEY >> $RCTMPif [ $first_time ]then # # If NFS is there, start YP first!! # egrep -s "$NFSSTART_KEY" $CLIENTROOT$RCFILE if [ $? -eq 0 ] then ed - $CLIENTROOT$RCFILE << END >> $NULL/$NFSSTART_KEY-.r $RCTMPwqEND else # # No NFS stuff; put 'em before local daemons # egrep -s "$LOCAL_KEY" $CLIENTROOT$RCFILE if [ $? -eq 0 ] then ed - $CLIENTROOT$RCFILE << END >> $NULL/$LOCAL_KEY-.r $RCTMPwqEND else # # Nothing there; put 'em on the end # cat $RCTMP >> $CLIENTROOT$RCFILE fi fielse ed - $CLIENTROOT$RCFILE << END >> $NULL/$YPSTART_KEY/,/$YPEND_KEY/ d-.r $RCTMPwqENDfirm $RCTMPif [ $verbose ]then if [ -f $CRTMP ] then cat $CRTMP >> $CRFILE rm $CRTMP fi if [ $first_time ] then if [ -n "$startup" ] then echo "The necessary Yellow Page daemon entries have been placed in the file$CLIENTROOT${RCFILE}. In order to begin using Yellow Pages, you must nowstart the daemons and add YP escape characters to the \"/etc\" filescorresponding to the maps for this domain. You may either allow ypsetupto start these daemons automatically or invoke them by hand, but in eithercase they will be started automatically on subsequent reboots." answer=y while [ $answer ] do echo -n "Would you like ypsetup to start the daemons automatically [y]? " answer="" read ans case $ans in [yY]*|"") if [ $DEBUG ] then echo $startup else eval "$startup" fi ;; [nN]*) ;; *) answer=y ;; esac done fi else echo "The necessary Yellow Page daemon entries have been placed in the file$CLIENTROOT${RCFILE}. You may start any additional YP daemons add by hand,or allow the new YP configuration to take effect on the next reboot." fifi## Clean up#if [ -r $YPTMP ]then rm $YPTMPfiecho "YP is not used on this system until the $SVC file is editedand \"yp\" is added to the database lists. Failure to do so resultsin the continued use of the current $SVC file. Please run$SVCSETUP or edit $SVC manually. See svcsetup(8)."if [ ! -f $CLIENTROOT$SVCORDER ]then echo "## The /etc/svcorder file designates the order and selection of# ULTRIX name services to be queried in the resolution of host# names and addresses. This file is not required for /etc/hosts# (local) access, but is required to access host names from # the current ULTRIX Yellow Pages and BIND services.## Note that additional preparation is required to set up each # name service. Consult the documentation for further information.#yplocal" >> $CLIENTROOT$SVCORDERfiif [ $verbose ]then echo "" echo "***** YPSETUP COMPLETE *****"fiexit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?