2014-11-26 05:09:55 +08:00
#! /bin/sh
set -e
if [ "$1" = "configure" ]; then
2014-11-28 22:38:45 +08:00
if [ -e "/etc/init.d/mysql" ]; then
#
2014-11-28 22:37:35 +08:00
# Get mysql started if it isn't
2014-11-28 22:38:45 +08:00
#
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
2014-11-26 05:09:55 +08:00
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 on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/debian.cnf mysql
fi
2014-11-28 03:21:56 +08:00
deb-systemd-invoke stop zoneminder.service || true
2014-11-26 05:09:55 +08:00
zmupdate.pl --nointeractive
else
echo 'NOTE: mysql not running, please start mysql and run dpkg-reconfigure zoneminder when it is running.'
fi
2014-11-28 22:38:45 +08:00
else
2014-11-28 22:36:06 +08:00
echo 'mysql not found, assuming remote server.'
fi
2014-11-26 05:09:55 +08:00
chown www-data:www-data /var/log/zm
chown www-data:www-data /var/lib/zm/
if [ -z "$2" ]; then
2014-11-28 22:38:45 +08:00
chown www-data:www-data -R /var/cache/zoneminder
2014-11-26 05:09:55 +08:00
fi
fi
# Ensure zoneminder is stopped...
2014-11-28 03:21:56 +08:00
deb-systemd-invoke stop zoneminder.service || exit $?
2014-11-26 05:09:55 +08:00
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
fi
#DEBHELPER#