wok-next rev 11428

Add: snort-mysql
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Thu Dec 15 10:43:50 2011 +0100 (2011-12-15)
parents 2796cc564a95
children 50e90a395ec9
files snort-mysql/receipt
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/snort-mysql/receipt	Thu Dec 15 10:43:50 2011 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="snort-mysql"
     1.7 +VERSION="2.9.1.2"
     1.8 +CATEGORY="network"
     1.9 +SHORT_DESC="Network intrusion prevention and detection system (IDS/IPS) with MySQL support."
    1.10 +MAINTAINER="pascal.bellard@slitaz.org"
    1.11 +TARBALL="$PACKAGE-$VERSION.tar.gz"
    1.12 +WEB_SITE="http://www.snort.org/"
    1.13 +WGET_URL="http://www.snort.org/downloads/1207"
    1.14 +DEPENDS="pcre libdnet libdaq libmysqlclient"
    1.15 +BUILD_DEPENDS="pcre-dev libpcap-dev libdaq-dev libdnet-dev wget zlib-dev mysql-dev"
    1.16 +
    1.17 +# Rules to configure and make the package.
    1.18 +compile_rules()
    1.19 +{
    1.20 +	cd $src
    1.21 +	./configure --prefix=/usr \
    1.22 +		--with-mysql \
    1.23 +		--enable-dynamicplugin \
    1.24 +		--enable-perfprofiling \
    1.25 +		--enable-zlib \
    1.26 +		--enable-reload \
    1.27 +	$CONFIGURE_ARGS &&
    1.28 +	make &&
    1.29 +	make DESTDIR=$PWD/_pkg install
    1.30 +}
    1.31 +
    1.32 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.33 +genpkg_rules()
    1.34 +{
    1.35 +	mkdir -p $fs/usr/lib \
    1.36 +		$fs/etc/snort/rules \
    1.37 +		$fs/usr/share/snort/schemas \
    1.38 +		$fs/var/log/snort 
    1.39 +		
    1.40 +	cp -a $_pkg/usr/bin $fs/usr
    1.41 +	cp -a $_pkg/usr/lib/snort_dynamic* $fs/usr/lib
    1.42 +	
    1.43 +	cp -a $src/etc/*.conf* $fs/etc/snort
    1.44 +	cp -a $src/etc/*.map $fs/etc/snort
    1.45 +	cp -a $src/schemas/create_mysql  $fs/usr/share/snort/schemas
    1.46 +	
    1.47 +	# Remove unwanted files
    1.48 +	rm -f $fs/usr/lib/*/*.*a
    1.49 +}
    1.50 +
    1.51 +
    1.52 +# Post install commands
    1.53 +post_install()
    1.54 +{
    1.55 +	local db_name=snort
    1.56 +	local db_pass=snort
    1.57 +	local db_schema=/usr/share/snort/create_mysql
    1.58 +
    1.59 +	echo "Processing post install commands..."
    1.60 +
    1.61 +	# addgroup snort if needed
    1.62 +    if ! grep -q snort $1/etc/group; then
    1.63 +        echo -n "Adding group Snort..."
    1.64 +        chroot $1/ /bin/addgroup snort
    1.65 +        status
    1.66 +    fi
    1.67 +    # adduser snort if needed
    1.68 +    if ! grep -q 'snort:' $1/etc/passwd; then
    1.69 +        echo -n "Adding user Snort..."
    1.70 +        chroot $1/ /bin/adduser -s /bin/false -h /dev/null \
    1.71 +            -g "Snort Daemon user" -H -D -S -G snort snort
    1.72 +        status
    1.73 +    fi
    1.74 +	chroot $1/ chown snort.snort /var/log/snort 
    1.75 +
    1.76 +	# Create database
    1.77 +        if [ -z $1 ]; then
    1.78 +                if ( ! mysqladmin -s ping > /dev/null ); then
    1.79 +                        echo "Starting MySQL server"
    1.80 +                        ( /etc/init.d/mysql start ; status  ) || exit
    1.81 +                        sleep 4 #let the mysql daemon start
    1.82 +                fi
    1.83 +                if ( ! mysql -u root -Be 'show databases' | grep -q $db_name ); then
    1.84 +                        echo -n "Create $db_name database"
    1.85 +                        mysql -Be "create database $db_name" ; 
    1.86 +                        # We suppose that user does not exist.
    1.87 +                        # It may be false.
    1.88 +                        echo  -n "Create user $db_user with password $db_pass"
    1.89 +                        mysql -Be "grant all privileges on glpi.* to $db_user@'localhost'
    1.90 +                                identified by '$db_pass'" ; status
    1.91 +                        # At last create the database for package
    1.92 +                        echo -n "Create $db_name database schema."
    1.93 +                        mysql -u $db_user -p${db_pass} $db_name < $db_schema ; status
    1.94 +
    1.95 +                fi
    1.96 +
    1.97 +        fi
    1.98 +
    1.99 +	
   1.100 +}