From 355f5d31dfb3bf803bfd20c9ba6537405c59aba4 Mon Sep 17 00:00:00 2001
From: Michael Hanson <hansonorders@verison.net>
Date: Fri, 19 Mar 2010 23:39:48 +0000
Subject: network-ups-tools: initial inclusion.  Needs testing. Ref: FS#512

---
 .../community/network-ups-tools/PKGBUILD           | 53 ++++++++++++++++++++++
 .../community/network-ups-tools/finish             | 17 +++++++
 .../community/network-ups-tools/nut.install        | 20 ++++++++
 abs/extra-testing/community/network-ups-tools/run  | 17 +++++++
 4 files changed, 107 insertions(+)
 create mode 100644 abs/extra-testing/community/network-ups-tools/PKGBUILD
 create mode 100644 abs/extra-testing/community/network-ups-tools/finish
 create mode 100644 abs/extra-testing/community/network-ups-tools/nut.install
 create mode 100644 abs/extra-testing/community/network-ups-tools/run

diff --git a/abs/extra-testing/community/network-ups-tools/PKGBUILD b/abs/extra-testing/community/network-ups-tools/PKGBUILD
new file mode 100644
index 0000000..515adf8
--- /dev/null
+++ b/abs/extra-testing/community/network-ups-tools/PKGBUILD
@@ -0,0 +1,53 @@
+# $Id: PKGBUILD 12757 2010-03-13 04:22:57Z dgriffiths $
+# Maintainer: Roman Kyrylych <roman@archlinux.org>
+# Contributor: Giuseppe Lucarelli <luk@rebelsoft.org>
+
+pkgname=network-ups-tools
+pkgver=2.4.3
+pkgrel=1
+pkgdesc="NUT is a collection of programs for monitoring and administering UPS hardware"
+arch=('i686' 'x86_64')
+url="http://www.networkupstools.org/"
+license=('GPL2')
+depends=('openssl' 'hal' 'gd')
+makedepends=('libusb')
+backup=(etc/ups/{ups.conf,upsd.conf,upsd.users,upsmon.conf,upssched.conf})
+install=nut.install
+source=(http://www.networkupstools.org/source/2.4/nut-$pkgver.tar.gz run finish)
+options=('!emptydirs' '!libtool')
+
+build() {
+cd $srcdir/nut-$pkgver
+./configure --with-user=nut \
+--prefix=/usr \
+--datadir=/usr/share/ups \
+--sysconfdir=/etc/ups \
+--with-group=nut \
+--with-hal \
+--with-usb \
+--with-cgi \
+--with-cgipath=/usr/share/webapps/nut \
+--with-htmlpath=/usr/share/webapps/nut \
+--with-udev-dir=/etc/udev || return 1
+
+  make || return 1
+  make DESTDIR=$pkgdir install
+  #ugly hack because --with-pkgconfig-dir doesn't work
+  install -D -m644 lib/libupsclient.pc $pkgdir/usr/lib/pkgconfig
+
+  install -D -m644 conf/ups.conf.sample $pkgdir/etc/ups/ups.conf
+  install -D -m640 conf/upsd.conf.sample $pkgdir/etc/ups/upsd.conf
+  install -D -m640 conf/upsd.users.sample $pkgdir/etc/ups/upsd.users
+  install -D -m640 conf/upsmon.conf.sample $pkgdir/etc/ups/upsmon.conf
+  install -D -m644 conf/upssched.conf.sample $pkgdir/etc/ups/upssched.conf
+  install -D -m755 ../run $pkgdir/etc/sv/upsd/run || return 1
+  install -D -m755 ../finish $pkgdir/etc/sv/upsd/finish || return 1
+
+  # Fix udev rules
+  sed -i "s|SYSFS|ATTRS|g" $pkgdir/etc/udev/rules.d/52-nut-usbups.rules
+  install -dm755 ${pkgdir}/lib
+  mv ${pkgdir}/etc/udev ${pkgdir}/lib
+}
+md5sums=('6f893b61b07915e7a139324fa3f79121'
+         '81cfad544c6342125057f9cb978515fb'
+         'b5b2e266774acfbc80e64ddfbd4057ee')
diff --git a/abs/extra-testing/community/network-ups-tools/finish b/abs/extra-testing/community/network-ups-tools/finish
new file mode 100644
index 0000000..d031d4e
--- /dev/null
+++ b/abs/extra-testing/community/network-ups-tools/finish
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PID=`pidof -o %PPID /usr/sbin/upsd`
+
+                stat_runit "Stopping UPSd Daemon"
+		/usr/bin/upsdrvctl stop &> /dev/null
+		/usr/sbin/upsmon -c stop &> /dev/null
+                [ ! -z "$PID" ] && kill $PID &> /dev/null
+                if [ $? -gt 0 ]; then
+                        stat_fail
+                else
+                        rm_daemon upsd
+                        stat_done
+                fi
diff --git a/abs/extra-testing/community/network-ups-tools/nut.install b/abs/extra-testing/community/network-ups-tools/nut.install
new file mode 100644
index 0000000..5bec199
--- /dev/null
+++ b/abs/extra-testing/community/network-ups-tools/nut.install
@@ -0,0 +1,20 @@
+post_install() {
+  groupadd -g 55 nut &> /dev/null
+  useradd -u 55 -g nut -G tty -d /var/state/ups -s /bin/false nut >/dev/null 2>&1
+  mkdir -p /var/state/ups/
+  chmod 0770 /var/state/ups/
+  chown root:nut /var/state/ups/
+  chown root:nut /etc/ups/upsd.conf /etc/ups/upsd.users /etc/ups/upsmon.conf
+  echo ">>> Before starting your UPSd daemon, you must"
+  echo ">>> edit /etc/ups/ups.conf in order to set your"
+  echo ">>> UPS driver and port."
+  echo ">>> Then add upsd as a service."
+  echo ">>> $ sudo add_service.sh upsd."
+}
+
+pre_remove() {
+  remove_service.sh upsd
+  userdel nut >/dev/null 2>&1
+  groupdel nut >/dev/null 2>&1
+  rm -rf /var/state/ups/
+}
diff --git a/abs/extra-testing/community/network-ups-tools/run b/abs/extra-testing/community/network-ups-tools/run
new file mode 100644
index 0000000..f549950
--- /dev/null
+++ b/abs/extra-testing/community/network-ups-tools/run
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PID=`pidof -o %PPID /usr/sbin/upsd`
+
+                stat_runit "Starting UPSd Daemon"
+		/usr/bin/upsdrvctl start &> /dev/null
+                [ -z "$PID" ] && /usr/sbin/upsd -f &>/dev/null
+                /usr/sbin/upsmon &>/dev/null
+                if [ $? -gt 0 ]; then
+                        stat_fail
+                else
+                        add_daemon upsd
+                        stat_done
+                fi
-- 
cgit v0.12

