#
# $Id: installme,v 1.7 2000/04/11 23:30:35 delson Exp $
#
#
# You might like to change these.
#
HTDOC=/home/httpd/html
HTTPCONF=/etc/httpd/conf/httpd.conf
INITDIR=/etc/rc.d/init.d
#
# You probably shouldn't change these.
#
WEBDIR=$HTDOC/eFire
VARDIR=/var/lib/eFire
WEBOWNER=nobody

echo "Installing eFire..."

if [ ! -d $HTDOC ]; then
  echo "You have no $HTDOC directory.  Is apache installed?  Perhaps it's"
  echo "installed somewhere other than the default RedHat location?  In"
  echo "any case you might want to edit the $0 script."
  exit 1
fi

if [ ! -d $INITDIR ]; then
  echo "You have no $INITDIR directory.  You probably want to edit the"
  echo "$0 script, since this doesn't seem to be a RedHat style Linux."
fi

if [ -f $HTTPCONF ]; then
  OWNER=`grep '^User ' $HTTPCONF | awk '{print $2}'`
else
  OWNER=root
  echo "Warning:  You have no $HTTPCONF file.  Is apache installed?"
  echo "Files in $VARDIR should be owned by httpd or nobody but will be"
  echo "owned by root.  You might like to fix this, or edit the $0"
  echo "script."
fi

IMAGES="images/*.gif images/*.jpg"
LIB="lib/*.js"
FILES="*.html *.php3 *.inc *.js"
NETWORK="network/*.php3"
REF="reference/*.php3"
RULES="rules/*.php3 rules/*.inc"
SCRIPT="script/*.php3 script/*.inc"
CONF="rc.firewall output.rules input.rules forward.rules netobjects"

IMAGESDIR=$WEBDIR/images
LIBDIR=$WEBDIR/lib
NETWORKDIR=$WEBDIR/network
REFDIR=$WEBDIR/reference
RULESDIR=$WEBDIR/rules
SCRIPTDIR=$WEBDIR/script
FIREWALLDIR=$WEBDIR/firewall

if [ `whoami` != "root" ]; then
  echo "Sorry, eFire can only be installed by root."
  exit 1
fi

mkdir -p $WEBDIR $VARDIR $IMAGESDIR $LIBDIR $NETWORKDIR $REFDIR $RULESDIR $SCRIPTDIR
mkdir -p $FIREWALLDIR
chmod 744 $FIREWALLDIR
chown $WEBOWNER $FIREWALLDIR
chown $WEBOWNER $VARDIR
install -o $WEBOWNER -m 444 $FILES $WEBDIR
install -o $WEBOWNER -m 444 $IMAGES $IMAGESDIR
install -o $WEBOWNER -m 444 $LIB $LIBDIR
install -o $WEBOWNER -m 444 $NETWORK $NETWORKDIR 
install -o $WEBOWNER -m 444 $REF $REFDIR
install -o $WEBOWNER -m 444 $RULES $RULESDIR
install -o $WEBOWNER -m 444 $SCRIPT $SCRIPTDIR
install -o $WEBOWNER -m 600 $CONF $VARDIR

echo "Installation succesfull."
echo "You should check the permissions on the files just to be sure it fits your needs"
