nfssetup.sh

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· Shell 代码 · 共 992 行 · 第 1/2 页

SH
992
字号
			more_paths=y		else			echo "	Would you like to add any directory pathnames to the ${EXFILE} file?"			again=y			while [ $again ]			do				again=""				echo -n "	Enter \"y\" or \"n\" [n]: "				read ans				case $ans in					[yY]*)					more_paths=y					;;					[nN]*|"")					more_paths=""					;;					*)					again=y					;;				esac			done		fi		while [ $more_paths ]		do			more_paths=""			permlist=""			echo ""			echo -n "Enter the directory pathname: "			read dirname			if [ $dirname ]			then				more_paths=y				if [ -d $dirname ]				then					more_perms=y					while [ $more_perms ]					do						more_perms=""						echo -n "	Netgroup/Machine name: "						read permname						if [ -n "$permname" ]						then							more_perms=y							permlist=`echo $permlist $permname | cat`						fi					done					echo "$dirname		$permlist" >> $EXTMP				else 					echo "The pathname: ${dirname}is not a valid directory."				fi			else			echo "Directory export list complete..."			fi		done	fi	#	# Find out which file systems from which machines are to be imported.	#	if [ $first_time ]	then		more_hosts=y		echo "You will now be asked to provide information about the remote filesystems you wish to access.  First list the name of the remote hostserving the directories you wish to mount, then give the full directorypathnames.  Also, for each remote directory, you must specify the fulldirectory pathname of the mount point on the local machine and whetherthe mount is read-only or read-write.  (Nfssetup will create the mountpoint directory if it does not already exist.)  Press the RETURN key toterminate the host and directory pathname lists:"	else		echo "	Would you like to add any remote file systems to be mounted?"		again=y		while [ $again ]		do			again=""			echo -n "	Enter \"y\" or \"n\" [n]: "			read ans			case $ans in				[yY]*)				more_hosts=y				;;				[nN]*|"")				more_hosts=""				;;				*)				again=y				;;			esac		done	fi	newdirs=""	while [ $more_hosts ]	do		more_hosts=""		echo ""		echo -n "Enter the remote host name: "		read hostid		if [ $hostid ]		then			more_hosts=y			more_paths=y			while [ $more_paths ]			do				more_paths=""				echo -n "	Enter the remote directory pathname: "				read rdir				if [ -n "$rdir" ]				then					more_paths=y					again=y					while [ $again ]					do						again=""						echo -n "	Enter the local mount point: "						read ldir						if [ -z "$ldir" ]						then							again=y						elif [ -f $ldir ]						then							echo "	${ldir}: File exists! Please choose a new mount point."							again=y						elif [ \! -d $ldir ]						then							echo "	${ldir}: Directory does not exist, but will be created."							newdirs=`echo $newdirs $ldir | cat`						fi					done					again=y					while [ $again ]					do						again=""						echo -n "	Is this a read-only mount [y] ? "						read readonly						case $readonly in						[nN]*)							echo "${rdir}@${hostid}:${ldir}:rw:0:0:nfs:bg:" >> $FSTMP							;;						[yY]*|"")							echo "${rdir}@${hostid}:${ldir}:ro:0:0:nfs:bg:" >> $FSTMP							;;						*)							again=y							;;						esac					done				fi			done		else			echo "Remote directory mount list complete..."		fi	done	#	# Ask user for verification...	#	echo "Please confirm the following information which youhave entered for your NFS environment:"	if [ $serving ]	then		echo "	${nnfsd} nfsd daemons"		echo "	${nbiod} biod daemons"		if [ $rlock = y ]		then			echo "	locking daemons installed"		fi		if [ $rwall = y ]		then			echo "	rwalld daemon installed"		fi		if [ -s $EXTMP ]		then			echo "	Directory export list:"			awk '			{				printf "\t\t%s", $1				if ( NF > 1 ) {					printf " exported to:"					for ( i = 2; i <= NF; i++ )						printf " %s", $i					printf "\n"				}				else					printf " exported with general permissions\n"			}' $EXTMP		else			echo "	No directories exported"		fi	else		echo "	${nbiod} biod daemons"		if [ $rlock = y ]		then			echo "	locking daemons installed"		fi		if [ $rwall = y ]		then			echo "	rwalld daemon installed"		fi		echo "	No directories exported"	fi	if [ -s $FSTMP ]	then		echo "	Remote directory mount list:"		awk '		BEGIN { FS = ":" }		{			if ( $3 == "ro" )				printf "\t\t%s mounted on: %s (Read Only)\n", $1, $2			else				printf "\t\t%s mounted on: %s\n", $1, $2		}' $FSTMP	else		echo "	No remote directories to mount"	fi	again=y	while [ $again ]	do		echo -n "Enter \"c\" to CONFIRM the information, \"q\" to QUIT nfssetupwithout making any changes, or \"r\" to RESTART the procedure [no default]: "		read conf		case $conf in			[qQ]*)			[ -r $EXTMP ] && rm $EXTMP			[ -r $FSTMP ] && rm $FSTMP			eval "$QUIT"			;;			[rR]*)			[ -r $EXTMP ] && rm $EXTMP			[ -r $FSTMP ] && rm $FSTMP			exec $NFSSETUP $*			;;			[cC]*)			again=""			;;			*)			again=y			;;		esac	donefi## PHASE TWO...  Update files!!#trap "" 1 2 3 15if [ $verbose ]then	echo ""	echo "Updating files:"	echo "	/etc/rc.local"fi## See if the port mapper is already there.#egrep -s '[ 	]*/etc/portmap' $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## Put in banner...#echo $NFSSTART_KEY >> $RCTMPecho "echo -n 'NFS daemons:'						>/dev/console" >> $RCTMP## Put in mountd IF we're serving...#if [ $serving ]thenecho "[ -f /etc/mountd -a -f /etc/portmap -a -s ${EXFILE} ] && {	/etc/mountd -i ; echo -n ' mountd -i'				>/dev/console}" >> $RCTMP	startup=`echo $startup "/etc/mountd -i; " | cat`fi## Install optional daemons...#if [ $nnfsd -gt 0 ] && [ $nbiod -gt 0 ]then	echo "[ -f /etc/nfsd -a -f /etc/portmap ] && {	/etc/nfsd ${nnfsd} ; echo -n ' nfsd'				>/dev/console}[ -f /etc/biod ] && {	/etc/biod ${nbiod} ; echo ' biod'				>/dev/console}" >> $RCTMP	startup=`echo $startup "/etc/nfsd ${nnfsd} ; /etc/biod ${nbiod} ; " | cat`elif [ $nnfsd -gt 0 ]then	echo "[ -f /etc/nfsd -a -f /etc/portmap ] && {	/etc/nfsd ${nnfsd} ; echo ' nfsd'				>/dev/console}" >> $RCTMP	startup=`echo $startup "/etc/nfsd ${nnfsd} ; " | cat`elif [ $nbiod -gt 0 ]then	echo "[ -f /etc/biod ] && {	/etc/biod ${nbiod} ; echo ' biod'				>/dev/console}" >> $RCTMP	startup=`echo $startup "/etc/biod ${nbiod} ; " | cat`fiif [ $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 >> $RCTMPfiif [ $rwall = y ]then	echo "[ -f /usr/etc/rwalld -a -f /etc/portmap ] && {	/usr/etc/rwalld ; echo 'rwall daemon: rwalld'		>/dev/console}" >> $RCTMP	startup=`echo $startup "/usr/etc/rwalld ; " | cat`fiecho "if [ \! \"\$DISKLESS\" ]then	echo -n 'mounting NFS directories:'			>/dev/console	/etc/nfs_umount -b					>/dev/null 2>&1	/etc/mount -a -t nfs				      >/dev/console 2>&1	echo ' done.'						>/dev/consolefi" >> $RCTMPecho $NFSEND_KEY >> $RCTMPif [ $first_time ]then	egrep -s "$LOCAL_KEY" $RCFILE	if [ $? -eq 0 ]	then		ed - $RCFILE << END >> /dev/null/$LOCAL_KEY-.r $RCTMPwqEND	else		cat $RCTMP >> $RCFILE	fielse	ed - $RCFILE << END >> /dev/null/$NFSSTART_KEY/,/$NFSEND_KEY/ d-.r $RCTMPwqENDfirm $RCTMPif [ $verbose ]then	#	# Update export list	#	if [ -r $EXTMP ]	then		echo "	/etc/exports"		cat $EXTMP >> $EXFILE		rm $EXTMP	fi	#	# Update fstab	#	if [ -r $FSTMP ]	then		echo "	/etc/fstab"		cat $FSTMP >> $FSFILE		rm $FSTMP	fi	#	# Make new local mount point directories...	#	if [ -n "$newdirs" ]	then		echo ""		echo "Creating local mount points:"	fi	for dirname in $newdirs	do		object=""		for subdirs in `echo $dirname | awk '		BEGIN { FS = "/" }		{			if (substr($0,1,1) != "/")				print $1			for (i = 2; i <= NF; ++i) print "/"$i		}'` 		do			object=$object$subdirs			if [ -f $object ]			then				echo "	Can't create ${object}. File exists!" 				break			fi			if [ \! -d $object ]			then				mkdir $object 2> /dev/null				if [ $? -ne 0 ]				then					echo "	Can't create ${object}. Mkdir failed!"					break				fi			fi		done		echo "	"$dirname	done	if [ $first_time ]	then		if [ -n "$startup" ]		then			echo "The necessary NFS daemon entries have been placed in the file ${RCFILE}.In order to begin using NFS, you must now start the daemons and mountany remote directories you wish to access.  You may either allow nfssetupto 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 nfssetup to start the daemons automatically [y]? "				answer=""				read ans				case $ans in				[yY]*|"")					eval "$startup"					echo "The NFS daemons for your machine have been started. In order to mount theremote directories you wish to access, type the following command afterexiting from nfssetup:	# /etc/mount -a -t nfs"					;;				[nN]*)					;;				*)					answer=y					;;				esac			done		fi	else		echo "The necessary NFS daemon entries have been placed in the file ${RCFILE}.You may start any additional NFS daemons added by hand, or allow the newNFS configuration to take effect on the next reboot."	fi	echo ""	echo "***** NFSSETUP COMPLETE *****"fiexit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?