From cd795551be430c3d398b0b80e3d9c91820aaed61 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sat, 22 Dec 2012 09:56:19 -0600
Subject: supplemental_web: fix wakeonlan.sh  to account for the change in mac
 address location in xymon, also added etherwake.

---
 abs/core/supplemental-web/PKGBUILD               | 17 +++++++++++------
 abs/core/supplemental-web/supplemental_web.rules |  2 ++
 abs/core/supplemental-web/wakeonlan.sh           | 17 +++++++++++------
 3 files changed, 24 insertions(+), 12 deletions(-)
 create mode 100644 abs/core/supplemental-web/supplemental_web.rules

diff --git a/abs/core/supplemental-web/PKGBUILD b/abs/core/supplemental-web/PKGBUILD
index f582cc1..d3f82d7 100644
--- a/abs/core/supplemental-web/PKGBUILD
+++ b/abs/core/supplemental-web/PKGBUILD
@@ -1,11 +1,11 @@
 pkgbase=supplemental-web
 pkgname=('supplemental-web' 'supplemental-web-slave')
 pkgver=1.0
-pkgrel=33
+pkgrel=36
 arch=('i686' 'x86_64')
 
 backup=('extra.cfg.txt')
-source=(lighttpd-supplement.conf extra.cfg.txt wakeonlan.sh slaveserve.py supplemental_slave.rules )
+source=(lighttpd-supplement.conf extra.cfg.txt wakeonlan.sh slaveserve.py supplemental_slave.rules supplemental_web.rules )
 
 build(){
     cd $startdir/src
@@ -30,11 +30,11 @@ build(){
 
 package_supplemental-web() {
     pkgdesc="supplemental-web package for master backend"
-    depends=('lighttpd'  'php' 'fcgi' 'python2' 'xymonserver' 'certmaster' 'func' 'python_aosd'  'LinHES-system>=2-50')
+    depends=('wol' 'etherwake' 'lighttpd'  'php' 'fcgi' 'python2' 'xymonserver' 'certmaster' 'func' 'python_aosd'  'LinHES-system>=2-50')
     install=supplemental-web.install
 
     cd $startdir/src
-    MVDIR=$pkgdir/pkg/usr/MythVantage
+    MVDIR=$pkgdir/usr/MythVantage
     mkdir -p $MVDIR/etc
     install -m755 -D lighttpd-supplement.conf $pkgdir/etc/gen_light_conf.d/lighttpd-supplement.conf
     install -m755 -D wakeonlan.sh $MVDIR/bin/wakeonlan.sh
@@ -47,6 +47,10 @@ package_supplemental-web() {
     cp -rp cgi $pkgdir/data/srv/httpd/
     cd $startdir/src
     install -m755 -D extra.cfg.txt $pkgdir/data/srv/httpd/cgi/extra.cfg.txt
+    #sudo rules
+    install -D -m400 $startdir/src/supplemental_web.rules $pkgdir/etc/sudoers.d/supplemental_web
+    chmod 750 $pkgdir/etc/sudoers.d
+
     }
 
 package_supplemental-web-slave() {
@@ -72,6 +76,7 @@ package_supplemental-web-slave() {
 
 md5sums=('521714803b5a3df529f0fc5f853c0d55'
          '3d8c7b430c1319d706ca420825918d2a'
-         '81cdb6ee6804fa36366c6e259a80e7b4'
+         '26598fd1dfaf5d36d7b1f9620da5543c'
          'fabf825ca07502db40d78f0aae15f90b'
-         'b41eeb0f0aa67ea06aedff61e53fa774')
+         'b41eeb0f0aa67ea06aedff61e53fa774'
+         'c90d7a015783316af2256a37bece62ce')
diff --git a/abs/core/supplemental-web/supplemental_web.rules b/abs/core/supplemental-web/supplemental_web.rules
new file mode 100644
index 0000000..f4d477b
--- /dev/null
+++ b/abs/core/supplemental-web/supplemental_web.rules
@@ -0,0 +1,2 @@
+#These rules are used by supplemental-web
+http    ALL = NOPASSWD:/usr/sbin/etherwake
diff --git a/abs/core/supplemental-web/wakeonlan.sh b/abs/core/supplemental-web/wakeonlan.sh
index 1213f79..7734401 100644
--- a/abs/core/supplemental-web/wakeonlan.sh
+++ b/abs/core/supplemental-web/wakeonlan.sh
@@ -1,12 +1,17 @@
 #!/bin/bash
-HWADDR=`curl  -s  http://localhost/xymon/hobbit-cgi/svcstatus.sh?CLIENT=$1|grep HWaddr|tr -s [:space:]| cut -d" " -f5|uniq`
-
-#for mac in `grep HW "$DIR/$FILE" |awk '{ print $5 } '`
+echo "Wake on lan attempt for $1"
+HWADDR=`curl  -s  http://localhost/xymon/hobbit-cgi/svcstatus.sh?CLIENT=$1|grep ether|grep txq|tr -s [:space:]| cut -d" " -f3|uniq`
 for mac in $HWADDR
 do
-	echo "/usr/bin/wol -v $mac"
-	/usr/bin/wol -v $mac
+    echo
+    echo "####################################################"
+    echo "wol:  $mac"
+    /usr/bin/wol -v $mac
+    echo
+    echo "etherwake: $mac "
+    sudo /usr/sbin/etherwake -D $mac 2>&1
+    echo "####################################################"
 done
-	
+
 
 
-- 
cgit v0.12

