summaryrefslogtreecommitdiff
path: root/community/darkstat
diff options
context:
space:
mode:
authorMichał Masłowski <mtjm@mtjm.eu>2012-03-16 10:34:49 +0100
committerMichał Masłowski <mtjm@mtjm.eu>2012-03-16 10:34:49 +0100
commitf24ad15758f8eebcc46cb0c210f888491869d3f0 (patch)
tree85c74dd33e056502de7a306161d28f5b15b274c2 /community/darkstat
parent5f4568c7f7ba204bc047d2c74a5721f23024b339 (diff)
parent636ce8849a9c82c1787c2919ffcfe6685cb799d3 (diff)
Merge branch 'master' of ssh://parabolagnulinux.org:1863/home/parabola/abslibre-pre-mips64el
Conflicts: community/chmsee/PKGBUILD community/darkstat/PKGBUILD community/dbmail/PKGBUILD community/dvdisaster/PKGBUILD community/epic4/PKGBUILD community/fb-client/PKGBUILD community/fcrackzip/PKGBUILD community/fdupes/PKGBUILD community/flobopuyo/PKGBUILD community/intel-tbb/PKGBUILD community/openbsd-netcat/PKGBUILD community/sunpinyin/PKGBUILD community/tinc/PKGBUILD community/uudeview/PKGBUILD community/zathura/PKGBUILD core/libedit/PKGBUILD core/mkinitcpio-busybox/PKGBUILD core/openssl/PKGBUILD core/util-linux/PKGBUILD extra/lua/PKGBUILD gnome-unstable/pidgin/PKGBUILD testing/openssl/PKGBUILD testing/sudo/PKGBUILD testing/udev/PKGBUILD testing/util-linux/PKGBUILD
Diffstat (limited to 'community/darkstat')
-rw-r--r--community/darkstat/PKGBUILD25
-rwxr-xr-xcommunity/darkstat/darkstat83
-rw-r--r--community/darkstat/darkstat.conf2
-rw-r--r--community/darkstat/darkstat.install14
4 files changed, 116 insertions, 8 deletions
diff --git a/community/darkstat/PKGBUILD b/community/darkstat/PKGBUILD
index 802ca496f..254b5a9c6 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 <pupykin.s+arch@gmail.com>
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 'mips64el')
-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"
+}