home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
encrypt
/
install
/
postinstall
< prev
next >
Wrap
Text File
|
1998-08-19
|
5KB
|
173 lines
#!/bin/sh
#
# @(#) postinstall.shinc 12.4 97/11/17
#
# Copyright (c) 1997 The Santa Cruz Operation, Inc.. All Rights Reserved.
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE SANTA CRUZ OPERATION INC.
# The copyright notice above does not evidence any actual or intended
# publication of such source code.
#
ME="`basename $0`"
ISL_FILE="/etc/inst/scripts/postreboot.sh"
SUCCESS=0; FAIL=1; INTR=3
trap "exit $INTR" 2 3 15
[ -f $ISL_FILE ] && exec 1>>/var/adm/log/$PKGINST.out
[ -f $ISL_FILE ] && exec 2>>/var/adm/log/$PKGINST.err
# location of the packaging information files during this phase of installation
INSTALL_DIR="/var/sadm/pkg/$PKGINST/install/$PKGINST"
# included standard routines
#############################################################################
#
# @(#) replace_with_newer.sh_h 12.2 97/10/27
#
# Standard routine to update the /etc/encrypt_config script with the
# one held in this package if, and only if, it can be determined that
# the one held in this package is at a later SCCS revision level.
#
# The routine uses what(C,1) to decide which file is the newer. Missing
# numbers in the SCCS R.L.B.S versioning are assumed to be 0. A file
# with no SCCS ID at all in it is assumed to be at 0.0.0.0.
#
# Arguments are:
#
# $1 - PKGINST
# $2 - action: 'test' or 'update'
# $3 - path to the original file
# $4 - path to the file to update it with
# $5 - mode of the 'new' file
# $6 - owner of the 'new' file
# $7 - group of the 'new' file
#
# Return values are:
#
# 0 - success; the file was upgraded if $2 is 'update', the
# file should be updated if $2 is 'test'
# 1 - failure; the file is as new or newer than the replacement
# we have for it
#
# Also uses:
#
# $ME - name of the shell script calling the routine
# $SUCCESS- success value 0
# $FAIL - error value 1
#
#############################################################################
replace_with_newer()
{
pkginst="$1"
action="$2"
original_file="$3"
shipped_file="$4"
mode="$5"
owner="$6"
group="$7"
# first, decide whether to update the file at all
update=0
if [ ! -f $shipped_file ]; then
echo "$ME: can't find $shipped_file" >&2
return $FAIL
fi
if [ ! -f $original_file ]; then
update=1
else
# find the SCCS IDs of both files
set -- `what $original_file | awk 'NR==2 { print $2 }' \
| awk -F'.' '{ print $1" "$2" "$3" "$4 }'`
oR=$1; oL=$2; oB=$3; oS=$4
[ -z "$oR" ] && oR=0; [ -z "$oL" ] && oL=0
[ -z "$oB" ] && oB=0; [ -z "$oS" ] && oS=0
set -- `what $shipped_file | awk 'NR==2 { print $2 }' \
| awk -F'.' '{ print $1" "$2" "$3" "$4 }'`
sR=$1; sL=$2; sB=$3; sS=$4
[ -z "$sR" ] && sR=0; [ -z "$sL" ] && sL=0
[ -z "$sB" ] && sB=0; [ -z "$sS" ] && sS=0
# now compare the SCCS releases
[ $sR -gt $oR ] && update=1
[ $sR -eq $oR -a $sL -gt $oL ] && update=1
[ $sR -eq $oR -a $sL -eq $oL -a $sB -gt $oB ] && update=1
[ $sR -eq $oR -a $sL -eq $oL -a $sB -eq $oB -a $sS -gt $oS ] && update=1
fi
if [ "$action" = "test" ]; then
# return a value based on what we found out about the
# file's comparative SCCS versions
if [ $update -eq 1 ]; then
return $SUCCESS
else
return $FAIL
fi
else
# if updating then copy over the file and update our packaging
# to reflect the fact that we now (jointly?) own this item
if [ $update -eq 1 ]; then
# copy the file, and update packaging; note that we
# make it volatile so that pkgchk won't complain if
# someone else installs a newer version later
cp $shipped_file $original_file
chmod $mode $original_file
chown $owner:$group $original_file
installf $pkginst $original_file v $mode $owner $group
# return file updated status
return $SUCCESS
else
# adopt joint ownership of the file that's there
# so that it isn't removed while we remain installed
chmod $mode $original_file
chown $owner:$group $original_file
installf $pkginst $original_file v $mode $owner $group
# return no change status
return $FAIL
fi
fi
# don't forget to run installf -f and removef -f before your
# installation script exits
echo "$ME: internal error - replace_with_newer: no valid end condition" >&2
return $FAIL
}
#############################################################################
#
# main
#
#############################################################################
# install our encrypt_config if it is newer
if [ -f $INSTALL_DIR/encrypt_config ]; then
replace_with_newer $PKGINST update /usr/sbin/encrypt_config \
$INSTALL_DIR/encrypt_config 700 root sys
ln -f /usr/sbin/encrypt_config /etc/encrypt_config
installf $PKGINST /etc/encrypt_config=/usr/sbin/encrypt_config
fi
# no more files to add or remove
removef -f $PKGINST
installf -f $PKGINST
# now run encrypt_config to reset the links for all of the packages
# that installing the strong encryption license affects
if [ -x /usr/sbin/encrypt_config ]; then
/usr/sbin/encrypt_config
else
echo "$ME: can't find or run /usr/sbin/encrypt_config" >&2
exit $FAIL
fi
# done
exit $SUCCESS