From 42a022d15ba94cf7fb9da6c5da06715832e64551 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 20 Jun 2017 09:41:02 -0400 Subject: [PATCH 1/3] always stop and start zoneminder on upgrade --- distros/ubuntu1604/zoneminder.postinst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/distros/ubuntu1604/zoneminder.postinst b/distros/ubuntu1604/zoneminder.postinst index a8f93c4d0..6962a5f2c 100644 --- a/distros/ubuntu1604/zoneminder.postinst +++ b/distros/ubuntu1604/zoneminder.postinst @@ -19,6 +19,8 @@ if [ "$1" = "configure" ]; then # Do this every time the package is installed or upgraded + # Ensure zoneminder is stopped + deb-systemd-invoke stop zoneminder.service || exit $? if [ "$ZM_DB_HOST" = "localhost" ]; then if [ -e "/etc/init.d/mysql" ]; then @@ -41,12 +43,8 @@ if [ "$1" = "configure" ]; then echo "grant lock tables,alter,select,insert,update,delete,create,index on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql fi - # Ensure zoneminder is stopped - deb-systemd-invoke stop zoneminder.service || exit $? zmupdate.pl --nointeractive zmupdate.pl --nointeractive -f - echo "Done Updating, starting ZoneMinder" - deb-systemd-invoke start zoneminder.service || exit $? else echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.' @@ -56,9 +54,10 @@ if [ "$1" = "configure" ]; then fi else - echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" + echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" fi - + echo "Done Updating, starting ZoneMinder" + deb-systemd-invoke start zoneminder.service || exit $? fi #DEBHELPER# From f78e720db373033f10ef74373aff117f106d717a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 20 Jun 2017 09:41:35 -0400 Subject: [PATCH 2/3] add /etc/zm and /etc/zm/conf.d to install dirs --- distros/ubuntu1204/zoneminder.dirs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/distros/ubuntu1204/zoneminder.dirs b/distros/ubuntu1204/zoneminder.dirs index 4178482c1..ff1ec7858 100644 --- a/distros/ubuntu1204/zoneminder.dirs +++ b/distros/ubuntu1204/zoneminder.dirs @@ -4,3 +4,5 @@ var/cache/zoneminder/events var/cache/zoneminder/images var/cache/zoneminder/temp usr/share/zoneminder/db +etc/zm +etc/zm/conf.d From 2e60864e99e077af263fe7da0a11e7703a7733b0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 20 Jun 2017 09:44:18 -0400 Subject: [PATCH 3/3] always stop and start zm on upgrade, not just if doing a db update --- distros/ubuntu1204/zoneminder.postinst | 78 +++++++++++++------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/distros/ubuntu1204/zoneminder.postinst b/distros/ubuntu1204/zoneminder.postinst index 9d786e27d..d01d27925 100644 --- a/distros/ubuntu1204/zoneminder.postinst +++ b/distros/ubuntu1204/zoneminder.postinst @@ -4,51 +4,51 @@ set -e if [ "$1" = "configure" ]; then - . /etc/zm/zm.conf + . /etc/zm/zm.conf - # The logs can contain passwords, etc... so by setting group root, only www-data can read them, not people in the www-data group - chown www-data:root /var/log/zm - chown www-data:www-data /var/lib/zm - if [ -z "$2" ]; then - chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/* - fi + # The logs can contain passwords, etc... so by setting group root, only www-data can read them, not people in the www-data group + chown www-data:root /var/log/zm + chown www-data:www-data /var/lib/zm + if [ -z "$2" ]; then + chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/* + fi - # Do this every time the package is installed or upgraded + # Do this every time the package is installed or upgraded + # Ensure zoneminder is stopped + invoke-rc.d zoneminder stop || true - if [ "$ZM_DB_HOST" = "localhost" ]; then - if [ -e "/etc/init.d/mysql" ]; then - # - # Get mysql started if it isn't - # - if ! $(/etc/init.d/mysql status >/dev/null 2>&1); then - invoke-rc.d mysql start - fi - if $(/etc/init.d/mysql status >/dev/null 2>&1); then - mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload - # test if database if already present... - if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null 2> /dev/null) ; then - cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf - # This creates the user. - echo "grant lock tables, alter,select,insert,update,delete,create,index on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost identified by \"${ZM_DB_PASS}\";" | mysql --defaults-file=/etc/mysql/debian.cnf mysql - else - echo "grant lock tables, alter,select,insert,update,delete,create,index on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql - fi - - # Ensure zoneminder is stopped - invoke-rc.d zoneminder stop || true - zmupdate.pl --nointeractive - zmupdate.pl --nointeractive -f - echo "Done Updating, starting ZoneMinder" - invoke-rc.d zoneminder start || true - else - echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.' - fi - else - echo 'mysql not found, assuming remote server.' + if [ "$ZM_DB_HOST" = "localhost" ]; then + if [ -e "/etc/init.d/mysql" ]; then + # + # Get mysql started if it isn't + # + if ! $(/etc/init.d/mysql status >/dev/null 2>&1); then + invoke-rc.d mysql start + fi + if $(/etc/init.d/mysql status >/dev/null 2>&1); then + mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload + # test if database if already present... + if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null 2> /dev/null) ; then + cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/debian.cnf + # This creates the user. + echo "grant lock tables, alter,select,insert,update,delete,create,index on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost identified by \"${ZM_DB_PASS}\";" | mysql --defaults-file=/etc/mysql/debian.cnf mysql + else + echo "grant lock tables, alter,select,insert,update,delete,create,index on ${ZM_DB_NAME}.* to '${ZM_DB_USER}'@localhost;" | mysql --defaults-file=/etc/mysql/debian.cnf mysql fi + + zmupdate.pl --nointeractive + zmupdate.pl --nointeractive -f + else + echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.' + fi else - echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" + echo 'mysql not found, assuming remote server.' fi + else + echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" + fi + echo "Done Updating, starting ZoneMinder" + invoke-rc.d zoneminder start || true fi #DEBHELPER#