whitespace to google code style specs. 2 spaces
This commit is contained in:
parent
aa0a831223
commit
a73a7b438c
|
@ -4,79 +4,79 @@ set -e
|
|||
|
||||
if [ "$1" = "configure" ]; then
|
||||
|
||||
. /etc/zm/zm.conf
|
||||
for CONFFILE in /etc/zm/conf.d/*.conf; do
|
||||
. "$CONFFILE"
|
||||
done
|
||||
|
||||
# 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
|
||||
if [ ! -e "/etc/apache2/mods-enabled/cgi.load" ] && [ "$(command -v a2enmod)" != "" ]; then
|
||||
echo "The cgi module is not enabled in apache2. I am enabling it using a2enmod cgi."
|
||||
a2enmod cgi
|
||||
fi
|
||||
|
||||
# Do this every time the package is installed or upgraded
|
||||
|
||||
# Ensure zoneminder is stopped
|
||||
deb-systemd-invoke stop zoneminder.service
|
||||
if [ "$ZM_DB_HOST" = "localhost" ]; then
|
||||
if [ -e "/lib/systemd/system/mysql.service" ] || [ -e "/lib/systemd/system/mariadb.service" ]; then
|
||||
|
||||
#
|
||||
# Get mysql started if it isn't running
|
||||
#
|
||||
$(systemctl status mysql.service >/dev/null 2>&1); MYSQL_STATUS=$?
|
||||
$(systemctl status mariadb.service >/dev/null 2>&1); MARIADB_STATUS=$?
|
||||
|
||||
# 3 = inactive, 4 = nonexistant
|
||||
if [ "$MARIADB_STATUS" != "4" ]; then
|
||||
DBSERVICE="mariadb.service"
|
||||
else
|
||||
DBSERVICE="mysql.service"
|
||||
fi
|
||||
|
||||
if [ "$MYSQL_STATUS" != "0" ] && [ "$MARIADB_STATUS" != "0" ]; then
|
||||
# 3 = inactive, 4 = nonexistant
|
||||
# Due to /etc/init.d service autogeneration, mysql.service always returns the status of mariadb.service
|
||||
# However, mariadb.service will not return the status of mysql.service.
|
||||
deb-systemd-invoke start $DBSERVICE
|
||||
fi
|
||||
|
||||
# Make sure systemctl status exit code is 0; i.e. the DB is running
|
||||
if systemctl status "$DBSERVICE" >/dev/null 2>&1; then
|
||||
mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload
|
||||
# test if database if already present...
|
||||
if ! $(echo quit | mysql 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 mysql
|
||||
fi
|
||||
|
||||
zmupdate.pl --nointeractive
|
||||
zmupdate.pl --nointeractive -f
|
||||
|
||||
# Add any new PTZ control configurations to the database (will not overwrite)
|
||||
zmcamtool.pl --import >/dev/null 2>&1
|
||||
|
||||
else
|
||||
echo 'NOTE: MySQL/MariaDB not running; please start mysql and run dpkg-reconfigure zoneminder when it is running.'
|
||||
fi
|
||||
. /etc/zm/zm.conf
|
||||
for CONFFILE in /etc/zm/conf.d/*.conf; do
|
||||
. "$CONFFILE"
|
||||
done
|
||||
|
||||
# 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
|
||||
if [ ! -e "/etc/apache2/mods-enabled/cgi.load" ] && [ "$(command -v a2enmod)" != "" ]; then
|
||||
echo "The cgi module is not enabled in apache2. I am enabling it using a2enmod cgi."
|
||||
a2enmod cgi
|
||||
fi
|
||||
|
||||
# Do this every time the package is installed or upgraded
|
||||
|
||||
# Ensure zoneminder is stopped
|
||||
deb-systemd-invoke stop zoneminder.service
|
||||
if [ "$ZM_DB_HOST" = "localhost" ]; then
|
||||
if [ -e "/lib/systemd/system/mysql.service" ] || [ -e "/lib/systemd/system/mariadb.service" ]; then
|
||||
|
||||
#
|
||||
# Get mysql started if it isn't running
|
||||
#
|
||||
$(systemctl status mysql.service >/dev/null 2>&1); MYSQL_STATUS=$?
|
||||
$(systemctl status mariadb.service >/dev/null 2>&1); MARIADB_STATUS=$?
|
||||
|
||||
# 3 = inactive, 4 = nonexistant
|
||||
if [ "$MARIADB_STATUS" != "4" ]; then
|
||||
DBSERVICE="mariadb.service"
|
||||
else
|
||||
echo 'MySQL/MariaDB not found; assuming remote server.'
|
||||
DBSERVICE="mysql.service"
|
||||
fi
|
||||
|
||||
if [ "$MYSQL_STATUS" != "0" ] && [ "$MARIADB_STATUS" != "0" ]; then
|
||||
# 3 = inactive, 4 = nonexistant
|
||||
# Due to /etc/init.d service autogeneration, mysql.service always returns the status of mariadb.service
|
||||
# However, mariadb.service will not return the status of mysql.service.
|
||||
deb-systemd-invoke start $DBSERVICE
|
||||
fi
|
||||
|
||||
# Make sure systemctl status exit code is 0; i.e. the DB is running
|
||||
if systemctl status "$DBSERVICE" >/dev/null 2>&1; then
|
||||
mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload
|
||||
# test if database if already present...
|
||||
if ! $(echo quit | mysql 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 mysql
|
||||
fi
|
||||
|
||||
zmupdate.pl --nointeractive
|
||||
zmupdate.pl --nointeractive -f
|
||||
|
||||
# Add any new PTZ control configurations to the database (will not overwrite)
|
||||
zmcamtool.pl --import >/dev/null 2>&1
|
||||
|
||||
else
|
||||
echo 'NOTE: MySQL/MariaDB 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/MariaDB not found; assuming remote server.'
|
||||
fi
|
||||
echo "Done Updating; starting ZoneMinder."
|
||||
deb-systemd-invoke restart zoneminder.service
|
||||
|
||||
else
|
||||
echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)."
|
||||
fi
|
||||
echo "Done Updating; starting ZoneMinder."
|
||||
deb-systemd-invoke restart zoneminder.service
|
||||
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue