📄 setld
字号:
} | awk 'BEGIN { vmax=0; vmin=0 lmax=0; lmin=0 } { order[$1","$2] = $3 inuse[$1","$2] = "y" if( $1 > vmax ) vmax = $1 if( $2 > lmax ) lmax = $2 if( $1 < vmin ) vmin = $1 if( $2 < lmin ) lmin = $2 } END { for( j = vmin; j <= vmax; ++j ) { for( i = lmin; i <= lmax; ++i ) { if( inuse[j","i] == "y" ) print( order[j","i] ) } } }'}: -DetectChanges# generate a restoration inventory## given: a subset name for which to generate an inventory# does: runs the synchronization inventory thru udetect# to produce a restoration inventory _TDIR/$1.res# return: nothing# effect: leaves $1.res in _TDIRDetectChanges(){ ( LOC_S=$1 cd $_R udetect < $_TDIR/$LOC_S.syn > $_TDIR/$LOC_S.res) }: -DetermineAvailable# determine which subsets are installable in this environment## given: global data only# contents of $_TDIR# $ADVFLAG - specifies installation type# does: uses the temp directory to derive a list of subsets which# are available and installable to the system. Installable# subsets are those which are not currently installed and# are not masked by the subset mask# return: nothing# effect: sets $SBS#DetermineAvailable(){ MASK=".*" # default, all subsets # decode, # bits: # 00 - basic base # 01 - adv base # 10 - basic ws # 11 - adv ws case "$ADVFLAG" in [01]) MASK="$RISC_B|$VAX_B" ;; [23]) MASK="$RISC_B|$RISC_WS|$VAX_B|$VAX_WS" ;; esac # get list of subsets from temp dir and filter thru the mask SBS=`(cd $_TDIR; ls *.ctrl | sed 's/.ctrl//g' | egrep "$MASK")` # verify that there were control files [ "$SBS" = '*' ] && SBS=}: -Dirs# create all needed directories## given: nothing# does: makes sure the directories needed to perform correctly# are available# return: 0Dirs(){ # check if setld is in use. #! a better lock mechanism is needed here # case $CMDSW in [alux]) [ -d $_TDIR ] && { Error "Temp directory $_TDIR already in use" return 1 } esac # make sure that all required directories exist. # (cd $_R rm -rf $_TDIR for X in $U $V $V/$A $V/$T $U/$E $UAS $_TDIR { [ -d $X ] || mkdir $X || { Error "$E_MKDIR $X" return 1 } } ) mknod $PIPE p return 0}: -Error# Print an error message to stderr## given: a message to print, $1 may be option '-n'# does: prints the message to stderr, if -n option is absent,# also logs the message to the logfile# return: nothingError(){ case "$1" in -n) shift ;; *) Log "$1" esac 1>&2 echo "$PROG: $1"}: -Exit# Leave the program## given: $1 - exit status# does: leave program performing any needed cleanup# return: noExit(){ STAT=$1 Cleanup exit $STAT}: -Extract# extract subsets from media## given: $* - names of specific subsets to extract# does: Extract subsets from the media for use by# remote installation service.# return: 0 if all goes well# 1 if mandatory/ROOT extraction failure# 2 if optional extraction failureExtract(){ #% Binding SBS=$* # subsets to be installed #% Local Variables EISSUB= # extraction element is a subset {0,1} ELOC= # Extraction element tape location (x:y) ENAME= # Extraction element name EOPT= # extraction element optionality value EXTL= # EXTraction List MASK= # egrep pattern for creating mandatory, all files. #% Local Code [ "$DEFPATH" = 0 ] && cd $_R Wait MTPID || { Error "Tape Positioning Error." return 1 } # make sure there is an instctrl directory [ -d instctrl ] || mkdir instctrl # get image and comp file cp $_TDIR/*.image $_TDIR/*.comp instctrl 2> /dev/null touch instctrl/*.image # establish an extraction list. This lists each object to be # extracted, it's media location, whether it is optional, and # whether it is an actual subset or a proprietary tape file. # at the same time, create an egrep mask to be used to generate # a checksum comparison file MASK= EXTL= #! reference to image file ENAME=`egrep '[ ]ROOT[ ]*$' instctrl/*.image` && { set -- $ENAME ENAME=$3 # dummy out an entry that looks like a subset would EXTL="$ENAME:1:-1:0:0:$1" MASK=ROOT } # build entries for the rest of the subsets for ENAME in $SBS { ReadCtrlFile $_TDIR $ENAME EOPT=`FlagsAttrCheck SATTR_OPTION $FLAGS` SUM=`egrep $ENAME instctrl/*.image` set -- $SUM SUM=$1 EXTL="$EXTL $ENAME:$MTLOC:$EOPT:1:$SUM" } OPTERR=0 # create empty files > checksums; > mandatory; > all > $TMP1 for EXTENT in $EXTL { set -- `Parse : $EXTENT` ENAME=$1 EVOL=$2 ELOC=$3 EOPT=$4 EISSUB=$5 Log "$ENAME \c" echo "Extracting $ENAME..." # read the media..... case "$_MEDIA" in tape) PositionTape $EVOL $ELOC || { Error "Error Extracting $ENAME" rm -f checksums mandatory all return 1 } TickWhile "dd if=$RAW of=$ENAME bs=20b 2> /dev/null" || { Error "Error Extracting $ENAME" rm -f checksums mandatory all return 1 } _CPOS=`Add $_CPOS 1` ;; disk) TickWhile "cp $_SRC/$ENAME ." || { Error "Error Extracting $ENAME" rm -f checksums mandatory all return 1 } esac [ $EISSUB = 1 ] && { # subset specific operations: # copy .ctrl, .inv, .scp for this subset into instctrl # update mandatory, all for X in inv scp ctrl { cp $_TDIR/$ENAME.$X instctrl || { Error "Control Info Error on $ENAME" rm -f all checksums mandatory return 1 } } echo "$ENAME" >> all [ $EOPT = 0 ] && echo "$ENAME" >> mandatory } # checksum the image # wait for previous checksum Wait SUMPID ( echo "$ENAME \c" >> $TMP1 sum $ENAME >> $TMP1 ) & SUMPID=$! Log "SUCCEEDED" } Wait SUMPID SUMLIST="$SUMLIST $SUM" [ "$_MEDIA" = tape ] && { mt -f $RAW rew & MTPID=$! _CPOS=-$T_0 } for EXTENT in $EXTL { # get subset name set -- `Parse : $EXTENT` ENAME=$1 ESUM=$6 set -- `egrep $ENAME $TMP1` SSUM=$2 shift SUMLIST=$* [ "$ESUM" = "$SSUM" ] || Error "$ENAME: extract checksum error" } # rm -f mandatory compare checksums csd all & echo "Media extraction complete." return 0}: -Ferror# Fatal Error## given: $1 - Exit status# $2 - Error Message# does: print error message and Exit with statusFerror(){ STAT=$1 Error "$2" Exit $STAT}: -FlagsAttrCheck# check flags attribute## given: $1 - flag attribute to check# $2 - word to check in# does: check the value of the $1 flag in $2# return: 0 if flag is clear, 1 if set#FlagsAttrCheck(){ ( ATTR=$1 FLAG=$2 case "$ATTR" in SATTR_STICKY) VAL=$FLAG ;; SATTR_OPTION) VAL=`expr $FLAG / 2` ;; SATTR_UPDATE) VAL=`expr $FLAG / 4` ;; *) Error "FlagsAttrCheck: $ATTR: unknown attribute type" Exit 1 esac expr $VAL % 2) }: -GetCompAttr# determine compression status of a subset## given: a subset name# does: determines whether the subset is compressed# return: 0 for a compressed subset# 1 for a non-compressed subsetGetCompAttr(){ ( S=$1 cd $_TDIR NameParse X_ $S [ -f $X_P$X_V.comp ]) }: -InitDevice# Initialize the installation device## given:# does:# return:#InitDevice(){ _MEDIA= # media type - tape, diskette, disk, inet _SRC= # unit - server name, /dev/xxx, install path _LOC= # location where the savesets are stored, can be # path name, host name or tape [ -d $DEVICE ] && { _MEDIA=disk _SRC=$DEVICE _LOC=$_SRC # stabilize the pathname case "$_SRC" in /*) ;; *) _SRC=`(cd $_SRC;Pwd)` esac Log "Loading from $_LOC ($_MEDIA)" return 0 } # get the media type. case "$DEVICE" in *::) # Error "$DEVICE - DECnet installation not supported" return 1 ;; *:) # TCP inet installation _MEDIA=inet # the 'unit-number' is the server hostname _SRC=`Parse : $DEVICE` _LOC=$_SRC #! error case should be handled with retries for goodies like #! no inet ports, login limit reached. ERROR=`rsh $_SRC -l ris -n "echo hello" 2>&1` [ "$ERROR" = 'hello' ] || { Error "Error contacting server $_SRC: $ERROR" return 1 } ;; *mt*[lmh]) # some sort of tape device, get unit number and verify # access to nrmt?h. _MEDIA=tape _SRC=`expr $DEVICE : '.*mt\([0-9][0-9]*\).*'` _LOC="/dev/nrmt${_SRC}h" ;; *mt*) # tape device naming obsolete - xlate to 2.0 _MEDIA=tape _SRC=`expr $DEVICE : '.*mt\([0-9][0-9]*\).*'` _SRC=`expr $_SRC % 4` # this gets unit plug number. ;; *ra*) # ra, diskettes # get unit number _SRC=`expr $DEVICE : '.*ra\([0-9][0-9]*\).*'` _MEDIA=diskette _LOC=$_SRC ALTOP=+ ALT=`expr $_SRC $ALTOP 1` # validate the existence of device files for # both the primary and alternate diskettes [ -c $D/rra${_SRC}a -a -c $D/rra${ALT}a ] || { Error "$E_NODEV: /dev/rra${U}a, /dev/rra${ALT}a" return 1 } esac case "$_MEDIA" in "") # bogus device. Error "Device $DEVICE $E_NOSUPP" return 1 ;; tape) # do code for old and new style tapes RAW=$D/nrmt${_SRC}h [ -c $RAW ] || { Error "Cannot access $RAW" MEDIA= return 1 } while : do echo "Please make sure your installation tape is mounted and on-line." Ready mt -f $RAW rew && break done _CPOS=-$T_0 ;; esac Log "Loading from $_LOC ($_MEDIA)"}: -InitializeConstants# Initialize all constants to be used in setld## given: arglist identical to invocation arglist# does: initialize the constants used thruough the program.# all constants should be defined here.# return: nothingInitializeConstants(){ # Message Strings E_FAIL="File copy to system disk failed." E_MKDIR="Cannot create directory" E_NODEV="Please be certain that device special file" E_NOINST="not currently installed" E_NORECOVER="Cannot recover" E_NOSUPP="not supported for installations." E_READ="Attempt to read from your distribution media failed." E_STARS="*** Subset" E_TPOS="Tape positioning error." E_UNKNOWN="Unknown subset" ENOENT="no such file or directory" IC="Installation Control" # the usage messages CUSAGE="Send a configuration message to an installed subset: setld [-D dir] -c subset message" DUSAGE="Delete subset(s): setld [-D dir] -d subset [subset ...]" USAGE="Setld Usage Examples:$CUSAGE$DUSAGEList all subsets: setld [-D dir] -iList contents of installed subset(s): setld [-D dir] -i subset [subset ...]Display this message: setld [-D dir] -hLoad layered product from device: setld [-D dir] -l device [subset...]Verify integrity of subset(s): setld [-D dir] -v subset [subset ...]Extract media images from device for network distribution: setld [-D dir] -x device [subset...]" DATFMT="+19%y.%m.%d.%T" # format specifier for date command PROG=setld # program name T_0=3 # control file tape offset # path name constants # A=adm D=/dev E=etc T=tmp U=usr UAS=$U/$E/subsets # location of the subsets database V=usr/var [ ! "$STL_SUBR_DEBUG" ] && { # interactive debugging turned off, mark all constants # as read only - please insert here in the order in which # they are defined above readonly E_NOSUPP E_READ E_STARS E_TPOS E_UNKNOWN ENOENT readonly E_FAIL E_MKDIR E_NODEV E_NOINST E_NORECOVER readonly IC CUSAGE DUSAGE USAGE readonly PROG T_0 A D E T U UAS V }}: -InitializeGlobals# Initialize default values for all global variables## given: nothing# does: sets starting values for the global values used in# setld. All global variables should be defined here.# return: nothingInitializeGlobals(){ _R=/ # default install root (_R for root) _CVOL=1 # currently mounted tape volume DATE= # current date DEBUG=0 # default debug flag DECOMP=cat # decompression program DEFPATH=1 # flag - installing to default root LOGFILE=/$E/setldlog # default logfile MTPID= # mag tape async op pid RISC_B="UDT" # RISC base system product definition RISC_WS="UDW" # RISC UWS product definition STAT=1 # default exit status _TDIR=/$V/$T/stltmp$$ # default temporary directory PIPE=$_TDIR/pipe # proc sync pipe HOSTS=$_TDIR/hosts # save /etc/hosts when install from inet TMP1=/$V/$T/tmp$$ TMPS="$_TDIR $TMP1" VAX_B="ULT" # VAX base system product definition VAX_WS="UWS" # VAX UWS product definition VBSE= # default tar verbose switch}: -Install# Install subsets## given: $* - list of subsets to be installed# does: calls LoadFromMedia() and RunScps() to install the software# return: 0 if all subsets install correctly# 1 (immediately) on LoadFromMedia mandatory subset failure# 2n for n optional failures# Install(){ OPTERRS=0 SCPLIST= for _S { LoadFromMedia $_S case "$?" in 0) SCPLIST="$SCPLIST $_S" # all's OK ;; 1) OPTERRS=1 # MAND (fatal) break ;; *) OPTERRS=`expr $OPTERRS + 2` # OPT (non-fatal) esac } RunScps POST_L $SCPLIST return $OPTERRS}: -Inventory# product inventory listings## given: $* - which subsets to inventory, if empty will provide# a list of all known subsets and subset status# does: see given# return: 0Inventory(){ ( _S= # current subset name LIST= # list of all known subsets cd $_R/$UAS [ "$*" ] && { set `Ucase $*` for _S { [ -f $_S.inv ] || { Error "$_S: $E_UNKNOWN" continue }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -