home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
TEDdesk
/
install
/
postinstall
< prev
next >
Wrap
Text File
|
1998-08-19
|
17KB
|
777 lines
#! /bin/sh
# $Id: postinstall.src,v 1.4 1997/11/07 00:13:18 marye Exp $
######################################################################
# Triteal Enterprise Desktop
# (c) Copyright 1997 TriTeal Corporation
#
# TEDdesk postinstall
######################################################################
INSTALL_ROOT=""
######################################################################
# KillProc
# $1 process
######################################################################
KillProc()
{
ps -ef | fgrep $1 | grep -v grep >/tmp/killproc.$$
if [ -s /tmp/killproc.$$ ]
then
awk '{print "kill " $2}' /tmp/killproc.$$ | /bin/sh 1>/dev/null
sleep 2
ps -ef | fgrep $1 | grep -v grep >/tmp/killproc.$$
if [ -s /tmp/killproc.$$ ]
then
awk '{print "kill -TERM " $2}' /tmp/killproc.$$ | /bin/sh 1>/dev/null
sleep 2
ps -ef | fgrep $1 | grep -v grep >/tmp/killproc.$$
if [ -s /tmp/killproc.$$ ]
then
awk '{print "kill -9 " $2}' /tmp/killproc.$$ | /bin/sh 1>/dev/null
sleep 2
fi
fi
fi
rm -f /tmp/killproc.$$
}
######################################################################
# Usage
######################################################################
Usage()
{
echo "Usage: `basename $0`"
echo ""
}
######################################################################
# SyncInetD
######################################################################
SyncInetD()
{
if [ -z "$TED_NO_EDIT_SYSFILES" ]; then
# issue a SIGHUP to the inetd process
ps -ef | grep inetd | grep -v grep >/tmp/tmppsout
if [ -s /tmp/tmppsout ]
then
$AWK '{print "kill -HUP " $2}' /tmp/tmppsout | /bin/sh
else
/usr/etc/inetd
fi
rm /tmp/tmppsout
fi
}
######################################################################
# UpdateEtcAppConfigDirectory
######################################################################
UpdateEtcAppConfigDirectory()
{
# a new locale has been installed. update /etc/dt
APPCONFIG=appconfig
# appconfig directories to update
APPCONFIG_DIRS="appmanager help icons types"
# make sure appconfig directory exists
cd ${INSTALL_ROOT}$TED_CONFIG_TOP
if [ ! -d $APPCONFIG ]
then
mkdir $APPCONFIG
fi
cd $APPCONFIG
for i in $APPCONFIG_DIRS
do
# make sure appconfig subdirectory exists
if [ ! -d $i ]
then
mkdir $i
fi
if [ -d ${INSTALL_ROOT}$TED_TOP/$APPCONFIG/$i ]; then
cd $i
# for each locale in install area, update appconfig
for j in ${INSTALL_ROOT}$TED_TOP/$APPCONFIG/$i/*
do
subdir=`basename $j`
if [ ! -d $subdir ]; then
# check to see if the locale is a sym link and create sym link dir if it is
if [ -h ${INSTALL_ROOT}$TED_TOP/$APPCONFIG/$i/$subdir ] ; then
base_subdir=`echo $subdir | cut -f1 -d! | cut -f1 -d_ `
ln -s $base_subdir $subdir
else
mkdir $subdir
fi
fi
done
cd ..
fi
done
}
# $Id: install.misc,v 1.1.1.1 1997/09/09 01:23:24 philip Exp $
# Misc installation functions
######################################################################
#
# moveVendorCDELibs
# looking at a package's pkglist, moves any library, whos target is
# /usr/dt/lib and already exists in /usr/dt/lib (vender's cde lib)
# and a link exists from the os's library dir to
# /usr/dt/lib/<library>, to the os's library dir.
#
# input:
# $1 - path and file name of pkglist for package to be installed
# $2 - os's library dir.
#
# output:
# moved libraries from /usr/dt/lib to os's library dir
#
# note:
# this should be called in every packages that installs libraries
# in /usr/dt/lib
#
######################################################################
moveVendorCDELibs ( )
{
pkglistFile="$1"
libDir="$2"
while read entry type
do
#
# check for valid entry
# check for target of /usr/dt/lib
# check for file (as opposed to directory)
# check for existance as a file in /usr/dt/lib
# check for link in lib directory to /usr/dt/lib
#
if [ -n "$entry" -a \
-n "$type" -a \
`echo $entry | \cut -f1 -d\/` = "lib" -a \
"$type" = "file" -a \
-f /usr/dt/$entry -a \
-h $libDir/$entry ]
then
# check for entry really being a lib (begins with lib)
isALib="no"
isALib="`echo $entry | \cut -f2 -d\/ | \sed -e 's/^lib.*//g'`"
if [ -z "$isALib" ]
then
\mv /usr/dt/$entry $libDir/$entry
fi
fi
done < $pkglistFile
}
INSTALL_ROOT=""
######################################################################
# Misc USL functions
######################################################################
CheckForClobberedLinks()
{
if [ -z "$TED_NO_EDIT_SYSFILES" ]; then
#
# ensure links not clobbered
#
for file in services inetd.conf
do
if [ ! -h /etc/$file ] ; then
if [ -f /etc/$file ] ; then
rm /etc/$file
ln -s /etc/inet/$file /etc/$file
fi
fi
done
fi
}
######################################################################
# FixEtcRpc
######################################################################
FixEtcRpc()
{
if [ -z "$TED_NO_EDIT_SYSFILES" ]; then
TMPFILE=/tmp/etc-rpc
if [ ! -f $RPC ]; then
# if the file doesnot exist (highly unlikely), make one
echo "cmsd 100068 dtcalendar" >$RPC
echo "ttdbserverd 100083 tooltalk" >>$RPC
else
rm -f /tmp/etc-rpc-already-there
if [ ! -f ${RPC}.preTED ]; then
cp $RPC ${RPC}.preTED
fi
# check to see if the cmsd entry is already there
$AWK '{
if ($1 == "cmsd" && $2 == "100068")
print $0 > "/tmp/etc-rpc-already-there"
}' $RPC >/dev/null
if [ ! -f /tmp/etc-rpc-already-there ]
then
# if it is not, check to see if either item already exists
$AWK '{
if ($1 == "cmsd" || $2 == "100068")
print $0 > "/tmp/etc-rpc-already-there"
}' $RPC >/dev/null
# if either one does they need to be commented out
if [ ! -f /tmp/etc-rpc-already-there ]
then
echo "cmsd 100068 dtcalendar" >>$RPC
else
$AWK '{if ($2 == "100068" && $1 != "cmsd")
print "#TED " $0;
else
print $0
}' $RPC >$TMPFILE
echo "cmsd 100068 dtcalendar" >>/tmp/etc-rpc
cp $TMPFILE $RPC
rm -f $TMPFILE
rm /tmp/etc-rpc-already-there
fi
else
rm /tmp/etc-rpc-already-there
fi
# check to see if the entry is already there
rm -f /tmp/etc-rpc-already-there
$AWK '{if ($1 == "ttdbserverd" && $2 == "100083")
print $0 > "/tmp/etc-rpc-already-there"
}' $RPC >/dev/null
if [ ! -f /tmp/etc-rpc-already-there ]
then
# if it isnot, check to see if either term already exists
$AWK '{if ($1 == "ttdbserverd" || $2 == "100083")
print $0 > "/tmp/etc-rpc-already-there"
}' $RPC >/dev/null
# exists. If either one does they need to be commented out.
if [ ! -f /tmp/etc-rpc-already-there ]
then
echo "ttdbserverd 100083 tooltalk" >>$RPC
else
$AWK '{if ($2 == "100083" || $1 != "ttdbserverd")
print "#TED " $0;
else
print $0
}' $RPC >$TMPFILE
echo "ttdbserverd 100083 tooltalk" >>$TMPFILE
cp $TMPFILE $RPC
rm -f $TMPFILE
rm /tmp/etc-rpc-already-there
fi
else
rm /tmp/etc-rpc-already-there
fi
fi
chmod 644 $RPC
else
echo "WARNING: did not modify $RPC"
fi
}
######################################################################
# AddCmsdToInetd
######################################################################
AddCmsdToInetd()
{
TMPFILE=/tmp/inetd.conf.cmsd.$$
# desired inetd.conf entry:
# 100068/2-5 dgram rpc/udp wait root /usr/dt/bin/rpc.cmsd rpc.cmsd
# first make an awk script and put it in a file. The awk script
# checks for rpc.cmsd AND that it is the TED version
# get rid of legacy entry
$AWK '{
if ($1 == "#TED" && $7 == "/usr/dt/bin/rpc.cmsd")
;
else
print $0
}' $INETD_CONF >$TMPFILE
cp $TMPFILE $INETD_CONF
rm -f $TMPFILE
# comment out any non-TED rpc.cmsd lines
$AWK '{if ($1 ~ "100068/" && $6 != "/usr/dt/bin/rpc.cmsd")
print "#TED " $0;
else
print $0
}' $INETD_CONF >$TMPFILE
cp $TMPFILE $INETD_CONF
rm -f $TMPFILE
# remove any TED 2-4 cmsd
$AWK '{
if ($1 == "100068/2-4" && $6 == "/usr/dt/bin/rpc.cmsd" )
;
else
print $0
}' $INETD_CONF >$TMPFILE
cp $TMPFILE $INETD_CONF
rm -f $TMPFILE
# now run an awk script to see if there is an occurrence of 2-5 cmsd
$AWK '{
if ($6 == "/usr/dt/bin/rpc.cmsd" && $1 == "100068/2-5")
print $0 > "/tmp/cmsd-already-there"
}' $INETD_CONF >/dev/null
# if it is not there, add it
if [ ! -f /tmp/cmsd-already-there ]; then
echo "100068/2-5 dgram rpc/udp wait root /usr/dt/bin/rpc.cmsd rpc.cmsd" >>$INETD_CONF
else
rm /tmp/cmsd-already-there
fi
}
######################################################################
# AddDtspcdToInetd
######################################################################
AddDtspcdToInetd()
{
TMPFILE=/tmp/inetd.conf.dtspcd.$$
# desired inetd.conf entry:
# "dtspc stream tcp nowait root /usr/dt/bin/dtspcd dtspcd
# get rid of legacy entry
$AWK '{if ($1 == "dtspc" && $6 == "/usr/dt/bin/dtspcd")
;
else
print $0
}' $INETD_CONF >$TMPFILE
cp $TMPFILE $INETD_CONF
rm -f $TMPFILE
# Now add the dtspc line
echo "dtspc stream tcp nowait root /usr/dt/bin/dtspcd dtspcd" >>$INETD_CONF
}
######################################################################
# AddTtdbToInetd
######################################################################
AddTtdbToInetd()
{
TMPFILE=/tmp/inetd.conf.ttdb.$$
/usr/sbin/pmadm -d -p tcp -s ttdbserverd >/dev/null 2>&1
/usr/sbin/pmadm -r -p tcp -s ttdbserverd >/dev/null 2>&1
/usr/sbin/pmadm -a -p tcp -s ttdbserverd -i root \
-m `/usr/sbin/nlsadmin -c /usr/dt/bin/rpc.ttdbserverd \
-D -R 100083:1` -v `/usr/sbin/nlsadmin -V`
/usr/sbin/sacadm -x -p tcp
}
######################################################################
# FixInetdDotConf
######################################################################
FixInetdDotConf()
{
if [ -z "$TED_NO_EDIT_SYSFILES" ]; then
if [ ! -f $INETD_CONF ]; then
echo "" >$INETD_CONF
fi
if [ ! -f ${INETD_CONF}.preTED ]; then
cp $INETD_CONF ${INETD_CONF}.preTED
fi
AddCmsdToInetd
AddDtspcdToInetd
AddTtdbToInetd
chmod 644 $INETD_CONF
else
echo "WARNING: did not modify $INETD_CONF"
fi
}
######################################################################
# FixEtcServices
######################################################################
FixEtcServices()
{
if [ -z "$TED_NO_EDIT_SYSFILES" ]; then
TMPFILE=/tmp/tmp.services.$$
if [ ! -f ${SERVICES}.preTED ]; then
cp $SERVICES ${SERVICES}.preTED
fi
#
# check for existence of $SERVICES
#
if [ ! -f $SERVICES ]; then # highly unlikely
echo "" >$SERVICES
fi
#
# remove legacy entries like dtspcd
#
$AWK '{
if ($1 == "dtspcd" || $1 == "#dtspcd")
;
else
print $0
}' $SERVICES >$TMPFILE
cp $TMPFILE $SERVICES
rm -f $TMPFILE
#
# see if it already exists
#
$AWK '{
if ($1 == "dtspc")
print $0 > "/tmp/dtspc-already-there"
}' $SERVICES >/dev/null
if [ ! -f /tmp/dtspc-already-there ]; then
echo "dtspc 6112/tcp # subprocess control" >>$SERVICES
else
rm /tmp/dtspc-already-there
fi
chmod 644 $SERVICES
else
echo "WARNING: did not modify $SERVICES"
fi
}
######################################################################
# CreateEtcAppConfigDirectory
######################################################################
CreateEtcAppConfigDirectory()
{
APPCONFIG=appconfig
APPCONFIG_DIRS="appmanager help icons types"
#
# Create the APPCONFIG directory inside TED_CONFIG_TOP and create
# all of its subdirectories
#
cd ${INSTALL_ROOT}$TED_CONFIG_TOP
if [ ! -d $APPCONFIG ]; then
mkdir $APPCONFIG
fi
cd $APPCONFIG
for i in $APPCONFIG_DIRS
do
if [ ! -d $i ]; then
mkdir $i
fi
if [ -d ${INSTALL_ROOT}$TED_TOP/$APPCONFIG/$i ]; then
cd $i
#
# for each locale
#
for j in ${INSTALL_ROOT}$TED_TOP/$APPCONFIG/$i/*
do
subdir=`basename $j`
if [ ! -d $subdir ]; then
mkdir $subdir
fi
done
cd ..
fi
done
}
######################################################################
# CreateVarDtDir
######################################################################
CreateVarDtDir()
{
APPCONFIG=appconfig
# create the /var/dt directory
#
if [ -h ${INSTALL_ROOT}$TED_TEMP_TOP ] ; then
rm ${INSTALL_ROOT}$TED_TEMP_TOP
fi
if [ ! -d ${INSTALL_ROOT}$TED_TEMP_TOP ]; then
mkdir -p ${INSTALL_ROOT}$TED_TEMP_TOP
if [ ! -d ${INSTALL_ROOT}$TED_TEMP_TOP/$APPCONFIG/appmanager ]; then
mkdir -p ${INSTALL_ROOT}$TED_TEMP_TOP/$APPCONFIG/appmanager
fi
# sanity check
if [ "$TED_TEMP_TOP" != "/" ]; then
chmod -R 777 ${INSTALL_ROOT}$TED_TEMP_TOP/*
chown -R root ${INSTALL_ROOT}$TED_TEMP_TOP/*
chgrp -R bin ${INSTALL_ROOT}$TED_TEMP_TOP/*
fi
else
if [ ! -d ${INSTALL_ROOT}$TED_TEMP_TOP/$APPCONFIG/appmanager ]; then
mkdir -p ${INSTALL_ROOT}$TED_TEMP_TOP/$APPCONFIG/appmanager
fi
fi
#
# create the /var/dt/tmp directory for the dtspcd
#
if [ ! -d ${INSTALL_ROOT}$TED_TEMP_TOP/tmp ]; then
mkdir -p ${INSTALL_ROOT}$TED_TEMP_TOP/tmp
fi
}
######################################################################
# CreateEtcDtDir
######################################################################
CreateEtcDtDir()
{
#
# create /etc/dt and its config directory
#
if [ -h ${INSTALL_ROOT}$TED_CONFIG_TOP ] ; then
rm ${INSTALL_ROOT}$TED_CONFIG_TOP
fi
if [ ! -d ${INSTALL_ROOT}$TED_CONFIG_TOP ]; then
mkdir -p ${INSTALL_ROOT}$TED_CONFIG_TOP
fi
if [ ! -d ${INSTALL_ROOT}$TED_CONFIG_TOP/config ]; then
mkdir -p ${INSTALL_ROOT}$TED_CONFIG_TOP/config
fi
#
# Configure Xsession.d
#
cd ${INSTALL_ROOT}$TED_CONFIG_TOP/config
if [ ! -d Xsession.d ]; then
mkdir Xsession.d
fi
if [ ! -z "$TED_CONFIG_TOP" ]; then
# sanity check
if [ "$TED_CONFIG_TOP" != "/" ]; then
chmod -R 755 ${INSTALL_ROOT}$TED_CONFIG_TOP\/*
fi
fi
#
# make sure /etc/dt/appconfig exists
#
CreateEtcAppConfigDirectory
}
######################################################################
# Main
######################################################################
SERVICES=/etc/inet/services
INETD_CONF=/etc/inet/inetd.conf
RPC=${INSTALL_ROOT}/etc/rpc
AWK=nawk
TED_TOP=$TED_DIR
TED_CONFIG_TOP=/etc/dt
TED_TEMP_TOP=/var/dt
if [ -z "$TED_TOP" ]; then
echo "ERROR TED_TOP not set, exiting"
exit 1;
fi
CheckForClobberedLinks
if [ -z "$SHAREDINSTALL" ]; then
# Link the installed files to /usr/dt (if needed)
TestDir=`echo $TED_TOP | sed -e 's|//*|/|g' -e 's|/$||'`
if [ "$TestDir" != "/usr/dt" ] ; then
installf TEDdesk /usr/dt=$TED_TOP s
if [ -f ${INSTALL_ROOT}/usr/dt ] ; then
mv ${INSTALL_ROOT}/usr/dt ${INSTALL_ROOT}/usr/dt.preTED
fi
rm -f ${INSTALL_ROOT}/usr/dt
ln -s $TED_TOP ${INSTALL_ROOT}/usr/dt
else
installf TEDdesk /usr/dt
fi
fi
# stop any running TED programs
KillProc "rpc.cmsd"
KillProc "rpc.ttdbserverd"
KillProc "dtspcd"
KillProc "dtlogin"
KillProc "dtsession"
PRINTERS=""
DEFAULT_PRINTER="DtPrint"
CreateVarDtDir
CreateEtcDtDir
FixEtcRpc
FixEtcServices
FixInetdDotConf
#
# ConfigurePrintersDir
#
if [ -z "$TED_NO_EDIT_SYSFILES" -a -x $TED_TOP/bin/dtprintinfo ]; then
env LANG=C ${INSTALL_ROOT}$TED_TOP/bin/dtprintinfo -populate
else
echo "WARNING: /etc/dt printer information files not created"
fi
# sync inetd with our changes
SyncInetD
if [ -z "$SHAREDINSTALL" ]; then
# Let the pkg routines know about our file system changes
installf -f TEDdesk
fi