Merge ../ZoneMinder.master into storageareas
This commit is contained in:
commit
43bdaff0a3
|
@ -26,28 +26,30 @@ if [ "$1" = "configure" ]; then
|
||||||
# Ensure zoneminder is stopped
|
# Ensure zoneminder is stopped
|
||||||
deb-systemd-invoke stop zoneminder.service || exit $?
|
deb-systemd-invoke stop zoneminder.service || exit $?
|
||||||
|
|
||||||
|
#
|
||||||
# Get mysql started if it isn't running
|
# 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 [ -e "/lib/systemd/system/mariadb.service" ]; then
|
||||||
if [ "$MARIADB_STATUS" != "4" ]; then
|
|
||||||
DBSERVICE="mariadb.service"
|
DBSERVICE="mariadb.service"
|
||||||
else
|
else
|
||||||
DBSERVICE="mysql.service"
|
DBSERVICE="mysql.service"
|
||||||
fi
|
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
|
if ! systemctl is-active --quiet mysql.service mariadb.service; then
|
||||||
# 3 = inactive, 4 = nonexistant
|
|
||||||
# Due to /etc/init.d service autogeneration, mysql.service always returns the status of mariadb.service
|
# 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.
|
# However, mariadb.service will not return the status of mysql.service.
|
||||||
deb-systemd-invoke start $DBSERVICE
|
deb-systemd-invoke start $DBSERVICE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure systemctl status exit code is 0; i.e. the DB is running
|
# 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
|
mysqladmin --defaults-file=/etc/mysql/debian.cnf -f reload
|
||||||
# test if database if already present...
|
# test if database if already present...
|
||||||
if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null 2> /dev/null) ; then
|
if ! $(echo quit | mysql --defaults-file=/etc/mysql/debian.cnf zm > /dev/null 2> /dev/null) ; then
|
||||||
|
|
|
@ -107,34 +107,34 @@ MYSQL_RES * zmDbFetch(const char * query) {
|
||||||
}
|
}
|
||||||
db_mutex.unlock();
|
db_mutex.unlock();
|
||||||
return result;
|
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();
|
zmDbRow *row = new zmDbRow();
|
||||||
if ( row->fetch( query ) ) {
|
if ( row->fetch(query) ) {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
delete row;
|
delete row;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MYSQL_RES *zmDbRow::fetch( const char *query ) {
|
MYSQL_RES *zmDbRow::fetch(const char *query) {
|
||||||
result_set = zmDbFetch( query );
|
result_set = zmDbFetch(query);
|
||||||
if ( ! result_set ) return result_set;
|
if ( ! result_set ) return result_set;
|
||||||
|
|
||||||
int n_rows = mysql_num_rows( result_set );
|
int n_rows = mysql_num_rows( result_set );
|
||||||
if ( n_rows != 1 ) {
|
if ( n_rows != 1 ) {
|
||||||
Error( "Bogus number of lines return from query, %d returned for query %s.", n_rows, query );
|
Error("Bogus number of lines return from query, %d returned for query %s.", n_rows, query);
|
||||||
mysql_free_result( result_set );
|
mysql_free_result(result_set);
|
||||||
result_set = NULL;
|
result_set = NULL;
|
||||||
return result_set;
|
return result_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
row = mysql_fetch_row( result_set );
|
row = mysql_fetch_row(result_set);
|
||||||
if ( ! row ) {
|
if ( ! row ) {
|
||||||
mysql_free_result( result_set );
|
mysql_free_result(result_set);
|
||||||
result_set = NULL;
|
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 {
|
} else {
|
||||||
Debug(5, "Success");
|
Debug(5, "Success");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue