#!/sbin/sh

#########################################################################
# 									
#   File:	 customize
#   @(#) customize $Revision: 1.10 $ $Date: 93/02/23 12:09:18 $
#   Description: /etc/update customization script for HPXT2-XDM fileset
# 
#########################################################################
#

umask 022
set -a
PATH="/bin:/usr/bin:/etc:."
FILESET=HPXT2-XDM

# Get environment variables as setup earlier in prerequisite fileset    
#
ENVARDIRS="/opt/hpxt/enware2/lbin /tmp /usr/tmp last"
for ENVARDIR in $ENVARDIRS
do
  if [ $ENVARDIR = "last" ]
  then
    echo "WARNING: cannot find suitable env.vars file"
    exit 0
  fi

  if [ -f $ENVARDIR/env.vars ]
  then
    . $ENVARDIR/env.vars
    break
  fi
done


if [ "$OS" = "hp10" ]
then

  if [ -f /usr/bin/dcnodes -o -f /usr/sbin/dcnodes ]
  then
    dcnodes -q
    if [ $? -eq 2 ]
    then
        exit 0
    fi
  fi

  CONTROL_UTILS=/usr/lbin/sw/control_utils
  if [ ! -f $CONTROL_UTILS ]
  then
    echo "ERROR:   Cannot find $UTILS"
    exit 1
  fi
  set +u
  . $CONTROL_UTILS
  set -u
  PATH=$PATH:/opt/hpxt/enware2/lbin
else
  PATH=$PATH:$ADMINDIR
fi


NEWXDMLIB=/opt/hpxt/enware2/xdm
XDMFILES="Xaccess Xresources Xservers xdm-config \
            Xsession Xstartup Xreset sys.xsession"

for FILE in $XDMFILES
do
  if [ -f $NEWXDMLIB/$FILE ]
  then
    cmp -s /opt/hpxt/enware2/newconfig/$FILE $NEWXDMLIB/$FILE
    if [ $? -ne 0 ]
    then
      echo
      echo "INFO:    existing $NEWXDMLIB/$FILE seems customized,"
      echo "         .. a new version is available in /opt/hpxt/enware2/newconfi"
    fi
  else
    cp /opt/hpxt/enware2/newconfig/$FILE $NEWXDMLIB
    xtutil_add-file $NEWXDMLIB/$FILE
  fi
done



if [ "$OS" = "hp10" ]
then
  exit 0
fi

#
# check if .greetless was used
#
if [ -s /etc/.greetless ]
then
	cat <<EOF
WARNING: It appears that you were using the greetless feature of xdm.
         If you still intend to run xdm instead of the default vuelogin,
         you will need to convert the lines in your "/etc/.greetless" file
         to BYPASS_LOGIN lines in "/opt/hpxt/enware2/xdm/Xaccess".
EOF
fi


if [ "$OS" = "hp" ]
then
  ARCH=$1
  ARCHEXT=""
  case $ARCH in
    HP-MC68*)
	if [ ! hp9000s300 ]
	then
	    ARCHEXT="+/$ARCH"
	fi
	;;
  esac
fi




# remove old 700X fileset
/bin/rm -rf /system${ARCHEXT}/XDM 2>/dev/null
/bin/rm -f /etc/filesets${ARCHEXT}/XDM 2>/dev/null

# remove old 700RX fileset
/bin/rm -rf /system${ARCHEXT}/700RX-XDM 2>/dev/null
/bin/rm -f /etc/filesets${ARCHEXT}/700RX-XDM 2>/dev/null

exit 0
