diff --git a/package/misc/snort/snort.conf b/package/misc/snort/snort.conf index 64b431964..d3e8de1fd 100644 --- a/package/misc/snort/snort.conf +++ b/package/misc/snort/snort.conf @@ -20,48 +20,19 @@ # # --- ROCK-COPYRIGHT-NOTE-END --- -# Set up options for configure -# snort should be installed in /opt because it is easier -# to maintain if it has its own directory structure -prefix=/opt/snort -set_confopt +if [ $prefix_auto = 1 ] ; then + prefix=opt/snort + set_confopt +fi # postgresql support -pgsqldir="" -if [ -r /opt/postgresql/include/libpq-fe.h ] ; then - pgsqldir=/opt/postgresql -elif [ -r /usr/include/libpq-fe.h ] ; then - pgsqldir=/usr -elif [ -r /usr/include/pgsql/libpq-fe.h ] ; then - pgsqldir=/usr -elif [ -r /usr/include/postgresqllibpq-fe.h ] ; then - pgsqldir=/usr -elif [ -f /usr/local/include/libpq-fe.h ] ; then - pgsqldir=/usr/local -elif [ -f /usr/local/include/pgsql/libpq-fe.h ] ; then - pgsqldir=/usr/local -elif [ -f /usr/local/include/postgresql/libpq-fe.h ] ; then - local pgsqldir=/usr/local -fi -if [ "$pgsqldir" != "" ] ; then - var_append extraconfopt " " "--with-postgresql=$pgsqldir" +if [ -n "$pkg_postgresql_prefix" ] ; then + var_append extraconfopt " " "--with-postgresql=$pkg_postgrsql_prefix" fi # mysql support -mysqldir="" -if [ -r /opt/mysql/include/mysql/mysql.h ] ; then - mysqldir=/opt/mysql -elif [ -r /usr/include/mysql.h ] ; then - mysqldir=/usr/ -elif [ -r /usr/include/mysql/mysql.h ] ; then - mysqldir=/usr -elif [ -r /usr/local/include/mysql.h ] ; then - mysqldir=/usr/local -elif [ -r /usr/local/include/mysql/mysql.h ] ; then - mysqldir=/usr/local -fi -if [ "$mysqldir" != "" ] ; then - var_append extraconfopt " " "--with-mysql=$mysqldir" +if [ -n "$pkg_mysql_prefix" ] ; then + var_append extraconfopt " " "--with-mysql=$pkg_mysql_prefix" fi # openSSL support @@ -89,66 +60,45 @@ fi snort_premake() { # Comply with FHS for /var/opt/ - cd $builddir/snort-$ver/src - sed 's/\/var\/log\/snort/\/var\/opt\/snort\/log/' snort.h > temp.f - mv -f temp.f snort.h + sed 's/\/var\/log\/snort/\/var\/opt\/snort\/log/' src/snort.h > \ + src/snort.new + mv -f snort.h{.new,} } snort_postmake() { # 'make install' sadly doesn't copy a lot of useful stuff # so we have to do it ourselves - cd $builddir/snort-$ver # The contrib directory contains helper scripts and tars # of plugins. This directory is just copied over. - cp -r contrib /opt/snort/ + cp -fr contrib $docdir # The etc directory includes snort.conf, sigs, maps and rules. # Technically the maps should not be here but snort convention # places them in etc. # For security reasons this directory should not be world-readable - mkdir -p /opt/snort/var - cp -r etc /opt/snort/ - cp -r rules /opt/snort/etc/ - mv /opt/snort/etc/etc/* /opt/snort/etc/ - rm -rf /opt/snort/etc/etc/ - sed 's/\.\.\/rules/.\/rules/' /opt/snort/etc/snort.conf > temp.f - mv -f temp.f /opt/snort/etc/snort.conf - chmod -R 700 /opt/snort/etc - + mkdir -p $root/$prefix/var + cp -r etc/* $root/$prefix/etc/ + cp -r rules $root/$prefix/etc/ + + # THIS IS DANGEROUS - IT MIGHT AFFECT OTHER PACKAFES FILES !!! + # FIS THIS PROPERLY! + # mv /opt/snort/etc/etc/* /opt/snort/etc/ + # rm -rf /opt/snort/etc/etc/ + sed 's/\.\.\/rules/.\/rules/' $root/$prefix/etc/snort.conf > \ + $root/$prefix/etc/snort.conf.new + mv -f $root/$prefix/etc/snort.conf{.new,} + + # THIS IS DANGEROUS - IT MIGHT AFFECT OTHER PACKAGES FILES !!! # Remove Makefiles (left from build) - rm -f /opt/snort/*/Makefile* - rm -f /opt/snort/*/*/Makefile* + # rm -f $root/$prefix/*/Makefile* + # rm -f $root/$prefix/*/*/Makefile* # Create a SysV init script for snort install_init snort $confdir/snort.init - - # Link snort's etc and var dirs to system's /etc and /var dirs. - # If the directory exists, make a new one with $TIMESTAMP in the name; - # this allows for more than one "version" of each directory - # so that previous configs and data are not overwritten - TIMESTAMP=`date +%y%m0%H%M` - mkdir -p /etc/opt - mkdir -p /var/opt - if [ -d /opt/snort/etc ] ; then - if [ -d /etc/opt/snort ] ; then - mv -fv /opt/snort/etc /etc/opt/snort/new$TIMESTAMP - else - mv -fv /opt/snort/etc /etc/opt/snort - fi - ln -sf /etc/opt/snort /opt/snort/etc - fi - if [ -d /opt/snort/var ] ; then - if [ -d /var/opt/snort ] ; then - mv -fv /opt/snort/var /var/opt/snort/new$TIMESTAMP - else - mv -fv /opt/snort/var /var/opt/snort - fi - ln -sf /var/opt/snort /opt/snort/var - mkdir -p /var/opt/snort/log - fi } -premake=snort_premake -postmake=snort_postmake +hook_add premake 3 snort_premake +hook_add postmake 3 snort_postmake +