nfssetup.sh
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· Shell 代码 · 共 992 行 · 第 1/2 页
SH
992 行
#! /bin/sh# @(#)nfssetup.sh 4.2 (ULTRIX) 10/16/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 NFS environment# Usage: nfssetup [client] [server]# Environment: Bourne shell script# Date: 6/11/86# Author: Fred L. Templin# # Remarks:# Sets up files:# /etc/rc.local# /etc/exports# /etc/fstab## Much of this has been borrowed from "netsetup.sh"### Modification History:## 03-Dec-89 lebel# Added -i option to mountd for ip address checking## 28-Jul-88 Fred Glover# Add newlines, error checking for #nfsds, #biods## 16-Feb-88 fglover# Add support for NFS locking### Set up interrupt handlers:#QUIT=' if [ -r $EXTMP ] then rm $EXTMP fi if [ -r $FSTMP ] then rm $FSTMP fi if [ -r $RCTMP ] then rm $RCTMP fi echo "Nfssetup terminated with no installations made." exit 1'## Trap ^c signal, etc.#trap 'eval "$QUIT"' 1 2 3 15EXTMP=/tmp/nfssetup.ex.$$FSTMP=/tmp/nfssetup.fs.$$RCTMP=/tmp/nfssetup.rc.$$VMUNIX=/vmunixRCFILE=/etc/rc.localFSFILE=/etc/fstabEXFILE=/etc/exportsNFILE=/etc/networksNFSSETUP=/etc/nfssetupLOCAL_KEY="echo -n 'local daemons:'"NFSSTART_KEY="# %NFSSTART% - NFS daemons added by \"nfssetup\""NFSEND_KEY="# %NFSEND%"NFSLOCKSTART_KEY="# %NFSLOCKSTART%"NFSLOCKEND_KEY="# %NFSLOCKEND%"USR_BIN=/usr/binnnfsd=0nbiod=4rwall=nrlock=nserving=""startup=""verbose=yfirst_time=yfull_config=n## PHASE ONE: Gather data!!#if [ $1 ]then # # Set up default environments for client or server. Runs fast # and silent for ease of use in other scripts. # if [ $1 = "client" ] then verbose="" nbiod=4 elif [ $1 = "server" ] then verbose="" nnfsd=4 nbiod=4 serving=y else echo "usage: nfssetup [ client ] [ server ]" eval "$QUIT" fi # # Require it to be run by root # if [ \! -w $RCFILE ] then exit 1 fi # # Run it multi-user # if [ \! -d $USR_BIN ] then exit 1 fi # # See if this is a re-install # egrep -s "$NFSSTART_KEY" $RCFILE if [ $? -eq 0 ] then egrep -s "$NFSEND_KEY" $RCFILE if [ $? -ne 0 ] then exit 1 fi first_time="" fielse if [ \! -w $RCFILE ] then echo "Please su to root first." eval "$QUIT" fi if [ \! -d $USR_BIN ] then echo "Please bring the system to multi-user mode before running nfssetup." eval "$QUIT" fi egrep -s "$NFSSTART_KEY" $RCFILE if [ $? -eq 0 ] then egrep -s "$NFSEND_KEY" $RCFILE if [ $? -ne 0 ] then echo "The network file system has already been installed but can notbe reconfigured automatically. To change the current NFS config-uration, edit the file $RCFILE to remove the old NFS environmentand run nfssettup again." eval "$QUIT" fi echo "The network file system has already been installed. Wouldyou like to change the current NFS configuration?" again=y while [ $again ] do again="" echo -n "Enter \"y\" or \"n\" [n]: " read ans case $ans in [yY]*) first_time="" ;; [nN]*|"") eval "$QUIT" ;; *) again=y ;; esac done fi if [ $first_time ] then echo "Checking kernel configuration..." nm $VMUNIX | grep -s 'nfs_namei' if [ $? -ne 0 ] then echo "In order to make use of the network file system (NFS) services,you must first configure the NFS support code into your ULTRIX-32kernel. Please consult the System Management Guide for informationon how to configure and bootstrap the new ULTRIX-32 kernel." eval "$QUIT" fi echo "The nfssetup command configures the network file system (NFS)environment for your system. All systems using NFS facilitiesmust run the Remote Procedure Call (RPC) port mapper daemon.An entry for this daemon is placed in the /etc/rc.local filealong with entries for the optional daemons you select." else echo "Changing the current NFS configuration." fi echo "You will be asked a series of questions about your system.Default answers are shown in square brackets ([]). To use adefault answer, press the RETURN key." # # Ask if NFS locking should be enabled # echo "" echo " Local locking supports local file and file region locking. Local locking is the default. NFS locking supports local and remote (NFS) file and file region locking. If you would like to enable the NFS locking functionality, then answer 'y' to the following question." again=y while [ $again ] do again="" echo "" echo -n " NFS locking to be enabled [n] ? " read rlock case $rlock in [yY]*) rlock=y ;; [nN]*|"") rlock=n ;; *) again=y ;; esac done # # Ask if he wants to run a full NFS Configuration... # if [ -z "$first_time" ] then again=y while [ $again ] do again="" echo "" echo -n " Would you like to change the rest of your NFS configuration [n] ? " read full_config case $full_config in [yY]*) full_config=y ;; [nN]*|"") full_config=n ;; *) again=y ;; esac done if [ $full_config = n ] then # # Copy curent rc.local to temp file # stripping %NFSLOCKSTART% to %NFSLOCKEND% # cat $RCFILE | sed "/%NFSLOCKSTART%/,/%NFSLOCKEND%/ d" > $RCTMP cp $RCTMP $RCFILE rm $RCTMP if [ $rlock = y ] then echo $NFSLOCKSTART_KEY >> $RCTMP echo "echo -n 'NFS Locking: ' >/dev/console" >> $RCTMP echo "[ -f /usr/etc/nfssetlock ] && { /usr/etc/nfssetlock on & echo -n 'enabled; ' >/dev/console}" >> $RCTMP echo "[ -f /usr/etc/statd ] && { /usr/etc/statd & echo -n 'daemons: statd ' >/dev/console}" >> $RCTMP echo "[ -f /usr/etc/lockd ] && { /usr/etc/lockd & echo 'and lockd' >/dev/console}" >> $RCTMP echo $NFSLOCKEND_KEY >> $RCTMP ed - $RCFILE << END >> /dev/null/%NFSEND%/-1.r $RCTMP-wq END rm $RCTMP else ed - $RCFILE << END >> /dev/null/$NFSLOCKSTART_KEY/,/$NFSLOCKEND_KEY/ d-wq END fi echo echo -n "Nfssetup terminated with NFS locking " if [ $rlock = y ] then echo "enabled" else echo "disabled" fi echo "and prior NFS configuration maintained." echo exit 0 fi # # End of if not full config # fi # # End of if not first time # # # Determine state of this NFS machine. PURE client (no exports made), # or exporter. # again=y while [ $again ] do again="" echo "" echo -n " Will you be exporting any directories [n] ? " read serving case $serving in [yY]*) serving=y ;; [nN]*|"") serving="" ;; *) again=y ;; esac done if [ $serving ] then # # Since we'll be serving up directories, need to put "nfsd" # in the local rc script along with the others. We'll ask # to see if the user wants more or less daemons than usual. # nnfsd=4 echo "" if [ $first_time ] then echo " Systems that export NFS directories must run /etc/nfsd to handle NFS requests from clients. You can configure up to 20 nfsd daemons, but for average workload situations, 4 is a good number to run." fi flag=y while [ $flag ] do flag="" echo "" echo -n " Enter the number of nfsd servers to run [4] : " read num if [ $num ] then if [ $num -le 0 ] then flag=y echo " Number must be greater than zero" elif [ $num -ge 20 ] then nnfsd=20 else nnfsd=$num fi fi done fi # # Ask if he wants any "biod" daemons. # if [ $first_time ] then echo "" echo " NFS clients can use block I/O daemons for buffering data transfers, although their use is not required. You can configure up to 5 biod daemons on your system based upon the workload you expect, but for average workload situations, 4 is a good number to run." fi flag=y while [ $flag ] do flag="" echo "" echo -n " Enter the number of block I/O daemons to run [4] : " read num if [ $num ] then if [ $num -lt 0 ] then flag=y echo " Number must be greater than or equal zero" elif [ $num -ge 5 ] then nbiod=5 else nbiod=$num fi fi done # # Ask if he wants to run the rwalld daemon... # if [ $first_time ] then echo "" echo " NFS clients that rely heavily on having certain NFS directories mounted may wish to be notified in the event of NFS servers going down. In order for users on your system to receive notifications, you must run the remote wall daemon. (rwalld)" fi again=y while [ $again ] do again="" echo "" echo -n " Would you like to run the rwalld daemon [n] ? " read rwall case $rwall in [yY]*) rwall=y ;; [nN]*|"") rwall=n ;; *) again=y ;; esac done # # He's exporting directories. Find out which ones and validate them # but don't add them to "/etc/exports" just yet! # if [ $serving ] then if [ $first_time ] || [ \! -f $EXFILE ] then echo "You are now setting up your directory export list. Enter thefull pathnames of the directories to be exported. For eachpathname, enter the network group names and/or machine names tobe given access permission to this directory, or a null list toindicate general permission. (Network groups are ONLY availableon machines using Yellow Pages). This information is placed in the/etc/exports file. Press the RETURN key to terminate the pathnameand permissions lists."
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?