From 23e92a9bcefb4b5f7a0b84920986830dafeaf0c2 Mon Sep 17 00:00:00 2001
From: Michael Hanson <hansonorders@verizon.net>
Date: Fri, 3 Dec 2010 03:22:02 +0000
Subject: monitorix: upgrade

---
 abs/extra/monitorix/PKGBUILD       | 45 ++++++++++++-------------------
 abs/extra/monitorix/monitorix.rc.d | 10 ++++---
 abs/extra/monitorix/readme.install | 54 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+), 32 deletions(-)
 create mode 100644 abs/extra/monitorix/readme.install

diff --git a/abs/extra/monitorix/PKGBUILD b/abs/extra/monitorix/PKGBUILD
index e73fcd1..d2dceec 100644
--- a/abs/extra/monitorix/PKGBUILD
+++ b/abs/extra/monitorix/PKGBUILD
@@ -1,22 +1,22 @@
-# Maintainer: graysky <da_audiophile yahoo>
+# Contributor: graysky <graysky AT archlinux dot us>
+# Contributor: res <andres87p gmail>
 
 pkgname=monitorix
-pkgver=1.4.2
-pkgrel=8
+pkgver=1.5.2
+pkgrel=1
 pkgdesc='A lightweight system monitoring tool that uses rrd databases.'
-arch=(i686)
+arch=(any)
 url=http://www.$pkgname.org/
 license=(GPL)
-depends=(dcron rrdtool lighttpd )
+depends=('rrdtool' 'perl-libwww')
 optdepends=('lm_sensors: enable support for system temp monitoring'
-'hddtemp: enable support for hdd temp monitoring')
+'hddtemp: enable support for hdd temp monitoring'
+'metamail: enable support for reports via system mail')
 
 backup=(etc/$pkgname.conf)
 source=($url$pkgname-$pkgver.tar.gz
         monitorix.rc.d)
-md5sums=('6db1bdbeeb0d128622590dfecb9694e4'
-'34e7cb2d78bb4e3ece4aeb4ed26a0d43')
-install=('monitorix.install')
+install=('readme.install')
 
 build() {
   cd $pkgname-$pkgver
@@ -24,22 +24,10 @@ build() {
   install -D $pkgname.pl $pkgdir/usr/sbin/$pkgname.pl
   install -D ../$pkgname.rc.d $pkgdir/etc/rc.d/$pkgname
 
-# use LinHES defaults
+# use Arch defaults
   sed -e '/^our $OSTYPE/ s,RHFC,Arch,' \
-      -e '/^our $TITLE/ s,FIBRANET NSP\, SL,LinHES,' \
-      -e '/^our @HDDTEMP_LIST/ s,hda,sda,' \
-      -e '/^our $ENABLE_CROND_MAIL/ s,Y,N,' \
-      -e '/^our $ENABLE_SERVU/ s,Y,N,' \
-      -e '/^our $ENABLE_PORT/ s,Y,N,' \
-      -e '/^our $ENABLE_USER/ s,Y,N,' \
-      -e '/^our $ENABLE_INT/ s,Y,N,' \
-      -e '/^our @HDDTEMP_LIST/ s,hda,sda,' \
-      -e '/^our @MNT_LIST/ s,boot,myth,' \
-      -e '/^\s*"Linux-Arch"/ s,/var/log/httpd/access.log,/var/log/httpd/access_log,' \
-      -e '/^\s*"Linux-Arch"/ s,/var/log/secure,/var/log/auth.log,' \
-      -e '/^\s*"Linux-Arch"/ s,/srv/http,/data/srv/httpd/htdocs,' < $pkgname.conf \
-                                                                        > $pkgdir/etc/$pkgname.conf
-
+      -e '/^our @HDDTEMP_LIST/ s,hda,sda,' < $pkgname.conf \
+                                           > $pkgdir/etc/$pkgname.conf
   mkdir -p $pkgdir/var/lib/$pkgname/usage
   cp -r reports $pkgdir/var/lib/$pkgname
 
@@ -47,12 +35,13 @@ build() {
   cp Changes $pkgname-apache.conf $pkgname-alert.sh README README.nginx TODO \
      $pkgdir/usr/share/doc/$pkgname
 
-  install -dm777 $pkgdir/data/srv/httpd/htdocs/$pkgname/imgs
-  cp {logo_bot,logo_top,${pkgname}ico}.png $pkgdir/data/srv/httpd/htdocs/$pkgname
+  install -dm777 $pkgdir/srv/http/$pkgname/imgs
+  cp {logo_bot,logo_top,${pkgname}ico}.png $pkgdir/srv/http/$pkgname
 
-  install -D $pkgname.cgi $pkgdir/data/srv/httpd/htdocs/cgi-bin/$pkgname.cgi
+  install -D $pkgname.cgi $pkgdir/srv/http/cgi-bin/$pkgname.cgi
 
   gzip -9 man/man5/$pkgname.conf.5
   install -Dm644 man/man5/$pkgname.conf.5.gz $pkgdir/usr/share/man/man5/$pkgname.conf.5.gz
 }
-
+sha256sums=('3d025d097fe8dd458501b8cf3345b80b1b66625ae257e21452b95d1596ec5b6d'
+            'f9ba4e09f8e583808bc9fa5476ddac067182799512e103ea40565b7da47dbab6')
diff --git a/abs/extra/monitorix/monitorix.rc.d b/abs/extra/monitorix/monitorix.rc.d
index 9649519..24eb433 100644
--- a/abs/extra/monitorix/monitorix.rc.d
+++ b/abs/extra/monitorix/monitorix.rc.d
@@ -10,15 +10,16 @@ case $1 in
     start)
         stat_busy "Starting Monitorix"
         if ck_daemon monitorix; then
-	if [ -x /etc/cron.hourly/sync-monitorix.sh ]; then
+        # check for monitorix-tmps and if present execute it
+        if [ -x /etc/cron.hourly/sync-monitorix.sh ]; then
                 /etc/cron.hourly/sync-monitorix.sh >/dev/null 2>&1
         fi
             # Creates RRDs files if needed
             /usr/sbin/monitorix.pl create >/dev/null 2>&1 || stat_die $?
             /usr/sbin/monitorix.pl init >/dev/null 2>&1 || stat_die $?
             add_daemon monitorix
-        # restart crond so data gets collected
-        /sbin/sv restart cron
+	# restart crond so data gets collected
+	/etc/rc.d/crond restart
             stat_done
         else
             stat_fail
@@ -28,13 +29,14 @@ case $1 in
     stop)
         stat_busy "Stopping Monitorix"
         if ! ck_daemon monitorix; then
+        # check for monitorix-tmps and if present execute it
         if [ -x /etc/cron.hourly/sync-monitorix.sh ]; then
                 /etc/cron.hourly/sync-monitorix.sh >/dev/null 2>&1
         fi
             /usr/sbin/monitorix.pl stop 2>&1 || stat_die $?
             rm_daemon monitorix
         # restart crond data stops getting collected
-        /sbin/sv restart cron
+        /etc/rc.d/crond restart
             stat_done
         else
             stat_fail
diff --git a/abs/extra/monitorix/readme.install b/abs/extra/monitorix/readme.install
new file mode 100644
index 0000000..2630018
--- /dev/null
+++ b/abs/extra/monitorix/readme.install
@@ -0,0 +1,54 @@
+post_install() {
+ echo '----------------------------------------------------------------------'
+ echo 'NOTE that you will need a mono-font for this package to work.'
+ echo 'There are many options here so I did not add one as a formal dep.'
+ echo 'You may use for example terminus-font.  If your graphs have no numbers'
+ echo 'go ahead and install it.  If they work as is you do not need it.'
+ echo ' '
+ echo 'Consider having your rrd databases for monitorix reside in RAM.'
+ echo 'D/L and build the monitorix-tmpfs package from the AUR:'
+ echo
+ echo '            http://aur.archlinux.org/packages.php?ID=34134'
+ echo '----------------------------------------------------------------------'
+}
+
+post_remove() {
+ echo '----------------------------------------------------------------------'
+ echo 'To remove all traces of monitorix from your system, you must manually'
+ echo 'remove the following dir trees (doing so will delete your databases):'
+ echo
+ echo '/var/lib/monitorix'
+ echo '/srv/http/monitorix'
+ echo '----------------------------------------------------------------------'
+}
+
+# $1: The new package version
+# $2: The old package version
+
+post_upgrade() {
+NEW=`echo $1 | cut -f-1 -d '-'`
+OLD=`echo $2 | cut -f-1 -d '-'`
+
+# if running the 1.4.2 series then display warning message
+
+if [ "$OLD" = "1.4.2" ]; then
+ echo '----------------------------------------------------------------------'
+ echo ' WARNING:'
+ echo
+ echo 'With this upgrade you MUST replace your current version of'
+ echo '/etc/monitorix.conf with /etc/monitorix.conf.pacnew which contains new'
+ echo 'configs needed by the 1.5.0 release of monitorix.'
+ echo
+ echo 'Simply do the following:'
+ echo '# cp /etc/monitorix.conf /etc/monitorix.conf.old'
+ echo '# mv /etc/monitorix.conf.pacnew /etc/monitorix.conf'
+ echo
+ echo 'Now you can compare your old config saved as /etc/monitorix.conf.old'
+ echo 'to your new config to ensure that you get all your config options into'
+ echo 'the new version.'
+ echo
+ echo 'Restart monitorix when you have completed the edit as well:'
+ echo '# /etc/rc.d/monitorix restart'
+ echo '----------------------------------------------------------------------'
+fi
+}
-- 
cgit v0.12