From 14635ca5380a480450a66c3fcc29992d29a2bd8e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 15 Mar 2012 00:01:19 +0000 Subject: Thu Mar 15 00:01:19 UTC 2012 --- community/darkstat/PKGBUILD | 25 +++++++---- community/darkstat/darkstat | 83 +++++++++++++++++++++++++++++++++++++ community/darkstat/darkstat.conf | 2 + community/darkstat/darkstat.install | 14 +++++++ 4 files changed, 116 insertions(+), 8 deletions(-) create mode 100755 community/darkstat/darkstat create mode 100644 community/darkstat/darkstat.conf create mode 100644 community/darkstat/darkstat.install (limited to 'community/darkstat') diff --git a/community/darkstat/PKGBUILD b/community/darkstat/PKGBUILD index 87fd7fbf2..43247106d 100644 --- a/community/darkstat/PKGBUILD +++ b/community/darkstat/PKGBUILD @@ -1,24 +1,33 @@ -# $Id: PKGBUILD 65108 2012-02-20 04:47:59Z spupykin $ +# $Id: PKGBUILD 67650 2012-03-13 15:19:52Z spupykin $ # Maintainer: Sergej Pupykin pkgname=darkstat -pkgver=3.0.714 -pkgrel=2 +pkgver=3.0.715 +pkgrel=1 pkgdesc="Network statistics gatherer (packet sniffer)." url="http://dmr.ath.cx/net/darkstat/" license=("GPL") arch=(i686 x86_64) -depends=('libpcap' 'zlib') -source=(http://dmr.ath.cx/net/darkstat/$pkgname-$pkgver.tar.bz2) -md5sums=('eef385fadc8dbb611d3d4c4d8fa94817') +depends=('libpcap' 'zlib' 'gcc-libs') +source=(http://dmr.ath.cx/net/darkstat/darkstat-$pkgver.tar.bz2 + darkstat + darkstat.conf) +install=darkstat.install +md5sums=('5b7abc7538dcd8e30667dac150e81d77' + '1021f95fabe16cfab4c95f6264d535e5' + 'aa9a9effd1e8f08860afcd6439fc94c5') build() { - cd $srcdir/$pkgname-$pkgver + cd $srcdir/darkstat-$pkgver ./configure --prefix=/usr make } package() { - cd $srcdir/$pkgname-$pkgver + cd $srcdir/darkstat-$pkgver make DESTDIR=$pkgdir install + + # darkstat script + install -D -m755 "$srcdir"/darkstat "$pkgdir"/etc/rc.d/darkstat + install -D -m644 "$srcdir"/darkstat.conf "$pkgdir"/etc/conf.d/darkstat.conf } diff --git a/community/darkstat/darkstat b/community/darkstat/darkstat new file mode 100755 index 000000000..26df1761a --- /dev/null +++ b/community/darkstat/darkstat @@ -0,0 +1,83 @@ +#!/bin/bash + +daemon_bin="/usr/sbin/darkstat" +daemon_name=$(basename $daemon_bin) +daemon_chroot=/var/$daemon_name +daemon_database="$daemon_name.dat" +daemon_output="$daemon_chroot/$daemon_name.out" +PIDF="$daemon_chroot/$daemon_name.pid" + +. /etc/rc.conf +. /etc/rc.d/functions +. /etc/conf.d/$daemon_name.conf + +get_pid() { + pidof -o %PPID $daemon_name +} + +case "$1" in + start) + stat_busy "Starting $daemon_name daemon" + + PID=$(get_pid) + if [ -z "$PID" ]; then + [ -f $PIDF ] && rm -f $PIDF + # RUN + $daemon_bin --user "$daemon_name" --chroot "$daemon_chroot" \ + --import "$daemon_database" \ + --export "$daemon_database" \ + --pidfile "$(basename $PIDF)" \ + -i "$DARKSTAT_IFACE" \ + $DARKSTAT_ARGS \ + 2>&1 | tee "$daemon_output" + ret=$? + grep -q error "$daemon_output" 2>/dev/null + error_output=$? + rm -f "$daemon_output" + # + if [ $ret -gt 0 -o $error_output -eq 0 ] ; then + stat_fail + rm -f "$PIDF" + exit 1 + else + add_daemon $daemon_name + stat_done + fi + else + stat_fail + exit 1 + fi + ;; + + stop) + stat_busy "Stopping $daemon_name daemon" + PID=$(get_pid) + # KILL + [ ! -z "$PID" ] && kill $PID &> /dev/null + # + if [ $? -gt 0 ]; then + stat_fail + exit 1 + else + rm -f $PIDF &> /dev/null + rm_daemon $daemon_name + stat_done + fi + ;; + + restart) + $0 stop + sleep 3 + $0 start + ;; + + status) + stat_busy "Checking $daemon_name status"; + ck_status $daemon_name + ;; + + *) + echo "usage: $0 {start|stop|restart|status}" +esac + +exit 0 diff --git a/community/darkstat/darkstat.conf b/community/darkstat/darkstat.conf new file mode 100644 index 000000000..63517ef9a --- /dev/null +++ b/community/darkstat/darkstat.conf @@ -0,0 +1,2 @@ +DARKSTAT_IFACE="eth0" +DARKSTAT_ARGS="" diff --git a/community/darkstat/darkstat.install b/community/darkstat/darkstat.install new file mode 100644 index 000000000..a92bba909 --- /dev/null +++ b/community/darkstat/darkstat.install @@ -0,0 +1,14 @@ +daemon_name=darkstat +daemon_chroot=/var/"$daemon_name" + +post_install() { + /usr/sbin/useradd -s /bin/false -r -N -g nobody "$daemon_name" + if [ ! -d "$daemon_chroot" ]; then + install -d "$daemon_chroot" + fi + chown -R "$daemon_name":nobody "$daemon_chroot" +} + +post_remove() { + /usr/sbin/userdel "$daemon_name" +} -- cgit v1.2.3-54-g00ecf