From fb05e1baadb051b4e7b2d0d109881a535b98e2fe Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 6 Apr 2016 13:01:20 -0400 Subject: [PATCH 1/8] grant requires rights regardless of password --- distros/debian/postinst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/distros/debian/postinst b/distros/debian/postinst index d06f9c641..2a370e4ea 100644 --- a/distros/debian/postinst +++ b/distros/debian/postinst @@ -15,11 +15,12 @@ if [ "$1" = "configure" ]; then # 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 - 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 + echo 'grant lock tables, alter,select,insert,update,delete,create,index on zm.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql fi invoke-rc.d zoneminder stop || true 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.' From cf76360ecba9a6bb0dad10bfe0b3fac9f1b6a487 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 6 Apr 2016 13:03:24 -0400 Subject: [PATCH 2/8] bring up to date with the one in debian --- distros/ubuntu1204/zoneminder.postinst | 49 +++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/distros/ubuntu1204/zoneminder.postinst b/distros/ubuntu1204/zoneminder.postinst index e7810e468..293af766f 100644 --- a/distros/ubuntu1204/zoneminder.postinst +++ b/distros/ubuntu1204/zoneminder.postinst @@ -3,11 +3,52 @@ set -e if [ "$1" = "configure" ]; then - chown www-data:root /var/log/zm - chown www-data:www-data /var/lib/zm - if [ -z "$2" ]; then - chown www-data:www-data -R /var/cache/zoneminder + 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 + echo 'grant lock tables, alter,select,insert,update,delete,create,index on zm.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + fi + + invoke-rc.d zoneminder stop || true + 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 'mysql not found, assuming remote server.' + fi + chown www-data:www-data /var/log/zm + chown www-data:www-data /var/lib/zm/ + if [ -z "$2" ]; then + chown www-data:www-data -R /var/cache/zoneminder + fi +fi +# Ensure zoneminder is stopped... +if [ -x "/etc/init.d/zoneminder" ]; then + if invoke-rc.d zoneminder status ; then + invoke-rc.d zoneminder stop || exit $? + fi +fi + +if [ "$1" = "configure" ]; then + if [ -z "$2" ]; then + 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 + fi fi #DEBHELPER# From 699b6458d522144e92c7e995796e3931368a5fbf Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 6 Apr 2016 13:08:30 -0400 Subject: [PATCH 3/8] bring up to date with debian postinst. Will not install the db, create the user and will run zmupdate. --- distros/ubuntu1504/zoneminder.postinst | 41 +++++++++++++++++++------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/distros/ubuntu1504/zoneminder.postinst b/distros/ubuntu1504/zoneminder.postinst index 82b256e6b..812b904e3 100644 --- a/distros/ubuntu1504/zoneminder.postinst +++ b/distros/ubuntu1504/zoneminder.postinst @@ -5,11 +5,11 @@ set -e . /etc/zm/zm.conf if [ "$1" = "configure" ]; then - chown www-data:root /var/log/zm - chown www-data:www-data /var/lib/zm - if [ -z "$2" ]; then - chown www-data:www-data -R /var/cache/zoneminder - fi + chown www-data:root /var/log/zm + chown www-data:www-data /var/lib/zm + if [ -z "$2" ]; then + chown www-data:www-data -R /var/cache/zoneminder + fi # Do this every time the package is installed or upgraded # Test for database presence to avoid failure of zmupdate.pl @@ -18,12 +18,33 @@ if [ "$1" = "configure" ]; then deb-systemd-invoke stop zoneminder.service || exit $? if [ "$ZM_DB_HOST" = "localhost" ]; then - echo 'grant lock tables, create, index, alter on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - # Run the ZoneMinder update tool - zmupdate.pl --nointeractive - else + # + # 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.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + else + echo 'grant lock tables, create, index, alter on zm.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + fi + + invoke-rc.d zoneminder stop || true + 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)" - fi; + fi fi From 6199a54838d125198698ca8613109c1d9aec2ba6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 6 Apr 2016 13:45:46 -0400 Subject: [PATCH 4/8] more work, check for local db, check for existence of mysql, sync up between debian ubuntu1204 ubuntu1504 --- distros/debian/postinst | 81 ++++++++++++------------ distros/ubuntu1204/zoneminder.postinst | 85 +++++++++++++------------- distros/ubuntu1504/zoneminder.postinst | 58 ++++++++++-------- 3 files changed, 115 insertions(+), 109 deletions(-) diff --git a/distros/debian/postinst b/distros/debian/postinst index 2a370e4ea..64bedff22 100644 --- a/distros/debian/postinst +++ b/distros/debian/postinst @@ -3,52 +3,51 @@ set -e if [ "$1" = "configure" ]; 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 - echo 'grant lock tables, alter,select,insert,update,delete,create,index on zm.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - fi - invoke-rc.d zoneminder stop || true - zmupdate.pl --nointeractive - zmupdate.pl --nointeractive -f + . /etc/zm/zm.conf - 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.' - fi - chown www-data:www-data /var/log/zm - chown www-data:www-data /var/lib/zm/ + # 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 -R /var/cache/zoneminder + chown www-data:www-data -R /var/cache/zoneminder fi -fi -# Ensure zoneminder is stopped... -if [ -x "/etc/init.d/zoneminder" ]; then - if invoke-rc.d zoneminder status ; then - invoke-rc.d zoneminder stop || exit $? + + # Do this every time the package is installed or upgraded + + 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.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + else + echo 'grant lock tables, alter,select,insert,update,delete,create,index on zm.* to 'zmuser'@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 + 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.' fi -fi - -if [ "$1" = "configure" ]; then - if [ -z "$2" ]; then - 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 - zmupdate.pl - fi + echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" + fi + fi #DEBHELPER# diff --git a/distros/ubuntu1204/zoneminder.postinst b/distros/ubuntu1204/zoneminder.postinst index 293af766f..81101a1a6 100644 --- a/distros/ubuntu1204/zoneminder.postinst +++ b/distros/ubuntu1204/zoneminder.postinst @@ -3,52 +3,51 @@ set -e if [ "$1" = "configure" ]; 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 - echo 'grant lock tables, alter,select,insert,update,delete,create,index on zm.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - fi - invoke-rc.d zoneminder stop || true - zmupdate.pl --nointeractive - zmupdate.pl --nointeractive -f + . /etc/zm/zm.conf - 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.' - fi - chown www-data:www-data /var/log/zm - chown www-data:www-data /var/lib/zm/ - if [ -z "$2" ]; then - chown www-data:www-data -R /var/cache/zoneminder - fi -fi -# Ensure zoneminder is stopped... -if [ -x "/etc/init.d/zoneminder" ]; then - if invoke-rc.d zoneminder status ; then - invoke-rc.d zoneminder stop || exit $? + # 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 -R /var/cache/zoneminder + fi + + # Do this every time the package is installed or upgraded + + 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.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + else + echo 'grant lock tables, alter,select,insert,update,delete,create,index on zm.* to 'zmuser'@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 + 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.' fi -fi - -if [ "$1" = "configure" ]; then - if [ -z "$2" ]; then - 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 - fi + else + echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" + fi fi #DEBHELPER# diff --git a/distros/ubuntu1504/zoneminder.postinst b/distros/ubuntu1504/zoneminder.postinst index 812b904e3..086bda4cd 100644 --- a/distros/ubuntu1504/zoneminder.postinst +++ b/distros/ubuntu1504/zoneminder.postinst @@ -2,9 +2,11 @@ set -e -. /etc/zm/zm.conf - if [ "$1" = "configure" ]; then + + . /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 @@ -12,36 +14,42 @@ if [ "$1" = "configure" ]; then fi # Do this every time the package is installed or upgraded - # Test for database presence to avoid failure of zmupdate.pl - - # Ensure zoneminder is stopped - deb-systemd-invoke stop zoneminder.service || exit $? if [ "$ZM_DB_HOST" = "localhost" ]; 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.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql - else - echo 'grant lock tables, create, index, alter on zm.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + + 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 + deb-systemd-invoke start mysql.service || exit $? fi - invoke-rc.d zoneminder stop || true - zmupdate.pl --nointeractive - zmupdate.pl --nointeractive -f + 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.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + else + echo 'grant lock tables, alter,select,insert,update,deletecreate, index on zm.* to 'zmuser'@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 + 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.' + fi else - echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.' + echo 'mysql not found, assuming remote server.' fi + else echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)" fi From 6cdbcfc9e68790ffbebc4254a2669b91b70fa36c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 6 Apr 2016 13:55:18 -0400 Subject: [PATCH 5/8] add back identified by --- distros/debian/postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/debian/postinst b/distros/debian/postinst index 64bedff22..85bf9c164 100644 --- a/distros/debian/postinst +++ b/distros/debian/postinst @@ -29,7 +29,7 @@ if [ "$1" = "configure" ]; then 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.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + echo 'grant lock tables, alter,select,insert,update,delete,create,index on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql else echo 'grant lock tables, alter,select,insert,update,delete,create,index on zm.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql fi From 3dd010b40ad76acc4fa718a3c43320528877cc92 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 6 Apr 2016 15:44:56 -0400 Subject: [PATCH 6/8] User and and instead of defaults --- distros/ubuntu1504/zoneminder.postinst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distros/ubuntu1504/zoneminder.postinst b/distros/ubuntu1504/zoneminder.postinst index 086bda4cd..cf1c5e218 100644 --- a/distros/ubuntu1504/zoneminder.postinst +++ b/distros/ubuntu1504/zoneminder.postinst @@ -32,9 +32,9 @@ if [ "$1" = "configure" ]; then 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.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + 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,deletecreate, index on zm.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + 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 From e473839704a5243913745ebf8844b1df4ad65afe Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 6 Apr 2016 15:50:51 -0400 Subject: [PATCH 7/8] substitute ZM_DB_NAME,ZM_DB_USER and ZM_DB_PASS from zm.conf for defaults --- distros/debian/postinst | 4 ++-- distros/ubuntu1204/zoneminder.postinst | 4 ++-- distros/ubuntu1504/zoneminder.postinst | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/distros/debian/postinst b/distros/debian/postinst index 85bf9c164..8bb4d23eb 100644 --- a/distros/debian/postinst +++ b/distros/debian/postinst @@ -29,9 +29,9 @@ if [ "$1" = "configure" ]; then 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.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + 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.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + 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 diff --git a/distros/ubuntu1204/zoneminder.postinst b/distros/ubuntu1204/zoneminder.postinst index 81101a1a6..1bfd41d42 100644 --- a/distros/ubuntu1204/zoneminder.postinst +++ b/distros/ubuntu1204/zoneminder.postinst @@ -29,9 +29,9 @@ if [ "$1" = "configure" ]; then 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.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + 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.* to 'zmuser'@localhost;' | mysql --defaults-file=/etc/mysql/debian.cnf mysql + 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 diff --git a/distros/ubuntu1504/zoneminder.postinst b/distros/ubuntu1504/zoneminder.postinst index cf1c5e218..c45474e1d 100644 --- a/distros/ubuntu1504/zoneminder.postinst +++ b/distros/ubuntu1504/zoneminder.postinst @@ -32,9 +32,9 @@ if [ "$1" = "configure" ]; then 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 + 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 + 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 From 02a56b811bbaa01f54540fef1c971c807d424002 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 20 Apr 2016 14:38:51 -0400 Subject: [PATCH 8/8] Don't be recursive when chowning /var/cache/zoneminder --- distros/debian/postinst | 2 +- distros/ubuntu1204/zoneminder.postinst | 2 +- distros/ubuntu1504/zoneminder.postinst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/distros/debian/postinst b/distros/debian/postinst index 8bb4d23eb..39e3dfc32 100644 --- a/distros/debian/postinst +++ b/distros/debian/postinst @@ -10,7 +10,7 @@ if [ "$1" = "configure" ]; then chown www-data:root /var/log/zm chown www-data:www-data /var/lib/zm if [ -z "$2" ]; then - chown www-data:www-data -R /var/cache/zoneminder + chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/* fi # Do this every time the package is installed or upgraded diff --git a/distros/ubuntu1204/zoneminder.postinst b/distros/ubuntu1204/zoneminder.postinst index 1bfd41d42..7c01cdde4 100644 --- a/distros/ubuntu1204/zoneminder.postinst +++ b/distros/ubuntu1204/zoneminder.postinst @@ -10,7 +10,7 @@ if [ "$1" = "configure" ]; then chown www-data:root /var/log/zm chown www-data:www-data /var/lib/zm if [ -z "$2" ]; then - chown www-data:www-data -R /var/cache/zoneminder + chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/* fi # Do this every time the package is installed or upgraded diff --git a/distros/ubuntu1504/zoneminder.postinst b/distros/ubuntu1504/zoneminder.postinst index c45474e1d..64699d1ca 100644 --- a/distros/ubuntu1504/zoneminder.postinst +++ b/distros/ubuntu1504/zoneminder.postinst @@ -10,7 +10,7 @@ if [ "$1" = "configure" ]; then chown www-data:root /var/log/zm chown www-data:www-data /var/lib/zm if [ -z "$2" ]; then - chown www-data:www-data -R /var/cache/zoneminder + chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/* fi # Do this every time the package is installed or upgraded