On Mon, Sep 06, 2010 at 08:56:38PM -0700, Vagrant Cascadian wrote:
> i think this should fix the issue and not break anything else... i tested
> install, remove, purge, upgrade from an older version...

also tested reinstall...

apparently, i didn't *really* test install... updated patch after *really*
testing it:

diff -r 447830338800 debian/postinst
--- a/debian/postinst   Mon Sep 06 14:12:17 2010 -0700
+++ b/debian/postinst   Mon Sep 06 21:50:27 2010 -0700
@@ -5,7 +5,6 @@
 VERSION=1.24.2
 
 if [ "$1" = "configure" ]; then
-       if [ -z "$2" ]; then
                #
                # Get mysql started if it isn't
                #
@@ -14,25 +13,30 @@
                fi
                if $(/etc/init.d/mysql status >/dev/null 2>&1); then
                        mysqladmin --defaults-file=/etc/mysql/debian.cnf -f 
reload
-                       cat /usr/share/zoneminder/db/zm_create.sql | mysql 
--defaults-file=/etc/mysql/debian.cnf
-                       echo 'grant lock tables, 
alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 
"zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
+                       # test if database if already present...
+                       if ! $(echo quit | mysql 
--defaults-file=/etc/mysql/debian.cnf zm > /dev/null) ; then
+                           cat /usr/share/zoneminder/db/zm_create.sql | mysql 
--defaults-file=/etc/mysql/debian.cnf
+                           echo 'grant lock tables, 
alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 
"zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
+                       fi
+
+                       # get old version from upgrade...
+                       OLD_ZM_VERSION=${2%-*}
+                       if [ -z "$OLD_ZM_VERSION" ]; then
+                               # fall back to getting version from database 
itself, which may not necessarily be accurate?
+                               OLD_ZM_VERSION=$(echo 'select Value from Config 
where Name = "ZM_DYN_CURR_VERSION";' | mysql 
--defaults-file=/etc/mysql/debian.cnf zm | egrep -v Value)
+                       fi
+                       if [ -n "$OLD_ZM_VERSION" ] && [ "$OLD_ZM_VERSION" != 
"$VERSION" ] ; then
+                               echo 'grant lock tables, alter on zm.* to 
'zmuser'@localhost identified by "zmpass";' | mysql 
--defaults-file=/etc/mysql/debian.cnf mysql
+                               # stop zoneminder before performing database 
upgrade.
+                               invoke-rc.d zoneminder stop || true
+                               zmupdate.pl --version $OLD_ZM_VERSION 
+                       fi
+
                else
                        echo 'NOTE: mysql not running, please start mysql and 
run dpkg-reconfigure zoneminder when it is running.'
                fi
                chown www-data:www-data /var/log/zm
                chown www-data:www-data /var/lib/zm/
                chown www-data:www-data -R /var/cache/zoneminder
-    else
-               chown www-data:www-data /var/log/zm
-               if $(/etc/init.d/mysql status >/dev/null 2>&1); then
-               echo 'grant lock tables, alter on zm.* to 'zmuser'@localhost 
identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
-            OLD_ZM_VERSION=${2%-*}
-            if [ "$OLD_ZM_VERSION" != "$VERSION" ] ; then
-                zmupdate.pl --version $OLD_ZM_VERSION 
-            fi
-               else
-                       echo 'NOTE: mysql not running, please start mysql and 
run dpkg-reconfigure zoneminder when it is running.'
-               fi
-       fi
 fi
 #DEBHELPER#
diff -r 447830338800 debian/postrm
--- a/debian/postrm     Mon Sep 06 14:12:17 2010 -0700
+++ b/debian/postrm     Mon Sep 06 21:50:27 2010 -0700
@@ -1,7 +1,7 @@
 #! /bin/sh
 # set -e # to be reinstated later
 
-if [ "$1" = "remove" ]; then
+if [ "$1" = "purge" ]; then
        echo 'delete from user where User="zmuser";' | mysql 
--defaults-file=/etc/mysql/debian.cnf mysql 
        echo 'delete from db where User="zmuser";' | mysql 
--defaults-file=/etc/mysql/debian.cnf mysql
        mysqladmin --defaults-file=/etc/mysql/debian.cnf -f drop zm


live well,
  vagrant



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to