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

📄 extract_unbundled

📁 操作系统SunOS 4.1.3版本的源码
💻
字号:
#!/bin/sh#set -x## @(#)extract_unbundled.sh	2.4  7/20/90#       Copyright (c) 1988, Sun Microsystems, Inc.  All Rights Reserved.#       Sun considers its source code as an unpublished, proprietary#       trade secret, and it is available only under strict license#       provisions.  This copyright notice is placed here only to protect#       Sun in the event the source is deemed a published work.  Dissassembly,#       decompilation, or other means of reducing the object code to human#       readable form is prohibited by the license agreement under which#       this code is provided to the user or company in possession of this#       copy.##       RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the#       Government is subject to restrictions as set forth in subparagraph#       (c)(1)(ii) of the Rights in Technical Data and Computer Software#       clause at DFARS 52.227-7013 and in similar clauses in the FAR and#       NASA FAR Supplement.## NAME: extract_unbundled ## DESCRIPTION:# 	Front end to unbundled installations.  This will skip the copyright on#	an unbundled release tape and execute the installation script which#	follows.#	Update: 10/10/88  added extentions for floppy media.  --SMAR#	        Expects install scripts and copyright.d in a subdir#               called "+install".## USAGE:#	extract_unbundled [-dDEVICE] | [-rREMOTE_HOST] | [-mMOUNT_POINT] | [-pPRODUCT] | [-DEFAULT]#       #    DEVICE = tape device (st0,mt0,ar0)#    REMOTE_HOST = host of remote tape drive#    DEFAULT = use all default values## DATE: 01/21/87PATH=/usr/ucb:/bin:/usr/bin:/etc:/usr/etc:export PATHWORK_PATH=/usr/tmp/unbundledINSTALL_SCRIPT=install_unbundledPARAMS=""CD="cd"DD="dd"MT="mt"TAR="tar"BAR="bar"MV="mv -f"EXPR="/usr/bin/expr"TAPE_LOC=""REMOTE_HOST=""REMOTE=0DEFAULT=0DEV_SPEC=0ANS=""DISK=0# CD-ROM related parametersCD_UNB_INST="cd_unbundled"MOUNT_POINT=""DEVICEISMOUNTED=0CDROM=0DEV_MP=0PRODUCT_NAME=""PRODUCT=0CDINSTALLDIR=${INSTALLAPPDIR:-""}PROGMOUNTEDDEVICE=0PAGECMD="more"USAGE="$0 [-dDEVICE] | [-rREMOTE_HOST] | [-mMOUNT_POINT] | [-pPRODUCT] | [-DEFAULT]" # Parse the argumentsfor param in $*;do	PARAMS="$PARAMS $param"        case "$param" in        -d*)	    DEVROOT=`$EXPR $param : '-d\(.*\)' '|' "1"` 	    if [ $DEVROOT -eq 1 ]	    then		echo		echo "$0 : Invalid device name"            	echo "            USAGE : $USAGE"		exit 1	    fi	    if [ "$DEVROOT" = "mounted" ]	    then# jdk assume that if mounted is specified as device, then we are using CDROM,# and the installation is local		DEVICEISMOUNTED=1	        OPTIONS="xvfp"		TAPE_LOC="local"	    fi	    DEV_SPEC=1 ;;        -r*)	    REMOTE_HOST=`$EXPR $param : '-r\(.*\)' '|' "1"` 	    if [ $REMOTE_HOST -eq 1 ]	    then		echo		echo "$0 : Invalid Host name"            	echo "            USAGE : $USAGE"		exit 1	    fi            REMOTE=1;;	-m*)	    MOUNT_POINT=`$EXPR $param : '-m\(.*\)' '|' "1"` 	    if [ $MOUNT_POINT -eq 1 ]	    then		echo		echo "$0 : Invalid mount point"            	echo "            USAGE : $USAGE"		exit 1	    fi# jdk assume that if a mount point is specified, then we are using CDROM, and# the installation is local	    TAPE_LOC="local"	    DEV_MP=1	    DEVROOT="mounted"	    DEVICEISMOUNTED=1	    OPTIONS="xvfp"	    DEV_SPEC=1;;       -p*)           PRODUCT_NAME=`$EXPR $param : '-p\(.*\)' '|' "1"`           if [ $PRODUCT_NAME -eq 1 ]           then               echo               echo "$0 : Invalid product name"               echo "            USAGE : $USAGE"               exit 1           fi	   PRODUCT=1;;        -DEFAULT)	    ANS="y"            DEFAULT=1;;        *)	    echo            echo USAGE : $USAGE	    exit 1;;        esacdone# Check if we know we're doing cd unbundled installation and haven't specified# mount point. In this case, choose environment variable or current directoryif [ $DEV_MP -eq 0 -a "`basename $0`" = $CD_UNB_INST ]then	if [ -n "$CDINSTALLDIR" ]	then		MOUNT_POINT=$CDINSTALLDIR	else		MOUNT_POINT=`pwd`	fi	DEVICEISMOUNTED=1	DEVROOT="mounted"	TAPE_LOC="local"	DEV_SPEC=1	DEV_MP=1fi	if [ $DEVICEISMOUNTED -eq 1 ]then	if [ ! -d "$MOUNT_POINT" ]	then		echo "Non-existent mount point specified - $MOUNT_POINT"		DEVICEISMOUNTED=0		MOUNT_POINT=""		DEVROOT=""		TAPE_LOC=""		DEV_MP=0		DEV_SPEC=0	fifi# Prompt user for device locationwhile [ "$ TAPE_LOC" =  "" ]do    if [ $REMOTE -eq 0 ]    then	if [ $DEFAULT -eq 0 ]	then		echo		echo -n "Enter media drive location [local | remote]: "		read TAPE_LOC	else		TAPE_LOC="local"	fi    else	TAPE_LOC="remote"    fi    case "$TAPE_LOC" in 	r*) if [ "$REMOTE_HOST" = "" ]		then			echo -n "Enter hostname of remote drive: "			read REMOTE_HOST			echo ""			REMOTE=1		fi		PARAMS="$PARAMS -r$REMOTE_HOST"	  	rsh -n  $REMOTE_HOST "echo 0 > /dev/null"		if [ "$?" -ne 0 ]		then 			echo "$0 : Problem with reaching remote host $REMOTE_HOST" 			exit 1		fi;;	l*) ;;	*)  	   echo "$0 : Incorrect response, use \"local\" or \"remote\""	   TAPE_LOC="" ;;    esacdone# prompt user for device if it hasn't been specified in the command line.if [ $DEV_SPEC -eq 0 ]then#   This one will loop until a correct device is chosen.    DEVROOT=""    while [ "$DEVROOT" = "" ]     do   	echo ""	echo -n "Enter Device Name (e.g. sr0, st0, mt0, fd0c, mounted) : "	read DEVROOT        case  "$DEVROOT" in	    mounted) if [ $REMOTE -eq 1 ]		  then		      echo "$0 : Remote option invalid for CD-ROM installation."		      echo "Please mount device locally"		      exit 1		  fi		  OPTIONS="xvfp"		  DEVICEISMOUNTED=1;;            sr*) if [ $REMOTE -eq 1 ]		  then		      echo "$0 : Remote option invalid for CD-ROM installation."		      echo "Please mount device locally"		      exit 1		  fi		  OPTIONS="xvfp"		  CDROM=1;;            st*) OPTIONS="xvfbp"                  BS=126;;            mt*) OPTIONS="xvfbp"                  BS=20;;            fd*) if [ $REMOTE -eq 1 ]		  then		      echo "$0 : Remote option cannot be used with diskette installation"		      exit 1		  fi 	  	  OPTIONS="xvfbpZT"                  BS="18"		  DISK=1;;            ar*) OPTIONS="xvfbp"                  BS=126;;            *)    echo "$0 : Invalid device name $DEVROOT"                  DEVROOT="";;        esac    doneelse #   This one will exit if an incorrect device is chosen. (default exec)    case  "$DEVROOT" in        mounted) if [ $REMOTE -eq 1 ]	      then		  echo "$0 : Remote option invalid for CD-ROM installation."		  echo "Please mount device locally"	          exit 1	      fi	      DEVICEISMOUNTED=1	      TAPE_LOC="local"	      OPTIONS="xvfp";;        sr*) if [ $REMOTE -eq 1 ]	      then		  echo "$0 : Remote option invalid for CD-ROM installation."		  echo "Please mount device locally"	          exit 1	      fi	      OPTIONS="xvfp"	      CDROM=1;;        st*) OPTIONS="xvfbp"              BS=126;;        mt*) OPTIONS="xvfbp"              BS=20;;        fd*) if [ $REMOTE -eq 1 ]	      then		  echo "$0 : Remote option cannot be used with diskette installation"	          exit 1	      fi	      OPTIONS="xvfbpT"              BS="18"	      DISK=1;;        ar*) OPTIONS="xvfbp"              BS=126;;        *)    echo "$0 : Invalid device name $DEVROOT"              exit;;    esacfiif [ $DEVICEISMOUNTED -eq 0 ]then	if [ $CDROM -eq 1 ]	then		DEVPATH="/dev/${DEVROOT}"	elif [ $DISK -eq 1 ]	then        	DEVPATH="/dev/r${DEVROOT}"	else        	DEVPATH="/dev/nr${DEVROOT}"	fi	echo	echo "**Please load the release media if you haven't done so already.**"# Wait for tape to mount, just in case.	if [ $DEFAULT -eq 0 ]	then		echo		echo -n "Press return when ready:"		read ans	fifisleep 8#########################################################################     if [ $DEV_MP -eq 0 ]then   if [ \( $DEVICEISMOUNTED -eq 1 \) -o \( $CDROM -eq 1 \) ]   then###Check if user wants to use default mount point	if [ -n "$CDINSTALLDIR" ]      	then		ans=""		echo		echo -n "OK to use default mount point - $CDINSTALLDIR [y|n]? "			read ans			if [ $ans = "y" ]			then				MOUNT_POINT=$CDINSTALLDIR			else				CDINSTALLDIR=""			fi       	fi       	if [ -z "$CDINSTALLDIR" ]       	then####### Ask the user for the CD-ROM mount point.		echo		echo -n "Please enter mount point [e.g. /cdrom]: " 		read MOUNT_POINT       	fi####### Check existence of mount point.        if [ ! -d "$MOUNT_POINT" ]        then### if mount point doesn't exist but user says device is mounted, there### is definitely a problem - exit		if [ $DEVICEISMOUNTED -eq 1 ]		then			echo			echo "$0: Device specified as mounted, but mount point is nonexistent, exiting"			exit 1		fi### If the mount point doesn't exist, no need to ask if device is### mounted later on		askmount=0		mkdir $MOUNT_POINT		if [ $? -ne 0 ]		then			echo			echo "$0 : Error making mount point, exiting"			exit 1		fi	else		askmount=1	fi####### Mount CD-ROM if needed. 	if [ $DEVICEISMOUNTED -eq 0 ]	then		if [ $askmount -eq 1 ]		then			ans=""			echo			echo -n "Is CD-ROM already mounted [y|n]? "			read ans		else			ans="n"		fi		if [ $ans = "n" ]		then			PROGMOUNTEDDEVICE=1			/etc/mount -rt hsfs $DEVPATH $MOUNT_POINT 2> /dev/null			if [ $? -ne 0 ]			then				echo				echo "$0 : Error mounting CD-ROM, exiting"				exit 1			fi		fi	fi	DEV_MP=1	DEVICEISMOUNTED=1   fifi#Do I need to set DEVROOT in all cases, or only in the non-CD casesif [ $DEV_MP -eq 1 ]then	PARAMS="$PARAMS -m$MOUNT_POINT"else	PARAMS="$PARAMS -d$DEVROOT"fi########################################################################## For tape devices only since tape can only use remote# Rewind tape, just to be sureif [ \( $DEV_MP -eq 0 \) -a \( $REMOTE -eq 1 \) ]then    stat=""    stat=`rsh -n ${REMOTE_HOST} "$MT -f ${DEVPATH} rew; echo \\$status"`    case $stat in	[1-9]* | 1[0-9]* )	     echo    	     echo "$0 : Problem with accessing tape drive, exiting"             exit 1;;	*)   ;;    esacelse    if [ \( $DISK -eq 0 \) -a \( $DEV_MP -eq 0 \) ]    then    	$MT -f ${DEVPATH} rew    	if [ $? -ne 0 ]    	then		echo    		echo "$0 : Problem with accessing tape drive, exiting"       		exit 1	fi    fifi# Print copyright to the screen for further verification# Remote install sometimes inter-mixes the stderr and stdoutif [ $DEV_MP -eq 1 ]then       while [ $PRODUCT -eq 0 ]       do               echo "Choose the product to be installed"               ls -d $MOUNT_POINT/*               read product               if [ -d $MOUNT_POINT/$product ]	       then                       PRODUCT_NAME=$product                       PRODUCT=1               fi       done ficlearecho "The following product will be installed:"# What form is copyright file on this CD? May need to use tar.if [ $DEV_MP -eq 1 ]then	$PAGECMD $MOUNT_POINT/$PRODUCT_NAME/_install/copyright.r	if [ $? -ne 0 ]	then		echo		echo "$0 : Problem accessing media, exiting"		if [ $PROGMOUNTEDDEVICE=1 ]		then			/etc/umount $MOUNT_POINT 2>/dev/null			if [ $? -ne 0 ]			then				echo				echo $0: Problem unmounting device			fi		fi		exit 1	fielse	if [ $REMOTE -eq 1 ]	then		rsh -n ${REMOTE_HOST} "$DD if=${DEVPATH}" > /tmp/cp.tmp		if [ "$?" -ne 0 ]		then			echo			echo $0 : Problem with reading copyright file on release tape. 			exit 1		fi		$PAGECMD /tmp/cp.tmp	else		if [ $DISK -eq 0 ]		then	    		$DD if=${DEVPATH} > /tmp/cp.tmp	    		if [ "$?" -ne 0 ]	    		then			echo $0 : Problem with reading copyright file on release tape.			exit 1	    		fi            		$PAGECMD /tmp/cp.tmp		else	    		$BAR ${OPTIONS} ${DEVPATH} ${BS} +install/copyright.d > /dev/null 	    		if [ "$?" -ne 0 ]            		then                		echo $0 : Problem with reading copyright file on release tape.                		exit 1            		fi	    		$PAGECMD +install/copyright.d	    		\cp +install/copyright.d /tmp/cp.tmp	    		\rm -rf +install		fi	fifiwhile [ \( "$ANS" = "" \) ]do	echo	echo -n "Do you want to continue [y|n]? "	read ANS        case $ANS in            y* )  continue;;            n* )  echo $0 : Terminating installation...                  exit 0;;            * )                  echo                  echo "Enter \"y\" or \"n\""                  ANS="";;        esacdone# tar off install script to /usr/tmp/unbundled and execute itif [ ! -d $WORK_PATH ]then	mkdir $WORK_PATH	chmod 777 $WORK_PATHfiechoecho $0 : "Extracting Installation Scripts"stat=""if [ $REMOTE -eq 1 ]then	$CD $WORK_PATH	stat=""	rsh -n  $REMOTE_HOST $MT -f $DEVPATH rew	rsh -n  $REMOTE_HOST $MT -f $DEVPATH fsf 1	rsh -n  $REMOTE_HOST $DD if=$DEVPATH bs=${BS}b | $TAR xBvfb - ${BS}	if [ "$?" -ne 0 ]	then	     	echo $0 : This tape is missing installation script.	     	exit 1	fi	rsh -n  $REMOTE_HOST $MT -f $DEVPATH rewelse	$CD $WORK_PATH	if [ $DEV_MP -eq 1 ]	then		 cp $MOUNT_POINT/$PRODUCT_NAME/_install/* .		if [ "$?" -ne 0 ]		then			echo			echo $0 : CD_ROM is missing an installation script.			exit 1		fi		/bin/chmod +x $WORK_PATH/$INSTALL_SCRIPT		if [ "$?" -ne 0 ]		then			echo			echo $0 : Error accessing installation script.			exit 1		fi	elif [ $DISK -eq 0 ]	then		$MT -f $DEVPATH rew		$MT -f $DEVPATH fsf 1		$TAR $OPTIONS $DEVPATH $BS		if [ "$?" -ne 0 ]		then			echo			echo $0 : This tape is missing an installation script.			exit 1		fi		$MT -f $DEVPATH rew	else		$BAR ${OPTIONS} ${DEVPATH} ${BS} +install		${MV} +install/* ${WORK_PATH}		rmdir $WORK_PATH/+install		if [ "$?" -ne 0 ] 		then			echo			echo $0 : This media is missing an installation script.			exit 1		fi	fifiechoecho "$0 : Begin Install Script Execution"# Note: the -f tells the install script that is was called #       from extract_unbundled# Use a different call here to make parameters simpler for the CD-ROM situation.# filter out the input parameters that are no longer needed, since DEVROOT isn't# needed if MOUNT_POINT has been setif [ $DEV_MP -eq 1 ]then	PARAMS="-m$MOUNT_POINT -p$PRODUCT_NAME"	if [ $DEFAULT -eq 1 ]	then		PARAMS="$PARAMS -DEFAULT"	fifi$WORK_PATH/$INSTALL_SCRIPT $PARAMS -fif [ $PROGMOUNTEDDEVICE -eq 1 ]then	/etc/umount $MOUNT_POINT 2>/dev/null	if [ $? -ne 0 ]	then		echo		echo $0: Problem unmounting device	fifi

⌨️ 快捷键说明

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