Merge ../ZoneMinder.master into storageareas

This commit is contained in:
Isaac Connor 2018-03-22 11:32:22 -04:00
commit 43bdaff0a3
2 changed files with 22 additions and 20 deletions

View File

@ -26,28 +26,30 @@ if [ "$1" = "configure" ]; then
# Ensure zoneminder is stopped
deb-systemd-invoke stop zoneminder.service || exit $?
#
# 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
if [ -e "/lib/systemd/system/mariadb.service" ]; then
DBSERVICE="mariadb.service"
else
DBSERVICE="mysql.service"
fi
if systemctl is-failed --quiet $DBSERVICE; then
echo "$DBSERVICE is in a failed state; it will not be started."
echo "If you have already resolved the problem preventing $DBSERVICE from running,"
echo "run sudo systemctl restart $DBSERVICE then run sudo dpkg-reconfigure zoneminder."
exit 1
fi
if [ "$MYSQL_STATUS" != "0" ] && [ "$MARIADB_STATUS" != "0" ]; then
# 3 = inactive, 4 = nonexistant
if ! systemctl is-active --quiet mysql.service mariadb.service; then
# 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
if systemctl is-active --quiet "$DBSERVICE"; 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

View File

@ -107,34 +107,34 @@ MYSQL_RES * zmDbFetch(const char * query) {
}
db_mutex.unlock();
return result;
} // end MYSQL_RES * zmDbFetch( const char * query );
} // end MYSQL_RES * zmDbFetch(const char * query);
zmDbRow *zmDbFetchOne( const char *query ) {
zmDbRow *zmDbFetchOne(const char *query) {
zmDbRow *row = new zmDbRow();
if ( row->fetch( query ) ) {
if ( row->fetch(query) ) {
return row;
}
delete row;
return NULL;
}
MYSQL_RES *zmDbRow::fetch( const char *query ) {
result_set = zmDbFetch( query );
MYSQL_RES *zmDbRow::fetch(const char *query) {
result_set = zmDbFetch(query);
if ( ! result_set ) return result_set;
int n_rows = mysql_num_rows( result_set );
if ( n_rows != 1 ) {
Error( "Bogus number of lines return from query, %d returned for query %s.", n_rows, query );
mysql_free_result( result_set );
Error("Bogus number of lines return from query, %d returned for query %s.", n_rows, query);
mysql_free_result(result_set);
result_set = NULL;
return result_set;
}
row = mysql_fetch_row( result_set );
row = mysql_fetch_row(result_set);
if ( ! row ) {
mysql_free_result( result_set );
mysql_free_result(result_set);
result_set = NULL;
Error("Error getting row from query %s. Error is %s", query, mysql_error( &dbconn ) );
Error("Error getting row from query %s. Error is %s", query, mysql_error(&dbconn));
} else {
Debug(5, "Success");
}