# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit webapp versionator eutils NW_VERSION="0.13.1" IG_VERSION="0.4.0" CONF_DIR="/etc/${PN}" CONF_OLD="base_conf.php.dist" CONF_NEW="base_conf.php" WWW_GRP="apache" MIDDLEMAN="base_path.php" DESCRIPTION="A web-based front-end to the Snort IDS." HOMEPAGE="http://base.secureideas.net" SRC_URI="mirror://sourceforge/secureideas/${P}.tar.gz" LICENSE="GPL-2" KEYWORDS="~x86 ~amd64" # SLOT is intentionally omitted because this package uses webapp-config IUSE="apache2 mysql postgres mssql oracle gd" DEPEND=">=app-arch/tar-1.14 >=sys-libs/zlib-1.2.1-r3 >=app-arch/gzip-1.3.5-r4 >=sys-apps/coreutils-5.2.1-r2 >=sys-apps/sed-4.0.9 >=net-www/apache-1.3 apache2? ( >=net-www/apache-2 ) mysql? ( >=dev-db/mysql-3.23.0 ) postgres? ( >=dev-db/postgresql-7.1.0 )" # A local database isn't necessary, so we only upgrade to a DB supported # by BASE when the user has USE flags set for one of these DBs. # Snort can also be installed on a remote system, so we don't require it. RDEPEND="${DEPEND} gd? ( >=media-libs/gd-1.8.0 ) >=virtual/httpd-php-4.0.4 gd? ( >=dev-php/php-4.0.4 ) >=dev-php/adodb-1.2 gd? ( >=dev-php/jpgraph-1.12.2 )" # NOTE: jpgraph is currently marked for testing (~). # gd and jpgraph are only required for graphing support pkg_setup() { webapp_pkg_setup if use gd; then built_with_use dev-php/mod_php gd || \ die "dev-php/mod_php must be built with USE=gd" built_with_use dev-php/php gd || \ die "dev-php/php must be built with USE=gd" fi } src_unpack() { unpack ${A} cd ${S} # Here we help the user configure ${CONF_NEW} so BASE works out of the # box in most environments. The user will still be warned to edit the # file manually at the pkg_postinst() stage. sed -i -e 's,$BASE_urlpath.*,$BASE_urlpath = "/base";,g' \ ${CONF_OLD} sed -i -e 's,$DBlib_path.*,$DBlib_path = "/usr/lib/php/adodb";,g' \ ${CONF_OLD} if use postgres; then sed -i -e 's,$DBtype.*,$DBtype = "postgres";,g' \ ${CONF_OLD} fi if use mssql; then sed -i -e 's,$DBtype.*,$DBtype = "mssql";,g' \ ${CONF_OLD} fi if use oracle; then sed -i -e 's,$DBtype.*,$DBtype = "oci8";,g' \ ${CONF_OLD} fi # Change the source to recognize the new ${MIDDLEMAN} file we are about to # create. for PHP in *.php */*.php; do sed -i -e "s,${CONF_NEW},${MIDDLEMAN},g" \ ${CONF_OLD} "${PHP}" done # Create the file ${MIDDLEMAN} to determine the web root directory # and redirect "include" to the new ${CONF_DIR}/${CONF_NEW} location. echo " ${MIDDLEMAN} echo ' $BASE_path = dirname(__FILE__);' >> ${MIDDLEMAN} echo " include(\"${CONF_DIR}/${CONF_NEW}\");" >> ${MIDDLEMAN} echo "?>" >> ${MIDDLEMAN} # Delete the $BASE_path constant from ${CONF_NEW} because we # now handle it with the ${MIDDLEMAN} file we created above. sed -i -e 's,$BASE_path =.*,,g' ${CONF_OLD} # Modify the HTML headers so search engines don't index BASE. sed -i -e \ 's::\n :g' \ index.php sed -i -e \ 's::\n :g' \ base_main.php } src_install() { webapp_src_preinst # Install the docs once in the standard /usr/share/doc/${PF}/DOCDESTREE # location instead of installing them in every virtual host directory. cd docs dodoc * cd ${S} rm -rf docs # Install the config files in the usual location (/etc/${PN}). insinto ${CONF_DIR} doins ${CONF_OLD} newins ${CONF_OLD} ${CONF_NEW} # Install BASE for webapp-config insinto ${MY_HTDOCSDIR} doins -r * # Tighten the security a little since BASE uses plain-text passwords. # This could use some future modifications to account for the fact that # some users may use a different web server than Apache. # fperms 640 ${CONF_DIR}/${CONF_NEW} fowners root:${WWW_GRP} ${CONF_DIR}/${CONF_NEW} # ewarn \ # "Please modify the permissions of ${CONF_DIR}/${CONF_NEW} as the file \ # stores plain-text passwords for connecting to your database." webapp_src_install } pkg_postinst() { if use gd; then /usr/bin/pear install Image_Color /usr/bin/pear install Log /usr/bin/pear install Numbers_Roman /usr/bin/pear install \ http://pear.php.net/get/Numbers_Words-${NW_VERSION}.tgz /usr/bin/pear install \ http://pear.php.net/get/Image_Graph-${IG_VERSION}.tgz fi webapp_pkg_postinst einfo "" einfo "For BASE to work properly, your web browser must have cookie" einfo "support enabled." einfo "Since the reports generated by BASE can contain sensitive" einfo "information, it is recommended that you implement (SSL/TLS). It is" einfo "also recommended that your php.ini have \"display_errors\"" einfo "set to \"off.\"" ewarn "You may need to edit \"${CONF_DIR}/${CONF_NEW}\" before using BASE." einfo "To setup your initial database, direct your web browser to the" einfo "location you installed BASE/base_db_setup.php." einfo "" }