tags 497107 patch thanks i think this should fix the issue and not break anything else... i tested install, remove, purge, upgrade from an older version...
changeset: 42:49836da188a6 tag: tip user: Vagrant Cascadian <vagr...@freegeek.org> date: Mon Sep 06 19:58:58 2010 -0700 files: debian/postinst debian/postrm description: Only remove database on purge, which requires only creating the database if it doesn't already exist, and upgrading the database if the version is old enough. hopefully, this fixes: http://bugs.debian.org/497107 changeset: 43:3f6ff8237340 tag: tip user: Vagrant Cascadian <vagr...@freegeek.org> date: Mon Sep 06 20:51:43 2010 -0700 files: debian/postinst description: only grant the user privledges if the upgraded is needed. diff -r 28d4a228d6e7 debian/postinst --- a/debian/postinst Mon Sep 06 14:11:24 2010 -0700 +++ b/debian/postinst Mon Sep 06 20:53:07 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,28 @@ 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) + fi + if [ "$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 + 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 28d4a228d6e7 debian/postrm --- a/debian/postrm Mon Sep 06 14:11:24 2010 -0700 +++ b/debian/postrm Mon Sep 06 20:53:07 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 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org