pkgname=hobbitserver
provides=hobbit
pkgver=4.2.0
pkgrel=103
pkgdesc="Hobbit is a system for monitoring servers and networks. "
license="GPL"
arch=('i686')

url="http://hobbitmon.sourceforge.net/"
source=(http://voxel.dl.sourceforge.net/sourceforge/hobbitmon/hobbit-4.2.0.tar.gz  hobbitadd.py hobbitcheck.sh hobbitgraph.cfg.diff hobbitserver.cfg.diff hobbitlaunch.cfg.diff clientlaunch.cfg.diff hobbitstorage.py  hbnotes.py hobbit-myth-orphan.sh hobbit-clients.cfg hbfunc.py be.png tuner.png tv.png  hobbit-mem-myth.sh hobbit_notify.sh hobbit-alerts.cfg hobbit_myth_data.py)
depends=(rrdtool fping pcre python graphviz)
install=hobbit.install

build() {
cd $startdir/src/hobbit-$pkgver
ENABLESSL=n \
ENABLELDAP=n \
ENABLELDAPSSL=n \
BBUSER=nobody \
BBTOPDIR=/data/srv/hobbit \
BBVAR=/data/srv/hobbit/var \
BBHOSTURL=/hobbit \
CGIDIR=/data/srv/httpd/htdocs/hobbit/hobbit-cgi \
BBCGIURL=/hobbit/hobbit-cgi \
SECURECGIDIR=/data/srv/httpd/htdocs/hobbit/hobbit-seccgi \
SECUREBBCGIURL=/hobbit/hobbit-seccgi \
HTTPDGID=nobody \
BBLOGDIR=/var/log/hobbit \
BBHOSTNAME=localhost \
BBHOSTIP=127.0.0.1 \
MANROOT=/usr/share/man \
BARS=all \
USENEWHIST=y \
PIXELCOUNT=960 \
INSTALLBINDIR=/data/srv/hobbit/server/bin \
INSTALLETCDIR=/data/srv/hobbit/etc \
INSTALLWEBDIR=/data/srv/hobbit/web \
INSTALLEXTDIR=/data/srv/hobbit/server/ext \
INSTALLTMPDIR=/data/srv/hobbit/tmp \
INSTALLWWWDIR=/data/srv/httpd/htdocs/hobbit/ \
USERFPING=/usr/sbin/fping \
./configure
	make PKGBUILD=1|| return 1
	make PKGBUILD=1 INSTALLROOT=$startdir/pkg install

cd $startdir/src
cp $startdir/src/hobbitadd.py  $startdir/pkg/data/srv/hobbit/server/bin/
install -D -m755 $startdir/src/hobbitstorage.py  $startdir/pkg/data/srv/hobbit/server/ext/hobbitstorage.py
install -D -m755 $startdir/src/hobbit-myth-orphan.sh $startdir/pkg/data/srv/hobbit/server/ext/hobbit-myth-orphan.sh
install -D -m755 $startdir/src/hbfunc.py $startdir/pkg/data/srv/hobbit/server/ext/hbfunc.py
install -D -m755 $startdir/src/hbnotes.py $startdir/pkg/data/srv/hobbit/server/ext/hbnotes.py
    install -D -m755 $startdir/src/hobbit_myth_data.py $startdir/pkg/data/srv/hobbit/server/ext/hobbit_myth_data.py
install -D -m755 $startdir/src/hobbit-mem-myth.sh $startdir/pkg/data/srv/hobbit/server/ext/hobbit-mem-myth.sh
install -D -m755  hobbitcheck.sh $startdir/pkg/etc/cron.tenminutes/hobbitcheck.sh
install  -m755 hobbit-clients.cfg $startdir/pkg/data/srv/hobbit/etc/hobbit-clients.cfg
install  -m755 hobbit-alerts.cfg $startdir/pkg/data/srv/hobbit/etc/hobbit-alerts.cfg
install  -m755 hobbit_notify.sh $startdir/pkg/data/srv/hobbit/server/bin/hobbit_notify.sh

install  -m755 $startdir/src/tv.png  $startdir/pkg/data/srv/httpd/htdocs/hobbit/gifs/tv.png
install  -m755 $startdir/src/tuner.png  $startdir/pkg/data/srv/httpd/htdocs/hobbit/gifs/tuner.png
install  -m755 $startdir/src/be.png  $startdir/pkg/data/srv/httpd/htdocs/hobbit/gifs/be.png


#apply patches to conf file

cd $startdir/pkg/data/srv/hobbit/etc
patch -p0 <  $startdir/src/hobbitgraph.cfg.diff
patch -p0 <  $startdir/src/hobbitserver.cfg.diff
patch -p0 <  $startdir/src/hobbitlaunch.cfg.diff


cd -
cd $startdir/pkg/data/srv/hobbit/client/etc
patch -p0 <  $startdir/src/clientlaunch.cfg.diff
cd -



#create client package as well
install -D -m755 $startdir/src/hobbit-mem-myth.sh $startdir/pkg/data/srv/hobbit/client/ext/hobbit-mem-myth.sh
cp -rp /$startdir/pkg/data/srv/hobbit/client $startdir/../hobbit-client

}