From 317075f448a7f47d66976273d4c9ae23b1c663dc Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Sat, 20 Dec 2014 17:51:33 +0000
Subject: zoneminder: forgot to mod .install

---
 abs/core/zoneminder/PKGBUILD           |  2 +-
 abs/core/zoneminder/zoneminder.install | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/abs/core/zoneminder/PKGBUILD b/abs/core/zoneminder/PKGBUILD
index 75b3301..a6402e8 100644
--- a/abs/core/zoneminder/PKGBUILD
+++ b/abs/core/zoneminder/PKGBUILD
@@ -11,7 +11,7 @@
 pkgbase=zoneminder
 pkgname=zoneminder
 pkgver=1.28.0
-pkgrel=1
+pkgrel=2
 pkgdesc='Capture, analyse, record and monitor video security cameras'
 arch=( i686 x86_64 mips64el arm )
      
diff --git a/abs/core/zoneminder/zoneminder.install b/abs/core/zoneminder/zoneminder.install
index 0a1f557..1d450aa 100644
--- a/abs/core/zoneminder/zoneminder.install
+++ b/abs/core/zoneminder/zoneminder.install
@@ -1,3 +1,20 @@
+install_db() {
+    . /etc/systemconfig
+    if [ $SystemType = Master_backend -o  $SystemType = Standalone ]
+    then
+        mysql -e "use zm" > /dev/null
+        rc=$?
+        if [ $rc = 1 ]
+        then
+            echo "Installing zoneminder database zm"
+            cat /usr/share/zoneminder/db/zm_create.sql | mysql
+            echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql
+        fi
+    else
+        echo "Will only init the database for  StandAlone or Master_backend LinHES systems"
+    fi
+    }
+
 pre_install() {
     set -e
     abort=false
@@ -78,6 +95,13 @@ post_install() {
     \|^Include /etc/httpd/conf/extra/httpd-zoneminder.conf$|d;
     s|^# Server-pool management (MPM specific)$|\nInclude /etc/httpd/conf/extra/httpd-zoneminder.conf\n&|;    
     ' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.zoneminder
+
+    #---LinHES Stuff
+    usermod -G video http
+    install_db
+    gen_light_include.py
+    /sbin/sv hup /service/lighttpd
+    #---
     
     cat << EOF
 Note for mysql:
@@ -123,6 +147,10 @@ EOF
 post_upgrade() {
     post_install
     /usr/bin/zmupdate.pl -f >/dev/null
+    #---LinHES Stuff
+    gen_light_include.py
+    /sbin/sv hup /service/lighttpd
+    #--
 }
 
 post_remove() {
@@ -138,6 +166,10 @@ post_remove() {
     # /Include \/etc\/httpd\/conf\/extra\/httpd-zoneminder.conf/d;
     # ' /etc/httpd/conf/httpd.conf || read
 
+    #---LinHES Stuff
+    gen_light_include.py
+    /sbin/sv hup /service/lighttpd
+    #--
     cat << EOF
 Note:
 ==> To clean Zoneminder mysql database, run as root (with password):
-- 
cgit v0.12