#! /bin/sh # # Copyright (c) 1996 by Sun Microsystems, Inc. # # # postinstall script of AnswerBook2 # # This script cover the scenerio where SUNWab2u is installed before this # package. If that is the case we need to check the following cases # # (1) This package (SUNWab2r) is relocated # In that case all references to this package basedir should be updated # e.g dwhttpd.cfg, naspi.cfg etc. # # (2) SUNWab2u is relocated # ab2mgr script contain a variable, AB2UsrDir which is the basedir # of SUNWab2u. We need to make this variable is correct. # # This script extracts/creates FPI of SGML book # The FPI will be stored in local.socat # create_socat() { # store list of collection in tmp file TMP_LIST=/tmp/col_list.$$ # backup the socat file #/usr/bin/cp $AB2SOCAT /tmp/socat.$$.bak # working socat file TMP_FILE=/tmp/local.socat.$$ # get a list of AB2 collections awk '$1 != "dwCollectionList" && /dwCollection/{printf "%s\n", $1}' ${AB2DB} | /usr/bin/grep -v "#" > ${TMP_LIST} # number of AB2 collection NUM=`/usr/bin/grep -c . ${TMP_LIST}` NUM=`expr $NUM + 1` i=1 # rm -f ${TMP_FILE} # go thru each collection while (test $i -lt $NUM) do # obtain collection name (id) according to the position COL_NAME=`/usr/bin/sed -n -e ''${i}'p' ${TMP_LIST}` # Find the section that description the collection (lines numbers) # should be dwSetParam col_id { ... } LINE_START=`/usr/bin/awk '$1 == "dwSetParam" && /'${COL_NAME}' {/ {print NR}' ${AB2DB}` LINE_END=`expr $LINE_START + 4` # etract that section into a file `/usr/bin/sed -n -e ''${LINE_START}','${LINE_END}'p' < ${AB2DB} > /tmp/lines.$$` # get the collection location LOCATION=`/usr/bin/awk '$1 == "location" {print $2}' /tmp/lines.$$` SOCAT_PATH=${LOCATION}/socat if [ -f $SOCAT_PATH ] then # get each fpi for the collection NUM_SOCAT=`/usr/bin/grep -c . ${SOCAT_PATH}` NUM_SOCAT=`expr $NUM_SOCAT + 1` j=1 while (test $j -lt $NUM_SOCAT) do FPI=`sed -n -e ''${j}'p' ${SOCAT_PATH} | awk '{printf "%s %s %s %s\n", $1, $2, $3, $4}'` BK_NAME=`sed -n -e ''${j}'p' ${SOCAT_PATH} | awk '{print $2}'` PATH_TO_BOOK=${LOCATION}/books/${BK_NAME} if [ -d $PATH_TO_BOOK ] then # echo $FPI echo "PUBLIC ${FPI} \"${PATH_TO_BOOK}\"" >> ${TMP_FILE} fi j=`expr $j + 1` done fi i=`expr $i + 1` done rm -f ${TMP_LIST} if [ -f ${TMP_FILE} ] then cp ${TMP_FILE} ${AB2SOCAT} fi rm -f ${TMP_FILE} rm -f ${TMP_LIST} rm -f /tmp/lines.$$ } if [ ! -z "$PKG_INSTALL_ROOT" -a "${PKG_INSTALL_ROOT}" != "/" ] then # install with -R with root other than / R_OPTION="TRUE" REAL_BASEDIR=`pkgparam -R $PKG_INSTALL_ROOT SUNWab2r BASEDIR` # Note that BASEDIR is $PKG_INSTALL_ROOT/$REAL_BASEDIR in his situation else REAL_BASEDIR=$BASEDIR fi # Is SUNWab2u exists? SUWab2u_FOUND=`/usr/bin/pkginfo | /usr/bin/fgrep SUNWab2u | /usr/bin/awk '{print $2}'` if [ ! -z "$SUWab2u_FOUND" ] ; then # Get SUNWab2u basedir USR_DIR=`/usr/bin/pkgparam SUNWab2u BASEDIR` REAL_USR_DIR=`/usr/bin/pkgparam SUNWab2u BASEDIR` if [ ! -z "$R_OPTION" ] then USR_DIR="$PKG_INSTALL_ROOT$USR_DIR" fi ############################################ if test "$REAL_BASEDIR" != "/"; then # (1) This package (SUNWab2r) is relocated DWHTTPD_orig=${USR_DIR}/lib/ab2/dweb/data/config/dwhttpd.cfg DWHTTPD_tmp=/tmp/dwhttpd.cfg$$ NSAPI_orig=${USR_DIR}/lib/ab2/dweb/data/config/nsapi.cfg NSAPI_tmp=/tmp/nsapi.cfg$$ NPHDWEB_orig=${USR_DIR}/lib/ab2/bin/cgi/nph-dweb if [ ! -f $NPHDWEB_orig ]; then NPHDWEB_orig=${USR_DIR}/lib/ab2/bin/ab2bin/nph-dweb fi NPHDWEB_tmp=/tmp/nph-dweb$$ # remove modified tmp file in case it already exists rm -f $DWHTTPD_tmp rm -f $NSAPI_tmp rm -f $STYLE_MAP_tmp rm -f $NPHDWEB_tmp # dwhttpd.cfg /usr/bin/sed -e 's:set AB2RootDir.*:set AB2RootDir '${REAL_BASEDIR}':g' < ${DWHTTPD_orig} > ${DWHTTPD_tmp} cp $DWHTTPD_tmp $DWHTTPD_orig rm -f $DWHTTPD_tmp /usr/bin/sed -e 's:set AB2VarDir.*:set AB2VarDir '${REAL_BASEDIR}/var':g' < ${DWHTTPD_orig} > ${DWHTTPD_tmp} cp $DWHTTPD_tmp $DWHTTPD_orig rm -f $DWHTTPD_tmp installf -c config SUNWab2u $DWHTTPD_orig e installf -f SUNWab2u || exit 2 # nsapi.cfg /usr/bin/sed -e 's:set AB2RootDir.*:set AB2RootDir '${REAL_BASEDIR}':g' < ${NSAPI_orig} > ${NSAPI_tmp} cp $NSAPI_tmp $NSAPI_orig rm -f $NSAPI_tmp /usr/bin/sed -e 's:set AB2VarDir.*:set AB2VarDir '${REAL_BASEDIR}/var':g' < ${NSAPI_orig} > ${NSAPI_tmp} cp $NSAPI_tmp $NSAPI_orig rm -f $NSAPI_tmp installf -c config SUNWab2u $NSAPI_orig e installf -f SUNWab2u || exit 2 # update nph-dweb if [ -f ${NPHDWEB_orig} ] ; then /usr/bin/sed -e 's:set AB2RootDir.*:set AB2RootDir = '${REAL_BASEDIR}':g' < ${NPHDWEB_orig} > ${NPHDWEB_tmp} cp $NPHDWEB_tmp $NPHDWEB_orig rm -f $NPHDWEB_tmp fi /usr/bin/sed -e 's:set AB2VarDir.*:set AB2VarDir = '${REAL_BASEDIR}/var':g' < ${NPHDWEB_orig} > ${NPHDWEB_tmp} cp $NPHDWEB_tmp $NPHDWEB_orig rm -f $NPHDWEB_tmp installf -c base SUNWab2u $NPHDWEB_orig f installf -f SUNWab2u || exit 2 AB2SOCAT=$PKG_INSTALL_ROOT${REAL_BASEDIR}/var/log/ab2/catalog/local.socat else AB2SOCAT=$PKG_INSTALL_ROOT/var/log/ab2/catalog/local.socat fi ############################################ if test "$REAL_USR_DIR" != "/usr" ; then # (2) SUNWab2u is relocated # update /etc/init.d/ab2mgr ab2mgr_tmp=/tmp/ab2mgr_tmp$$ rm -f $ab2mgr_tmp if (test "$REAL_BASEDIR" = "/") ; then if [ ! -z "$R_OPTION" ] then ab2mgr_orig=$PKG_INSTALL_ROOT/etc/init.d/ab2mgr else ab2mgr_orig=/etc/init.d/ab2mgr fi else ab2mgr_orig=$REAL_BASEDIR/etc/init.d/ab2mgr fi /usr/bin/sed -e 's:AB2UsrDir\=.*:AB2UsrDir='${REAL_USR_DIR}':g' <${ab2mgr_orig} > ${ab2mgr_tmp} cp $ab2mgr_tmp $ab2mgr_orig rm -f $ab2mgr_tmp installf -c preserve $PKGINST $ab2mgr_orig e installf -f $PKGINST || exit 2 AB2DB=$PKG_INSTALL_ROOT${USR_DIR}/lib/ab2/dweb/data/config/ab2_collections.template else AB2DB=$PKG_INSTALL_ROOT/usr/lib/ab2/dweb/data/config/ab2_collections.template fi ############################################ # Update loca.socat file create_socat fi exit 0