I was able to set up filters like by creating a pared down version of zm_create.sql, and loading it as an additional step (and FYI: it overwrites all existing filters, too).
The file I created has the default filter plus a delete unarchived 7day old footage filter.
Code: Select all
-- MySQL dump 10.13 Distrib 5.6.13, for Linux (i686)
--
-- Host: localhost Database: zm
-- ------------------------------------------------------
-- Server version 5.6.13
--
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Current Database: `zm`
--
USE `zm`;
--
-- Table structure for table `Filters`
--
DROP TABLE IF EXISTS `Filters`;
CREATE TABLE `Filters` (
`Name` varchar(64) NOT NULL default '',
`Query` text NOT NULL,
`AutoArchive` tinyint(3) unsigned NOT NULL default '0',
`AutoVideo` tinyint(3) unsigned NOT NULL default '0',
`AutoUpload` tinyint(3) unsigned NOT NULL default '0',
`AutoEmail` tinyint(3) unsigned NOT NULL default '0',
`AutoMessage` tinyint(3) unsigned NOT NULL default '0',
`AutoExecute` tinyint(3) unsigned NOT NULL default '0',
`AutoExecuteCmd` tinytext,
`AutoDelete` tinyint(3) unsigned NOT NULL default '0',
`Background` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`Name`)
) ENGINE=InnoDB;
--
-- Add a sample filter to purge the oldest 100 events when the disk is 95% full
--
insert into Filters values ('PurgeWhenFull','{"sort_field":"Id","terms":[{"val":0,"attr":"Archived","op":"="},{"cnj":"and","val":95,"attr":"DiskPercent","op":">="}],"limit":100,"sort_asc":1}',0,0,0,0,0,0,'',1,1);
insert into Filters values ('Purge1WeekOld','{"terms":[{"attr":"Archived","op":"=","val":"0"},{"cnj":"and","attr":"DateTime","op":"<","val":"7 day ago"}],"sort_field":"DateTime","sort_asc":"1","limit":"100"}',0,0,0,0,0,0,'',1,1);
And then use this with:
Code: Select all
mysql -uYOURUSER -pYOURPASS < /usr/share/zoneminder/db/zm_reset_filters.sql
Or in the case of using ansible:
Code: Select all
# Always overwrite the filters
- name: Copy mysql code for filters to host
copy:
src=files/zm_reset_filters.sql
dest=/usr/share/zoneminder/db/zm_reset_filters.sql
owner=root
group=root
mode=0644
force=yes
- name: Reset the Zoneminder filters in the database
shell: mysql -u{{ mysqlusr }} -p{{ mysqlpwd }} < /usr/share/zoneminder/db/zm_reset_filters.sql