diff options
-rw-r--r-- | tenshi/PKGBUILD | 45 | ||||
-rw-r--r-- | tenshi/tenshi | 62 | ||||
-rw-r--r-- | tenshi/tenshi-conf.d | 2 | ||||
-rw-r--r-- | tenshi/tenshi.install | 42 |
4 files changed, 151 insertions, 0 deletions
diff --git a/tenshi/PKGBUILD b/tenshi/PKGBUILD new file mode 100644 index 0000000..a1ec7eb --- /dev/null +++ b/tenshi/PKGBUILD @@ -0,0 +1,45 @@ +# Contributor: Ryan Corder <ryanc@greengrey.org> + +pkgname=tenshi +pkgver=0.9.1 +pkgrel=1 +pkgdesc="real-time log monitor from the Gentoo Linux project" +arch=(i686 x86_64) +license="custom" +depends=('perl') +install="$pkgname.install" +source=(http://dev.inversepath.com/tenshi/$pkgname-$pkgver.tar.gz + 'tenshi' + 'tenshi-conf.d' + 'tenshi.install') +url="http://dev.inversepath.com/trac/tenshi" +md5sums=('17a2f5f72b232b81b01f800e0e932a99' + 'c1de0e9473003f816d79e0dfb3f19a3b' + '947a195840ff67bbd558135e25c94165' + 'b1605a5f5396cf44dca3ae49c327a4e8') + +build() { + cd $startdir + chmod -R og-rwx ./ + + cd ${startdir}/src/$pkgname-$pkgver + + # create retired directories first + mkdir -m 0755 -p $startdir/pkg/usr/sbin || return 1 + mkdir -m 0750 -p $startdir/pkg/var/lib/tenshi || return 1 + mkdir -m 0750 -p $startdir/pkg/etc/tenshi || return 1 + mkdir -m 0755 -p $startdir/pkg/etc/conf.d || return 1 + mkdir -m 0755 -p $startdir/pkg/etc/rc.d || return 1 + + # install tenshi binary + install -m 755 $startdir/src/$pkgname-$pkgver/tenshi $startdir/pkg/usr/sbin || return 1 + + # install config and init file + install -m 640 $startdir/src/$pkgname-$pkgver/tenshi.conf $startdir/pkg/etc/tenshi || return 1 + install -m 644 $startdir/tenshi-conf.d $startdir/pkg/etc/conf.d/tenshi || return 1 + install -m 755 $startdir/tenshi $startdir/pkg/etc/rc.d/tenshi || return 1 + + # install docs and man pages + install -Dm 644 $startdir/src/$pkgname-$pkgver/LICENSE $startdir/pkg/usr/share/licenses/$pkgname/LICENSE || return 1 + install -Dm 644 $startdir/src/$pkgname-$pkgver/tenshi.8 $startdir/pkg/usr/man/man8/tenshi.8 || return 1 +} diff --git a/tenshi/tenshi b/tenshi/tenshi new file mode 100644 index 0000000..7ea610c --- /dev/null +++ b/tenshi/tenshi @@ -0,0 +1,62 @@ +#!/bin/bash + +# source application-specific settings +[ -f /etc/conf.d/tenshi ] && . /etc/conf.d/tenshi + +. /etc/rc.conf +. /etc/rc.d/functions + +PID=`pgrep -f /usr/sbin/tenshi` + +start() { + stat_busy "Starting Tenshi log monitor" + [ -z "$PID" ] && /usr/sbin/tenshi $TENSHI_OPTIONS + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon tenshi + stat_done + fi +} + +stop() { + stat_busy "Stopping Tenshi log monitor" + [ ! -z "$PID" ] && kill $PID + if [ $? -gt 0 ]; then + stat_fail + else + rm -f $TENSHI_PID + rm_daemon tenshi + stat_done + fi +} + +reload() { + stat_busy "Reloading Tenshi log monitor" + [ ! -z "$PID" ] && kill -HUP $PID + if [ $? -gt 0 ]; then + stat_fail + else + stat_done + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + # calling 'stop' and 'start' without the $0 fails... + $0 stop + $0 start + ;; + reload) + reload + ;; + *) + echo "usage: $0 {start|stop|restart|reload}" +esac +exit 0 diff --git a/tenshi/tenshi-conf.d b/tenshi/tenshi-conf.d new file mode 100644 index 0000000..26b87ff --- /dev/null +++ b/tenshi/tenshi-conf.d @@ -0,0 +1,2 @@ +TENSHI_PID="/var/lib/tenshi/tenshi.pid" +TENSHI_OPTIONS="-c /etc/tenshi/tenshi.conf -P $TENSHI_PID" diff --git a/tenshi/tenshi.install b/tenshi/tenshi.install new file mode 100644 index 0000000..270cd64 --- /dev/null +++ b/tenshi/tenshi.install @@ -0,0 +1,42 @@ +# $Id: $ +# +# Description: post-install script for tenshi +# Contributor: Ryan Corder <ryanc@greengrey.org> +# + +# arg 1: new package version +post_install() { + # create tenshi user + if [ -z "`grep '^tenshi:' /etc/group`" ]; then + groupadd tenshi + fi + if [ -z "`grep '^tenshi:' /etc/passwd`" ]; then + useradd -d /var/lib/tenshi -g tenshi -s /bin/false tenshi + else + usermod -s /bin/false tenshi + fi + + # set more secure permissions on config files, etc + chown -R tenshi:tenshi /etc/tenshi + chmod 640 /etc/tenshi/tenshi.conf + chown -R tenshi:tenshi /var/lib/tenshi + chmod 750 /var/lib/tenshi + chmod -R o-rwx /var/lib/tenshi +} + +# arg 1: new package version +# arg 2: old package version +post_upgrade() { + post_install $1 +} + +# arg 1: old package version +pre_remove() { + userdel tenshi &> /dev/null + groupdel tenshi &> /dev/null +} + +op=$1 +shift + +$op $* |