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

📄 setld

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻
📖 第 1 页 / 共 5 页
字号:
#!/bin/sh5#	setld.sh#		manage software subset distributions##	setld [-D path] -c subset message		(configure)#	setld [-D path] -d subset [subset...]		(delete)#	setld [-D path] -h				(help)#	setld [-D path] -i [subset...]			(inspect)#	setld [-D path] -l location			(load)#	setld [-D path] -v [subset...]			(validate)#	setld [-D path] -x location			(extract)##			Copyright (c) 1988, 1989 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.##	SCCSID = "@(#)setld	4.9	(ULTRIX)	4/4/91"##	000	ccb	12-mar-1987#		Digital Equipment Corporation#	Many thanks to robin, rnf, and afd#	new version for 2.2##	001	ccb	02-mar-1988#		Set UMASK to 22 so that ris can read the images.##	002	06-APR-1988	ccb#		Fix DEVICE parsing bug.##	003	18-feb-1989	ccb#		Port to sh5#		add update (-u) support##	004	07-mar-1989	ccb#		Add support for new style ris servers.##	005	12-jun-1989	ccb#		Fix extraneous scp on failed subset problem,#		clean up entry to -l when subsets specified on command line,#		clean up exit returns, fix 'D is read-only' problem in trap#		for keyboard interrupts.##	006	17-jul-1990	ccb#		Fix problem finding unique client names in risdb.##	007	05-nov-1990	ech#		Fix path used by setld to exclude current directory,#		add subset description in the dependency-check error message,#		change format of messages givien when subset is loaded,#		change return value such that setld will exit if underlying#		scp preforms an exit 1.#	   #	008	16-nov-1990	ech#		Fix problem in setld -i when .ctrl is empty by resetting #		all control variables in ReadCtrlFile(), also mark subset as #		incomplete if .ctrl is incomplete.#		Fix leftover /hosts problem.##	009	17-dec-1990	ech#		call fverify -yp in Verify(), fix path of .inv fed to tclear #		in LoadFromMedia().##	010	29-jan-1991	ech#		add current directory back to the end of setld PATH.#		restore /etc/hosts every time LoadFromInet is called.##	011	19-feb-1991	ech#		clean up usage (no -a, -u, -v w/o specifying subsets).#		move "Deleting (subset)" to before C_DELETE is called.#		bug fix in RunScps (no C_INSTALL if POST_L fails).##	012	12-mar-1991	ech#		add reg expr when 'egrep' ROOT in .image file in Extract().#		check if RIS server echoes 'hello' in InitDevice().##	013	03-apr-1991	ech#		take out fverify -yp in Verify().ARGV=$*		# just in case#%	DECLARATIONS#%	SUBROUTINES#		all subroutines used in setld are defined in alphabetical#		order here.:	-Add#		add two numbers##	given:	$1 - a number#		$2 - a number#	does:	echos the sum of the numbers#	return:	ignoreAdd(){ (	X=$1 Y=$2	OP=+	# operator	CSR=0	# sign change required	# expr does not recognize negative numbers. The following formulae	#  are used:	#	#   x +  y == x + y	#  -x +  y == -(x - y)	#   x + -y == x - y	#  -x + -y == -(x + y)	case "$X,$Y" in	-*,-*)	CSR=1		;;	-*,*)	CSR=1		OP=-		;;	*,-*)	OP=-	esac	# take absolute values	X=`Parse - $X`	Y=`Parse - $Y`	# apply operation	Z=`expr $X $OP $Y`	# adjust direction	case "$CSR,$Z" in	1,0)	;;	# zero, ignore $CSR	1,-*)	# change sign		Z=`Parse - $Z`		;;	1,*)	Z=-$Z	esac	# print	echo $Z) }:	-ArchiveChanges#		protect user customizations from the update.##	given:	$1 - name of the subset for which to perform archiving#	does:	uses the restoration inventory ($_TDIR/$1.res) to drive#		the archiving of the files listed therein.#	return:	1 if perservation failed, 0 otherwise#	side:	operates in sub-contextArchiveChanges(){ (	SUB=$1		# subset to archive	mkdir var/adm/install/archive 2> /dev/null	awk '{print $10}' $_TDIR/$SUB.res > $TMP1	BigTar $TMP1 var/adm/install/archive) }:	-ArchiveReferenceCopies#		preserve newly installed copies of volitile product files##	given:	a subset code#	does:	preserve reference copies of all newly installed files which#		were modified in the previous release#	return:	nothingArchiveReferenceCopies(){	SUB=$1	mkdir var/adm/install/reference 2> /dev/null	awk '{print $10}' $_TDIR/$SUB.res > $TMP1	BigTar $TMP1 var/adm/install/reference}:	-AreInstalled#		subset installed status predicate##	given:	$* - list of subsets#	does:	copies each subset code on the arglist representing a#		subset which is installed to stdout#	return:	nothingAreInstalled(){ (	ILIST=$*	for ISUB in $ILIST	{		[ -f $UAS/$ISUB.lk ] && echo $ISUB	}) }:	-Args#		break up the command args##	given:	the command line#	does:	break the command line up#	return:	nothing#	effect:	$ACT - sets to act value#		$DEFPATH - set to 0 if root specified, else 1#		$DEVICE - set to device name for -alux#		$_R - set to / or new rootpath if specified#		$ARGV - set to remaining argumentsArgs(){	IGNORE=0	# ignore current option	OPT=		# current option value	# parsing the command line:	[ $# = 0 ] &&	{		# no arguments		Usage		return 1	}	case "$1" in	-*)	;;	*)	# assume old-style optional path prepend -D option switch		set -- -D $*	esac	set -- `getopt "a:cD:dhil:x:u:v" $*` ||	{		Usage		return 1	}	ACT=	_R=/	DEFPATH=1	for OPT in $*	{		[ "$IGNORE" = 1 ] &&		{			# skip already used option			IGNORE=0			continue		}		#! checks may be desired to guarantee that only one		#!  action option has been specified		case "$OPT" in		-[alux])			CMDSW=$OPT			DEVICE=$2			IGNORE=1	# ignore OPT value on next iteration			shift 2			;;		-[cdhiv])			CMDSW=$OPT			shift			;;		-D)	DEFPATH=0			_R=$2			IGNORE=1	# ignore OPT value on next iteration			shift 2			# verify that the target directory exists			[ -d $_R ] ||			{				Error "$_R: $ENOENT"				return 1			}			case "$_R" in			/*)	;;			*)	_R=`(cd $_R;Pwd)`			esac			;;		--)	# end of options			shift			break			;;		*)	# bad switches			Error "Unreached in Args()"			return 1		esac	}	CMDSW=`Parse - $CMDSW`	(Log "root=$_R -$CMDSW")	# subshell to protect command args	[ "$CMDSW" = "a" ] && CMDSW=l	ACT=`Ucase $CMDSW`	case "$WHOAMI,$CMDSW" in	*,)	# no action switch specified		Usage		return 1		;;	root,[cdluvx])		;;	*,[cdluvx])		Error "-$CMDSW can be used by super-user only."		return 1	esac	ARGV=$*	return 0}:	-BigTar#		move a potentially large number of files using tar##	given:	$1 - the name of a file containing a list of files to be moved#		$2 - a root directory where the files are to be moved #	does:	arranges for tar(1) to copy the files, splitting the list of#		things to be copied into smaller pieces if necessary.#	return:	!0 on failureBigTar(){	LIST=$1		# file name of list of files to copy	DEST=$2		# destination path	BTPATH=		# name of current file	[ -f "$LIST" ] ||	{		# List file does not exist		Error "cannot open $LIST ($ENOENT)"		return 1	}	[ -d "$DEST" ] ||	{		# no destination directory		Error "cannot copy to $DEST ($ENOENT)"		return 1	}	[ -s "$LIST" ] || return 0		# no files to move	# split the input file into as many 9 line files as needed	mkdir $_TDIR/split$$	split -9 $LIST $_TDIR/split$$/	for BTPATH in $_TDIR/split$$/*	{		tar cf - `cat $BTPATH` | (cd $DEST; tar xpf -)	}	rm -rf $_TDIR/split$$	return 0}:	-ChOp#		Change Operator##	given:	$1 - {-,+}#	does:	effective "tr '+-' '-+'"#	return:	ignoreChOp(){	case "$1" in	+)	echo -		;;	-)	echo +	esac}:	-Cleanup#		cleanup before exiting##	given:	uses global context#	does:	exit processing, called from ExitCleanup(){	trap '' 0	cd $_R	case "$_MEDIA" in	tape)	echo "Rewinding Tape..."		TickWhile Wait MTPID		TickWhile mt -f $RAW rew		;;	inet)		# restore the hosts file in the event it was overwritten during		# the install of a previous subset		[ -f $HOSTS ] && mv $HOSTS etc/hosts		;;	esac	DATE=`date +19%y.%m.%d.%T`	Ticker off	wait	Log "SETLD $$ $DATE $_R -$CMDSW $STAT $EMESG"	rm -rf $TMPS}:	-Configure#		configure a subset##	given:	$1 - the argument to be used in invoking the scp#		$2 - the name of the subset to configure#	does:	invoke the scp for the named subset with ACT=C and the#		specified argument on the command line#	return:	0 is successful, 1 on errorConfigure(){	[ $# != 2 ] &&	{		Usage -c		return 1	}	set `Ucase $*`	#! coerce subset name and option to upper case	LOC_S=$1	# subset name to configure	CONFARG=$2	# command arg for scp	#% Local Code	cd $_R	Log "$LOC_S ($CONFARG) \c"	# Make sure the subset is installed	[ -f $UAS/$LOC_S.lk ] ||	{		Error "$LOC_S $E_NOINST, cannot configure."		return 1	}	# verify that the scp exists	[ -f $UAS/$LOC_S.scp ] ||	{		Error "$LOC_S: missing control program, cannot configure."		return 1	}	# all clear	echo "Configuring $LOC_S"	if ACT=C $UAS/$LOC_S.scp $CONFARG; then	{		Log "SUCCEEDED"		return 0	}	else	{		Log "FAILED: scp status $?"		return 1	}; fi}:	-DbPurge#		Purge subsets database of all prior information about a#	subset.##	given:	$1 - a subset name#	does:	removes all .ctrl .inv and .scp files belonging to#		prior versions of a subset#	return:	nilDbPurge(){ (	DBP_P= DBP_N= DBP_V=		# parse variables	RMLIST=				# list of files to be removed	TYPE=				# loop index	[ $# != 1 ] &&	{		Error "DbPurge($*): expected 1 arg, $# recieved"		return 1	}	NameParse DBP_ $1	cd $UAS	# how:	#  the previous elements are purged type-by-type. A list of existing	#  versions of a file is generated by forcing the shell to glob on	#  the version field of the subset name. This sorts in asc. order	#  by version number. All files except the last in this sorted order	#  are to be removed.	for TYPE in .ctrl .scp .inv .dw .lk	{		set -- `echo $DBP_P$DBP_N???$TYPE`		while [ $# -gt 1 ]		do			RMLIST="$RMLIST $1"			shift		done	}	rm -f $RMLIST) }:	-Delete#		Delete subsets##	given:	$* - a list of subsets to delete#	does:	delete the subsets#	return:	0 on success#		1 on failureDelete(){ (	case "$#" in	0)	#! menuhook		Usage -d		Log "Delete(): argument error"		return 1	esac	set -- `Ucase $*`	CTX=		# context prefix	_S=		# current subset	cd $_R		# assure operation in user specified hierarchy	for _S in $*	{		CTX=$UAS/$_S		Log "$_S"		# is it installed? (correctly or damaged)		[ -f $CTX.lk -o -f $CTX.dw ] ||		{			Error "$_S: $E_NOINST, cannot delete"			continue		}		# read in the control file.		ReadCtrlFile $UAS $_S ||		{			Error "Error reading $_S control file, cannot delete."			continue		}		[ `FlagsAttrCheck SATTR_STICKY $FLAGS` = 1 ] &&		{			# sticky flag is set for this subset			Error "Sorry, You may not delete the $DESC ($_S) subset"			continue		}		[ -s $CTX.lk ] &&		{			# subset is installed and has a non-zero length lock			#  file. This means that there are subsets that depend			#  on the one that we are trying to remove. This			#  requires that we notify the user and verify that			#  the ramification of a request to delete are			#  understood			echo "The following subsets need the subset you are trying to deleteto operate correctly:"			cat $CTX.lk | sed 's/^/	/'			while :			do				echo "Are you sure you wish to delete the $DESC ($_S) subset? (y/n): \c"				read X				case "$X" in				[Yy]*)	Log " WARNING: locked"					break					;;				[Nn]*)	Log " FAILED: locked"					continue 2				esac			done		}		[ -f $CTX.lk ] &&		{			# subset is actually installed, run the pre-delete			#  in the scp			ACT=PRE_D $CTX.scp ||			{				Error "$_S: deletion declined by subset control program"				continue			}			echo "Deleting $DESC ($_S)."			# run the configure delete			ACT=C $CTX.scp DELETE		}		# remove the subset.		# run the inventory into 'frm'		frm < $CTX.inv		[ -f $CTX.lk ] &&		{			# subset was installed, clean up			ACT=POST_D $CTX.scp			# clean out dependency info			[ "$DEPS" != . ] &&			{				# remove dependency lock file info				for K in $DEPS				{					[ -f $UAS/$K.lk ] &&					{						egrep -v $_S $UAS/$K.lk > $TMP1						mv $TMP1 $UAS/$K.lk					}				}			}		}		# mark subset as uninstalled		rm -f $CTX.lk $CTX.dw	}	return 0) }:	-DependencyOrder#		order a bucketload of subsets##	given:	$* - a list of subsets#	does:	orders the subset in tape order, writing the ordered list#		to stdout. It is assumed that the control files for the#		subsets are in the current directory.#	return:	nothingDependencyOrder(){	case "$#" in	0)	Error "DependencyOrder(): no subsets specified"		return 1	esac	Bu_SUBS=$*	#% Local Variables	Bu_ORD=			# ordered subsets	Bu_LEFT= Bu_RIGHT=	# sort temp variables	#% Local Code	# get the PNV for the lead subset in the bucket	for Bu_SUB in $Bu_SUBS	{		NameParse Bu_ $Bu_SUB && break		Bu_SUBS=`(set $Bu_SUBS;shift;echo $*)`	}	for Bu_S in $Bu_SUBS	{		# get tape location		ReadCtrlFile $_TDIR $Bu_S || continue		set -- `Parse : $MTLOC`		Bu_VOL=$1		Bu_SORD=$2		echo "$Bu_VOL $Bu_SORD $Bu_S"

⌨️ 快捷键说明

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