#!/bin/sh
# vim:set sw=4 ts=4:
#
# $Id: make_apache,v 1.3 2005/04/11 14:14:39 fabian Exp $
#
#############################################################################
#
# ALICE
# Automatic Linux Installation and Configuration Environment
#
# Copyright (c) 2000-2002 SuSE Linux Solutions AG, Eschborn, Germany
#               2002-2004 SuSE Linux AG, Eschborn, Germany
#               2005      SUSE GmbH, Nuernberg, Germany
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#############################################################################
#
# Authors: Paul Buhr
#          Fabian Herschel
#
############################################################################
#
# All rights reserved.
#
############################################################################
#
# make_apache
# Configures the Apache WWW server
#
# Sections: apache
# Tags:     HTTPD_CONF, HTTPD_PHP3_INI, HTTPD_PHP_INI
#
test -n "$alice_dir" || alice_dir="/usr/lib/alice2/"
export alice_dir
usage()
{
   cat <<EOF
usage: $0 -h | --help | -?

EOF
}

while [ $# -gt 0 ]
do
   case $1 in
       -h | --help | -? ) usage
                          exit 1
                          ;;
       -fqhn ) export fqhn=$2; shift
            ;;

   esac
   shift
done   

. $alice_dir/lib/alicerc

WELCOME
std_httpd_conf=/etc/httpd/httpd.conf
std_php3_ini=/etc/httpd/php3.ini
std_php_ini=/etc/httpd/php.ini

#
############################################################################
#
GET_CONFIGURATION --require apache $CFG_DEBUG
#
# TODO: Handling of apache2
#
if [ -n "$HTTPD_CONF" ]
then
 (
   cat <<EOHD
#
# /etc/httpd/httpd.conf
# generated by ALICE
#
EOHD
   echo "$HTTPD_CONF"
 ) > ${std_httpd_conf}.alice
   CHANGED ${std_httpd_conf} || { 
      BACKUP --error ${std_httpd_conf}  
      mv ${std_httpd_conf}.alice ${std_httpd_conf}
   } 
fi

#
# generate php3.ini (for PHP3)
#
if [ -n "$HTTPD_PHP3_INI" ] 
then
 ( 
   cat <<EOHD
;
; /etc/httpd/php3.ini 
; generated by ALICE 
;
EOHD
   echo "$HTTPD_PHP3_INI" 
 ) > ${std_php3_ini}.alice 
   sleep 10
   CHANGED ${std_php3_ini} || {
      BACKUP --error ${std_php3_ini} 
      mv ${std_php3_ini}.alice ${std_php3_ini} 
   } 
fi

#
# generate php.ini (for PHP4)
#
if [ -n "$HTTPD_PHP_INI" ] 
then
 ( 
   cat <<EOHD
;
; /etc/httpd/php.ini 
; generated by ALICE 
;
EOHD
   echo "$HTTPD_PHP_INI" 
 ) > ${std_php_ini}.alice 
   sleep 10
   CHANGED ${std_php_ini} || {
      BACKUP --error ${std_php_ini} 
      mv ${std_php_ini}.alice ${std_php_ini} 
   } 
fi

#
############################################################################
# Thats all
GOOD_BYE 
