: ' : ************************************************************************* : : INFORMIX SOFTWARE, INC. : : PROPRIETARY DATA : : THIS DOCUMENT CONTAINS TRADE SECRET DATA WHICH IS THE PROPERTY OF : INFORMIX SOFTWARE, INC. THIS DOCUMENT IS SUBMITTED TO RECIPIENT IN : CONFIDENCE. INFORMATION CONTAINED HEREIN MAY NOT BE USED, COPIED OR : DISCLOSED IN WHOLE OR IN PART EXCEPT AS PERMITTED BY WRITTEN AGREEMENT : SIGNED BY AN OFFICER OF INFORMIX SOFTWARE, INC. : : THIS MATERIAL IS ALSO COPYRIGHTED AS AN UNPUBLISHED WORK UNDER : SECTIONS 104 AND 408 OF TITLE 17 OF THE UNITED STATES CODE. : UNAUTHORIZED USE, COPYING OR OTHER REPRODUCTION IS PROHIBITED BY LAW. : : : Title: installclientsdk : Sccsid: @(#)installesql 9.2 2/19/93 16:36:09 : Description: : Installation script : Derived from 7.1 : ********************************************************************** : ' flags=hiof installflag="" need_vers_check="yes" versionfile="ClientSDK-cr" file_list="etc/clientsdkfiles" lvers_file="etc/.lvers_csdk" ans="" usage() { echo ' Usage: installclientsdk [-i|-o] [-f] -i: To install ClientSDK along with Informix Dynamic Server with Universal Data Option -o: To install ClientSDK along with Informix Dynamic Server or Informix Dynamic Server with other options -f: Force install to override version checking For installation of ClientSDK along with Informix Dynamic Server with Universal Data Option (Release 9), installclientsdk should be run as user "informix". For installation of ClientSDK along with Informix Dynamic Server (Release 7), or Informix Dynamic Server with other options, installclientsdk should be run as "root". All types of installation require existence of user "informix"' } # # Write the .lvers file used by check_version utility. # This file is a 'hidden' file that stores the newest # version of ClientSDK installed by the user. # write_lvers_file() { nvers=$1 if test ! -f $lvers_file ; then echo "$nvers" > $lvers_file return fi lvers="`cat $lvers_file`" compare_versions "$lvers" "$nvers" result=$? # Only overwrite the file if the just installed version # is a newer release than the previous contents. if test "x$result" = "x0" ; then echo "$nvers" > $lvers_file fi } # # function vers_abort # If the new version to be installed is older than the # installed one, abort the install. Called by version_check() # vers_abort() { i=$1 ; n=$2 echo "" echo " *** INSTALL ABORTED ***" echo "" echo "Installed version: $i" echo "New version: $n" p="`echo $versionfile|sed 's/-cr//'`" echo "" echo " Install of $p aborted to avoid overwrite of identical" echo " or newer version." echo " NOTE: To override version checking, rerun install with -f option" exit 1 } # # tar/bar/cpio the contents of the clientsdkcontent file # extract_content_file() { tarcmd=$1 ; tarfile=$2 eval $tarcmd $tarfile } # # Extract the -cr file from the etc directory. # I couldn't use extract_content_file() because the syntax is so # different b/w tar and cpio. # get_version_info() { cmd=$1 ; file=$2 case $cmd in tar | bar ) $cmd xf $file "etc/ClientSDK-cr" ;; cpi | cpio ) cpio -icdBum "etc/ClientSDK-cr" < $file > /dev/null 2>&1 ;; esac } # # function: version_check() # Make sure we're not installing over newer version. # version_check() { # Get the tar file name. First find out what type of file (tar, bar, etc.) # we are dealing with. fil="`echo ${file_list}| sed 's/etc\///' | sed 's/files//'`"content # Extract the suffix (e.g. the 'tar' of clientsdkcontent.tar) tmps=`ls -t ${fil}* 2>/dev/null |awk '{print $NR}'` if test "x$tmps" = "x" ; then echo "" echo " *** INSTALL ABORTED ***" echo "" echo ' Cannot find clientsdkcontent file' exit 1 fi filtype=`expr $tmps : '.*\.\(.*\)'` case $filtype in tar | bar ) tarfile="${fil}.${filtype}" ; tarcmd="$filtype xf " ;; cpi | cpio ) tarfile="${fil}.${filtype}" ; tarcmd="cpio -icvdBum <" ;; * ) tarfile="${fil}.${filtype}" ; tarcmd="$filtype xf " ;; esac # Make sure the tar file exists if test ! -f $tarfile ; then echo "" echo " *** INSTALL ABORTED ***" echo "" echo " Cannot find $tarfile file" exit 1 fi # If there is no versionfile (i.e. no previous version) # we're ok installedversionfile=${INFORMIXDIR}/etc/${versionfile} if test ! -f ${installedversionfile} ; then need_vers_check="no" fi # What's the currently installed version? if test -f ${installedversionfile} ; then ins_vers="`cat ${installedversionfile}|grep Version | awk '{print $NF}'`" fi # cd to /tmp to extract the ClientSDK-cr file from clientsdkcontent.tar tarfile=`pwd`/$tarfile olddir=`pwd` mkdir /tmp/crdir.$$ cd /tmp/crdir.$$ get_version_info "$filtype" "$tarfile" if test -f etc/$versionfile ; then cat etc/$versionfile new_vers="`cat etc/$versionfile|grep Version | awk '{print $NF}'`" fi cd $olddir rm -rf /tmp/crdir.$$ if test "x${need_vers_check}" = "xyes" ; then compare_versions $ins_vers $new_vers result=$? if test "x$result" = "x1" ; then vers_abort "$ins_vers" "$new_vers" fi fi # We made it this far, so go ahead and tar down the files return } # # Compare two versions, looking for differences. # returns 0 for new version is a newer release than installed version # returns 1 for new version is an older release or the same # Called by version_check() and write_lvers_file() # compare_versions() { ivers=$1 ; nvers=$2 # Compare major versions (e.g. '7' of 7.23.UC1) ins_maj=`echo $ivers|awk 'BEGIN {FS="."} {printf "%d", $1}'` new_maj=`echo $nvers|awk 'BEGIN {FS="."} {printf "%d", $1}'` if test $ins_maj -gt $new_maj ; then return 1 elif test $ins_maj -lt $new_maj ; then return 0 fi # Compare minor versions (e.g. '23' of 7.23.UC1) ins_min=`echo $ivers|awk 'BEGIN {FS="."} {printf "%d", $2}'` new_min=`echo $nvers|awk 'BEGIN {FS="."} {printf "%d", $2}'` if test $ins_min -gt $new_min ; then return 1 elif test $ins_min -lt $new_min ; then return 0 fi # Compare release versions (e.g. 'UC' of 7.23.UC1) tmp1=`echo $ivers|awk 'BEGIN {FS="."} {print $3}'` ins_rel=`expr /$tmp1 : '.*/\([A-Z][A-Z]\)'` tmp2=`echo $nvers|awk 'BEGIN {FS="."} {print $3}'` new_rel=`expr /$tmp2 : '.*/\([A-Z][A-Z]\)'` if test `expr $ins_rel \> $new_rel` = 1 ; then return 1 elif test `expr $ins_rel \< $new_rel` = 1 ; then return 0 fi # Compare release number (e.g. '1' of 7.23.UC1) ins_num=`echo $tmp1|sed 's/[A-Z][A-Z]//'` new_num=`echo $tmp2|sed 's/[A-Z][A-Z]//'` if test $ins_num -gt $new_num ; then return 1 elif test $ins_num -lt $new_num ; then return 0 fi if test $ins_rel = $new_rel ; then return 1 fi } # # main # while getopts $flags flag do case $flag in i ) if [ "${installflag}" -ne "" ] then usage exit 1 else installflag="INSTALLIUS" fi ;; o) if [ "${installflag}" -ne "" ] then usage exit 1 else installflag="INSTALLODS" fi ;; f) need_vers_check="no" ;; *) usage exit 1 ;; esac done # Before installing, check version of new product against installed version # to avoid installing an older version over a newer one version_check if [ "${installflag}" = "" ] then echo ' Is ClientSDK being installed along with Informix Dynamic Server with Universal Data Option (Release 9, required to be run as user "informix")? (yes or no)' read ans if [ "${ans}" = "yes" -o "${ans}" = "y" ] then installflag="INSTALLIUS" else installflag="INSTALLODS" fi fi echo "Extracting files from clientsdkcontent file..." echo "" extract_content_file "$tarcmd" "$tarfile" if [ "${installflag}" = "INSTALLIUS" ] then echo ' Installing ClientSDK as user informix...' else echo ' Installing ClientSDK as user root...' fi etc/installc etc/clientsdkfiles CHECK BRAND NO_UPGRADE $installflag # Write .lvers_csdk file write_lvers_file "$new_vers" # Remove content tar file rm -f clientsdkcontent.tar