#!/bin/sh
#
# postinstall script for Apache written by Ron Record (rr@caldera.com) 11-Feb-99
# Modified 2001-03-14 Allan Clark (allanc@caldera.com)
# 
# Previously, we would setup the Apache password authentication
# file with root's password.  This was for the benefit of the
# Administrators Webtop, but webtop configuration is now a
# separate package (apwebtop)
#

# Edit the configuration file(s)
#
  if [ -f /etc/inst/scripts/postreboot.sh ]
  then
    HOST=`grep TCP_DOMAIN_NAME /isl/ifile`
    HOSTNAME=`uname -n`.`echo $HOST | sed -e "s/^.*=\"\(.*\)\"$/\1/p"`
  else
    HOSTPROG=/usr/ucb/hostname
    if [ -x $HOSTPROG ] 
    then
      HOSTNAME=`$HOSTPROG`
    else
      HOSTNAME=localhost
    fi
  fi
  [ "$HOSTNAME" ] || HOSTNAME=localhost
  INTERFACE=/etc/confnet.d/inet/interface
  CLUSTERIP=
  [ -f $INTERFACE ] && {
     CLUSTERIP=`grep cvip $INTERFACE | awk -F : ' { print $3 } '`
  }
  [ "$CLUSTERIP" ] || {
    CLUSTERIP=`ifconfig net0 | grep netmask | awk ' { print $2 } '`
  }
  [ "$CLUSTERIP" ] || {
    CLUSTERIP=`grep $HOSTNAME /etc/hosts | awk ' { print $1 } '`
  }
  HOST_FILES="/usr/lib/apache/conf/httpd.conf \
/usr/lib/apache/conf/httpd.conf.default"

  for i in $HOST_FILES
  do
  [ -f $i ] && {
    sed -e "s/rincon.pdev.ca.caldera.com/$HOSTNAME/g" < $i > /tmp/_ccs$$
    mv /tmp/_ccs$$ $i
    rm -f /tmp/_ccs$$ /tmp/_ccs_ip$$
    chown root:sys $i
  }
  done

# Create a /usr/local/apache symlink for backwards compatibility
# with previous Skunkware Apache releases
#
[ -d /usr/local/apache ] && {
    echo "Moving /usr/local/apache to /usr/local/apache.bak"
    mv /usr/local/apache /usr/local/apache.bak
}
[ -h /usr/local/apache ] && rm -f /usr/local/apache
[ -d /usr/local ] || mkdir -p /usr/local
ln -s /usr/lib/apache /usr/local/apache

# Configure DocView for use with Apache's documentation
#
LOGFILE=/var/sadm/install/logs/ApacheDoc.log
doctool --add HelpTopics/INThome/INTgroup/ApacheDoc.desktop >> $LOGFILE 2>&1

# Enable the auto-start of the server at boot time
#
#/etc/apache enable

echo "
Apache web server installation complete. This release includes the
Apache interface to OpenSSL, mod_ssl. An introduction to this interface
is available at

    http://$HOSTNAME/manual/mod/mod_ssl/

To configure Apache to start when the system is booted run the command:

    # /etc/apache enable
 
To start Apache manually run the command:

    # /etc/apache start
 
The server is preconfigured to listen on port 80. Before starting, verify
that no other web server is listening on port 80 (e.g. Netscape FastTrack,
the OpenLinux Apache under LKP or a previously installed release of Apache).

Visit your preliminary startup page at http://$HOSTNAME\n"

exit 0
    

