⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setld

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻
📖 第 1 页 / 共 5 页
字号:
			$J)	;;			*)	echo "Invalid choice: $I (malformed number)"				continue			esac			# is it in range?			[ $I -gt $EXIT ] &&			{				echo "Invalid Choice: $I (out of range)"				continue			}			HI=$SORTED LO=			# insert # into sorted list...			for J in $SORTED			{				case "$I" in				$J)	I=					break					;;				esac				if [ $I -gt $J ]				then					LO="$LO $J"					set xx $HI					shift;shift					HI=$*				else					break				fi			}			SORTED="$LO $I $HI"		}		case $SORTED in		"")	continue			;;		$ALL)	SBS="$MAND $OPT"			;;		$NONE)	SBS="$MAND"			;;		$EXIT)				while :		# do they really want to quit			do				echo "You have chosen to exit without ${OPERATION}ing subsetsIs this correct (y/n) [y]: \c"				read X				case "$X" in				""|[yY]*)					[ "$MAND" ] && return 1					return 2					;;				[nN]*)	continue 2				esac			done			;;		*)	SBS="$MAND"			for X in $SORTED			{				eval _S='$ORD'$X				SBS="$SBS $_S"			}		esac		case "$SORTED" in		$ALL|*)			# if they have selected all or some, size them.			#  no sizing is required if none of the optionals			#  were selected becuase they were sized before			#  selection even began.			TickWhile PreSize $OPERATION $SBS ||			{				echo "There is not enough file system space to install all of the softwaresubsets that you have selected. Make another selection"				continue			}			;;		esac		case "$SBS" in		"")	echo "You have chosen not to install any of the subsets offered.Is this correct? (y/n): \c"			read X			case "$X" in			[Yy]*)	return 2			esac			continue		esac		echo "You are ${OPERATION}ing the following subsets:"		PrintTable ' ' $SBS		echo "Is this correct? (y/n): \c"		read X		case "$X" in		[Yy]*)	break		esac	done	return 0}:	-SplitByType#		split subset list into optional and mandatory##	given:#	does:#	return:SplitByType(){	MAND=""	# list of mandatory subsets	OPT=""	# list of optional subsets	# scan control files, differentiate OPT & MAND subsets	INSTALLED=		# smu-2290	for _S in $SBS	{		case "$CMDSW" in		l)			# make sure subset is not installed.			[ -f $UAS/$_S.lk ] && 			{				INSTALLED=1				continue			}			;;		x)	# Make sure subset is not already on server			[ -f $_S ] &&			{				INSTALLED=1				continue			}		esac		ReadCtrlFile $_TDIR $_S		# if STL_NOACTM is not set, run scp with M action.		#  Will fail if subset does not want to appear on the menu.		[ "$STL_NOACTM" ] ||		{			ACT=M $_TDIR/$_S.scp -$CMDSW || continue		}		# bit 2 on flags means subset is optional		case `FlagsAttrCheck SATTR_OPTION $FLAGS` in		1)	OPT="$OPT $_S"			;;		*)	MAND="$MAND $_S"		esac	}	case "$MAND$OPT$INSTALLED" in	"")	Error "No installable subsets on your kit"		return 1		;;	1)	Error "All subsets on the kit are already installed"		return 1	esac}:	-Subtract#		subract one integer value from another##	given:	$1 - initial value#		$2 - subtrahend#	does:	echo value of $1 - $2 to stdout#	return:	ignoreSubtract(){ (	X=$1	Y=$2	OP=-	# operation to perform	CSR=0	# change sign of result flag	#% Local Code	# now for some ugly arithmetic using expr	#  expr does not understand negative numbers.	#  to compensate, the following formulae are used:	#	#	x - y	=>	x - y	#	-x - y	=>	-( x + y )	#	x - -y	=>	x + y	#	-x - -y	=>	-( x - y )	# determine operators and signs of results, note that	#  *,* case is default defined above	case "$X,$Y" in	-*,-*)	CSR=1		;;	-*,*)	OP=+		CSR=1		;;	*,-*)	OP=+	esac		# remove signs from both operands	X=`Parse - $X`	Y=`Parse - $Y`	# perform the operation	Z=`expr $X $OP $Y`	# check sign on result	case "$CSR,$Z" in	1,0)	;;	# prevent -0	1,-*)	Z=`Parse - $Z`		;;	1,*)	Z=-$Z	esac	echo $Z) }:	-Synch#		Synchronize back versions of a subset inventory, generate#	debris debris inventory.##	given:	the name of the subset to synchronize#	does:	generate synchronization inventory: _TDIR/$1.syn#		generate debris inventory: _TDIR/$1.frm#	return:	nothingSynch(){	MS=$1		# store the subset name	#% Local Variables	#	MS_P=		# product field	MS_N=		# subset field	MS_V=		# version field	SYNCLIST=	# list of installed versions	X= Y=		# temporary variables	#% Local Code	#	# break out subset name fields	NameParse MS_ $MS	# determine which subsets are currently installed	SYNCLIST=`ListKnown $MS_P$MS_N`	SYNCLIST=`AreInstalled $SYNCLIST`	# set up list of subsets to be synchronized	set xx $SYNCLIST	shift	[ $# = 0 ] &&	{		# No subsets. Error		Error "$PROG: $MS: attempt to update non-resident subset"		return	}	(		cd $_TDIR		# sort the initial inventory ascending by pathname		sort -o $1.#syn -8 +9 $_R/$UAS/$1.inv		# Iteratively synchronize inventories 2 at a time.		#  the oldest two are synchronized into one which		#  is in turn used as the oldest in the next iteration		#		Y=$1	# set $Y to $1 in case it is the only subset					while [ $# -gt 1 ]		do			# pop the first two from the list.			X=$1 Y=$2			shift 2			# rename output of last iteration			mv $X.#syn $X.syn 2> /dev/null			# get original copies the inventories			#  if we haven't already and sort them			[ -f $X.syn ] ||			{				sort -o $X.syn -8 +9 $_R/$UAS/$X.inv &				SORTPID=$!			}			[ -f $Y.syn ] ||				sort -o $Y.syn -8 +9 $_R/$UAS/$Y.inv			Wait SORTPID			# synchronize the inventory pair			usync $X.syn $Y.syn > $Y.#syn			# remove the left version			# rm -f $X.syn			# push the right version back into the list			set $Y $*		done		# sort the media inventory		sort -o $MS.inv -8 +9 $MS.inv		# propogate flags info into synchronized inventory		umerge $Y.#syn $MS.inv > $MS.syn ||		{			Error "Synch(): cannot merge inventories"			return 1		}		# generate debris inventory with final version		udelta $Y.#syn $MS.inv > $MS.frm ||		{			Error "Synch(): cannot generate frm datafile"			return 1		}		# remove tell-tale copy		rm $Y.#syn	)}:	-TickWhile#		Provide ticking while a named process is running##	given:	$* a command line to run#	does:	establish a Ticker(), run the named process, turn the#		Ticker() off.#	return:	the exit status of the named processTickWhile(){	PROC=$*	Ticker on	eval $PROC	PROCRET=$?	Ticker off	return $PROCRET}:	-Ticker#		present time stamps on stdout##	given:	$1 - "on" or "off"#	does:	turn output time stamping on or off#	return:	nothing#	effect:	$TICKPID updatedTicker(){	case "$1" in	on)	# make sure there isn't one already		[ "$TICKPID" ] && return		(				# ticking is a background subshell that			#  traps on sighup			trap 'exit 0' 1			echo > $PIPE			sleep 15	# wait a bit before starting			while :			do				echo "	Working....`date`"				# ticker wakes up faster taking				#  short naps...				for X in 0 1 2 3 4 5 6 7 8 9				{					sleep 6					sleep 6				}			done		) &		TICKPID=$!		(read X) < $PIPE		;;	off)	# make sure there's one running		[ "$TICKPID" ] &&		{			# kill it			kill -1 $TICKPID			Wait TICKPID		}	esac}:	-Ucase#		echo arguments upcased##	given:	$* - some text#	does:	upcases the text and writes it to stdout#	return:	ignoreUcase() {	echo $* | dd conv=ucase 2> /dev/null;	}:	-Update#		update installed subsets present on specified media##	given:	global $SBS - list of subset available from media#	does:	determine which SBS subsets have versions currently#		installed. Update these subsets.#	return:	1 on failure, 0 otherwise.Update(){	UpdateSearch $SBS	# generate .syn, .res, and .frm inventories for all subsets	#  to be updated.	#  archive all changes before installing any software	for _S in $SBS	{		ReadCtrlFile $_TDIR $_S		echo "Preparing system to update $DESC ($_S)"		Ticker on		Synch $_S 		# synchronize inventory for this subset		DetectChanges $_S	# generate change information		ArchiveChanges $_S ||	# archive changes		{			Error "preserve: update failed."			return 1		}		Ticker off	}	OPTERRS=0	SCPLIST=	# load the software from the media.	for _S in $SBS	{		LoadFromMedia $_S		case "$?" in		0)	SCPLIST="SCPLIST $_S"			# Clear out previous entries for this subset from			#  the subsets database			DbPurge $_S			;;		1)	return 1			;;		*)	OPTERRS=`expr $OPTERRS + 2`			continue		esac		ArchiveReferenceCopies $_S		RecoverChanges $_S		RemoveDebris $_S	}	RunScps POST_U $USBS	return 0}:	-UpdateSearch#		Determine which subsets are to be applied as updates##	given:	$* - a list of subsets known to be available from the#		distribution.#		uses data available in usr/etc/subsets and _TDIR.#	does:	copies those subset names in the arglist which match#		subsets currently installed on the system to stdout.#	return:	nothing useful#	effect:	sets $SBS to the names of the media subsets which have#		currently installed versions#UpdateSearch(){	MSS=$*		# list of subsets available on the media	MS=	# working subset name	MS_N=	# working name	MS_P=	# working product code	MS_V=	# working version code	RS=	# working _R_esident _S_ubset	RSS=	# list of resident subsets		#% Local Code	SBS=	for MS in $MSS	{		# check to see if update flag is set		ReadCtrlFile $_TDIR $MS		[ `FlagsAttrCheck SATTR_UPDATE $FLAGS` = 1 ] || continue		# set MS_{P,N,V}		NameParse MS_ $MS		# Get a list of all other versions of the current subset		#  that are installed to the system.		RSS=`Resident $MS_P$MS_N` ||		{			# none resident			continue		}		# Make sure all of them are lower of equal versions		#		for RS in $RSS		{			NameParse RS_ $RS			[ $RS_V -gt $MS_V ] &&			{				Error "Cannot Update $MS_P$MS_N from version $RS_V to $MS_V"				continue 2			}		}		SBS="$SBS $MS"	}}:	-Usage#		print usage messages##	given:	$1 - switch for which message to print#	does:	prints a particular usage message#	return:	nothingUsage(){	case "$1" in	"")	Error -n "$USAGE"		;;	-c)	Error -n "Usage:$CUSAGE"		;;	-d)	Error -n "Usage: $DUSAGE"		;;	-h)	echo "$USAGE"		;;	esac	return 0}:	-Verify#		verify the integrity of the installation subsystem##	given:	$* - list of subsets to be verified #	does:   For each subset specified:#		1) check if subset is installed.#		2) read control file to get subset description#		3) test ivp#	return: nothingVerify(){	cd $_R	for _S in $*	{		[ -f $UAS/$_S.lk ] ||		{			Error "$_S: $E_NOINST"			continue		}                # read .ctrl to get subset description ($DESC),                # ReadCtrlFile() will provide proper error msg when needed.                ReadCtrlFile $UAS $_S                Log "$_S, IVP \c"                echo "$DESC ($_S)"		ACT=V $UAS/$_S.scp ||		{			Error "ivp failed."			continue		}	  	Log " SUCCEEDED"	}	return 0}:	-Wait#		intelligent wait routine##	given:	$1 - the name of the variable contianing the pid of the#			process to wait for (yes, this uses call-by-reference)#		[$2 - $n] - optional string to eval if wait fails#	does:	wait on the specified PID if contents of $1 is not null#		if wait returns !0 status, eval remainder of command line#		clear contents of variable specified in $1#	return:	exit status of the waitWait(){	VAR=$1	shift	# was there a first arg?	[ ! "$VAR" ] && return 0	eval VAL=\$$VAR	# was the value of the named variable set?	[ ! "$VAL" ] && return 0	# clear the value from the named variable	eval $VAR=	wait $VAL ||	{		STAT=$?		eval $*		return $STAT	}}:	-WriteLog#		xfer stdin to logfile##	given:	no args, reads stdin#	does:	xfer stdin to logfile $LOGFILE#	return:	ignoreWriteLog(){ (	2>&1 cat > $LOGFILE) }#% CODE#	actual code bgins here. This is structured this way to#	enable interactive debugging of the independent subroutines#	by setting STL_SUBR_DEBUG to something and running '. setld'CDPATH= ;export CDPATH		# assure no surprises.InitializeConstantsInitializeGlobals# run the main routine only if subr debug is disabled#[ -z "$STL_SUBR_DEBUG" ] && {	PATH=/install.tmp:/etc/stl:/etc:/bin:/usr/bin:/usr/adm/bin:/usr/ucb:.	export PATH	Main $ARGV}echo "$PROG: syntax test passed"

⌨️ 快捷键说明

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