Merge branch 'master' of git://github.com/ZoneMinder/zoneminder
add preset delete option in the PTZ controls
This commit is contained in:
commit
879fab24af
|
@ -1,23 +1,43 @@
|
|||
You should only file an issue if you found a bug. Feature and enhancement requests, general discussions and support questions should occur in one of the following areas:
|
||||
**THIS FORUM IS FOR BUG REPORTS ONLY**
|
||||
|
||||
Do not post feature or enhancement requests, general discussions or support questions here.
|
||||
|
||||
Feature and enhancement requests, general discussions, and support questions should occur in one of the following areas:
|
||||
|
||||
- The [ZoneMinder-Chat Slack channel](https://zoneminder-chat.herokuapp.com/)
|
||||
- The [ZoneMinder Forum](https://forums.zoneminder.com/)
|
||||
|
||||
**Do not post feature or enhancement requests, general discussions or support questions here.**
|
||||
|
||||
Docker related issues should be posted here: https://github.com/ZoneMinder/zmdockerfiles
|
||||
|
||||
Make sure you are running the latest version of ZoneMinder before reporting an issue.
|
||||
In order to submit a bug report, please populate the fields below. This is required.
|
||||
|
||||
**ZoneMinder Version (`zmaudit.pl -v`):**
|
||||
**Describe Your Environment**
|
||||
- Version of ZoneMinder [release version, development version, or commit]
|
||||
- How you installed ZoneMinder [e.g. PPA, RPMFusion, from-source, etc]
|
||||
- Full name and version of OS
|
||||
|
||||
**Are you using a development snapshot / git checkout? If so, what is the latest commit? (`git rev-parse HEAD`):**
|
||||
**If the issue concerns a camera**
|
||||
- Make and Model
|
||||
- frame rate
|
||||
- resolution
|
||||
- ZoneMinder Source Type:
|
||||
|
||||
**Linux Distribution and Version (`cat /etc/os-release` or `cat /etc/redhat-release`):**
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**If the issue concerns a camera, provide the make, model, frame rate, resolution and ZoneMinder Source Type:**
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Relevant log lines:**
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Debug Logs**
|
||||
```
|
||||
log lines here
|
||||
|
||||
<insert debug logs here, please make sure they are within the ``` quotes so they are formatted properly>
|
||||
|
||||
```
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# Configuration for welcome - https://github.com/behaviorbot/welcome
|
||||
|
||||
# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
|
||||
|
||||
# Comment to be posted to on first time issues
|
||||
newIssueWelcomeComment: >
|
||||
Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template!
|
||||
|
||||
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
|
||||
|
||||
# Comment to be posted to on PRs from first time contributors in your repository
|
||||
#newPRWelcomeComment: >
|
||||
# Thanks for opening this pull request! Please check out our contributing guidelines.
|
||||
|
||||
# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
|
||||
|
||||
# Comment to be posted to on pull requests merged by a first time user
|
||||
#firstPRMergeComment: >
|
||||
# Congrats on merging your first pull request! We here at behaviorbot are proud of you!
|
||||
|
||||
# It is recommend to include as many gifs and emojis as possible
|
|
@ -0,0 +1,13 @@
|
|||
# Configuration for probot-no-response - https://github.com/probot/no-response
|
||||
|
||||
# Number of days of inactivity before an Issue is closed for lack of response
|
||||
daysUntilClose: 7
|
||||
# Label requiring a response
|
||||
responseRequiredLabel: more-information-needed
|
||||
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
|
||||
closeComment: >
|
||||
This issue has been automatically closed because there has been no response
|
||||
to our request for more information from the original author. With only the
|
||||
information that is currently in the issue, we don't have enough information
|
||||
to take action. Please reach out if you have or find the answers we need so
|
||||
that we can investigate further.
|
|
@ -38,6 +38,7 @@ env:
|
|||
- OS=el DIST=7
|
||||
- OS=fedora DIST=27 DOCKER_REPO=knnniggett/packpack
|
||||
- OS=fedora DIST=28 DOCKER_REPO=knnniggett/packpack
|
||||
- OS=fedora DIST=29 DOCKER_REPO=knnniggett/packpack
|
||||
- OS=ubuntu DIST=trusty
|
||||
- OS=ubuntu DIST=xenial
|
||||
- OS=ubuntu DIST=trusty ARCH=i386
|
||||
|
|
|
@ -127,7 +127,8 @@ mark_as_advanced(
|
|||
ZM_PATH_ARP
|
||||
ZM_CONFIG_DIR
|
||||
ZM_CONFIG_SUBDIR
|
||||
ZM_SYSTEMD)
|
||||
ZM_SYSTEMD
|
||||
ZM_MANPAGE_DEST_PREFIX)
|
||||
|
||||
set(ZM_RUNDIR "/var/run/zm" CACHE PATH
|
||||
"Location of transient process files, default: /var/run/zm")
|
||||
|
@ -210,6 +211,10 @@ set(ZM_TARGET_DISTRO "" CACHE STRING
|
|||
"Build ZoneMinder for a specific distribution. Currently, valid names are: fc27, fc26, el7, OS13, FreeBSD")
|
||||
set(ZM_SYSTEMD "OFF" CACHE BOOL
|
||||
"Set to ON to force building ZM with systemd support. default: OFF")
|
||||
set(ZM_MANPAGE_DEST_PREFIX "share/man" CACHE PATH
|
||||
"Relative path used to install ZoneMinder's Man pages into a
|
||||
non-standard folder. Most Linux users will not need to change this.
|
||||
BSD users may need to set this.")
|
||||
|
||||
# Reassign some variables if a target distro has been specified
|
||||
if((ZM_TARGET_DISTRO MATCHES "^el") OR (ZM_TARGET_DISTRO MATCHES "^fc"))
|
||||
|
|
|
@ -53,9 +53,9 @@ Lastly, if you desire to build a development snapshot from the master branch, it
|
|||
Please visit our [ReadtheDocs site](https://zoneminder.readthedocs.org/en/stable/installationguide/index.html) for distro specific instructions.
|
||||
|
||||
### Package Maintainers
|
||||
Many of the ZoneMinder configration variable default values are not configurable at build time through autotools or cmake. A new tool called *zmeditconfigdata.sh* has been added to allow package maintainers to manipulate any variable stored in ConfigData.pm without patching the source.
|
||||
Many of the ZoneMinder configuration variable default values are not configurable at build time through autotools or cmake. A new tool called *zmeditconfigdata.sh* has been added to allow package maintainers to manipulate any variable stored in ConfigData.pm without patching the source.
|
||||
|
||||
For example, let's say I have created a new ZoneMinder package that contains the cambolzola javascript file. However, by default cambozola support is turned off. To fix that, add this to the pacakging script:
|
||||
For example, let's say I have created a new ZoneMinder package that contains the cambozola javascript file. However, by default cambozola support is turned off. To fix that, add this to the packaging script:
|
||||
```bash
|
||||
./utils/zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes
|
||||
```
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# To use it, include this file in CMakeLists.txt and
|
||||
# invoke POD2MAN(<podfile> <manfile> <section>)
|
||||
|
||||
MACRO(POD2MAN PODFILE MANFILE SECTION)
|
||||
MACRO(POD2MAN PODFILE MANFILE SECTION MANPAGE_DEST_PREFIX)
|
||||
FIND_PROGRAM(POD2MAN pod2man)
|
||||
FIND_PROGRAM(GZIP gzip)
|
||||
|
||||
|
@ -58,9 +58,9 @@ MACRO(POD2MAN PODFILE MANFILE SECTION)
|
|||
|
||||
INSTALL(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/${MANFILE}.${SECTION}.gz
|
||||
DESTINATION share/man/man${SECTION}
|
||||
DESTINATION ${MANPAGE_DEST_PREFIX}/man${SECTION}
|
||||
)
|
||||
ENDMACRO(POD2MAN PODFILE MANFILE SECTION)
|
||||
ENDMACRO(POD2MAN PODFILE MANFILE SECTION MANPAGE_DEST_PREFIX)
|
||||
|
||||
MACRO(ADD_MANPAGE_TARGET)
|
||||
# It is not possible add a dependency to target 'install'
|
||||
|
|
|
@ -496,7 +496,6 @@ CREATE TABLE `Monitors` (
|
|||
`TrackDelay` smallint(5) unsigned,
|
||||
`ReturnLocation` tinyint(3) NOT NULL default '-1',
|
||||
`ReturnDelay` smallint(5) unsigned,
|
||||
`DefaultView` enum('Events','Control') NOT NULL default 'Events',
|
||||
`DefaultRate` smallint(5) unsigned NOT NULL default '100',
|
||||
`DefaultScale` smallint(5) unsigned NOT NULL default '100',
|
||||
`SignalCheckPoints` INT UNSIGNED NOT NULL default '0',
|
||||
|
@ -556,7 +555,12 @@ INSERT INTO States (Name,Definition,IsActive) VALUES ('default','','1');
|
|||
DROP TABLE IF EXISTS `Servers`;
|
||||
CREATE TABLE `Servers` (
|
||||
`Id` int(10) unsigned NOT NULL auto_increment,
|
||||
`Protocol` TEXT,
|
||||
`Hostname` TEXT,
|
||||
`Port` INTEGER UNSIGNED,
|
||||
`PathToIndex` TEXT,
|
||||
`PathToZMS` TEXT,
|
||||
`PathToApi` TEXT,
|
||||
`Name` varchar(64) NOT NULL default '',
|
||||
`State_Id` int(10) unsigned,
|
||||
`Status` enum('Unknown','NotRunning','Running') NOT NULL default 'Unknown',
|
||||
|
@ -781,6 +785,7 @@ INSERT INTO `Controls` VALUES (NULL,'D-LINK DCS-3415','Remote','DCS3415',0,0,0,1
|
|||
INSERT INTO `Controls` VALUES (NULL,'IOS Camera','Ffmpeg','IPCAMIOS',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0);
|
||||
INSERT INTO `Controls` VALUES (NULL,'Dericam P2','Ffmpeg','DericamP2',0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,10,0,1,1,1,0,0,0,1,1,0,0,0,0,1,1,45,0,0,1,0,0,0,0,1,1,45,0,0,0,0);
|
||||
INSERT INTO `Controls` VALUES (NULL,'Trendnet','Remote','Trendnet',1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0);
|
||||
INSERT INTO `Controls` VALUES (NULL,'PSIA','Remote','PSIA',0,0,0,1,0,0,1,0,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20,0,1,1,1,0,0,1,0,1,0,0,0,0,1,-100,100,0,0,1,0,0,0,0,1,-100,100,0,0,0,0);
|
||||
INSERT INTO `Controls` VALUES (NULL,'Dahua','Remote','Dahua',0,0,0,1,0,0,1,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20,0,1,1,1,0,0,1,0,1,0,0,0,0,1,1,8,0,0,1,0,0,0,0,1,1,8,0,0,0,0);
|
||||
|
||||
--
|
||||
|
@ -808,6 +813,7 @@ INSERT into MonitorPresets VALUES (NULL,'Axis IP, mpeg4, unicast','Remote','rtsp
|
|||
INSERT into MonitorPresets VALUES (NULL,'Axis IP, mpeg4, multicast','Remote','rtsp',0,255,'rtsp','rtpMulti','<ip-address>',554,'/mpeg4/media.amp','/trackID=',NULL,NULL,3,NULL,0,NULL,NULL,NULL,100,100);
|
||||
INSERT into MonitorPresets VALUES (NULL,'Axis IP, mpeg4, RTP/RTSP','Remote','rtsp',0,255,'rtsp','rtpRtsp','<ip-address>',554,'/mpeg4/media.amp','/trackID=',NULL,NULL,3,NULL,0,NULL,NULL,NULL,100,100);
|
||||
INSERT into MonitorPresets VALUES (NULL,'Axis IP, mpeg4, RTP/RTSP/HTTP','Remote',NULL,NULL,NULL,'rtsp','rtpRtspHttp','<ip-address>',554,'/mpeg4/media.amp','/trackID=',NULL,NULL,3,NULL,0,NULL,NULL,NULL,100,100);
|
||||
INSERT INTO MonitorPresets VALUES (NULL,'D-link DCS-930L, 640x480, mjpeg','Remote','http',0,0,'http','simple','<ip-address>',80,'/mjpeg.cgi',NULL,640,480,3,NULL,0,NULL,NULL,NULL,100,100);
|
||||
INSERT INTO MonitorPresets VALUES (NULL,'Panasonic IP, 320x240, mpjpeg','Remote','http',0,0,'http','simple','<ip-address>',80,'/nphMotionJpeg?Resolution=320x240&Quality=Standard',NULL,320,240,3,NULL,0,NULL,NULL,NULL,100,100);
|
||||
INSERT INTO MonitorPresets VALUES (NULL,'Panasonic IP, 320x240, jpeg','Remote','http',0,0,'http','simple','<ip-address>',80,'/SnapshotJPEG?Resolution=320x240&Quality=Standard',NULL,320,240,3,NULL,0,NULL,NULL,NULL,100,100);
|
||||
INSERT INTO MonitorPresets VALUES (NULL,'Panasonic IP, 320x240, jpeg, max 5 FPS','Remote','http',0,0,'http','simple','<ip-address>',80,'/SnapshotJPEG?Resolution=320x240&Quality=Standard',NULL,320,240,3,5.0,0,NULL,NULL,NULL,100,100);
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
ALTER TABLE Frames MODIFY COLUMN EventId bigint unsigned NOT NULL;
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
--
|
||||
-- This updates a 1.32.1 database to 1.32.2
|
||||
--
|
||||
-- No changes required
|
||||
--
|
|
@ -0,0 +1,362 @@
|
|||
--
|
||||
-- This updates a 1.32.2 database to 1.32.3
|
||||
--
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Hour_delete_trigger//
|
||||
CREATE TRIGGER Events_Hour_delete_trigger BEFORE DELETE ON Events_Hour
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,1)-1,
|
||||
HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Hour_update_trigger//
|
||||
|
||||
CREATE TRIGGER Events_Hour_update_trigger AFTER UPDATE ON Events_Hour
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)-COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET HourEventDiskSpace=COALESCE(HourEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
DELIMITER ;
|
||||
|
||||
delimiter //
|
||||
DROP TRIGGER IF EXISTS Events_Day_delete_trigger//
|
||||
CREATE TRIGGER Events_Day_delete_trigger BEFORE DELETE ON Events_Day
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
DayEvents = COALESCE(DayEvents,1)-1,
|
||||
DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Day_update_trigger;
|
||||
CREATE TRIGGER Events_Day_update_trigger AFTER UPDATE ON Events_Day
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET DayEventDiskSpace=COALESCE(DayEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_delete_trigger//
|
||||
CREATE TRIGGER Events_Week_delete_trigger BEFORE DELETE ON Events_Week
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
WeekEvents = COALESCE(WeekEvents,1)-1,
|
||||
WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Week_update_trigger;
|
||||
CREATE TRIGGER Events_Week_update_trigger AFTER UPDATE ON Events_Week
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+COALESCE(NEW.DiskSpace,0) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET WeekEventDiskSpace=COALESCE(WeekEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_delete_trigger//
|
||||
CREATE TRIGGER Events_Month_delete_trigger BEFORE DELETE ON Events_Month
|
||||
FOR EACH ROW BEGIN
|
||||
UPDATE Monitors SET
|
||||
MonthEvents = COALESCE(MonthEvents,1)-1,
|
||||
MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Events_Month_update_trigger;
|
||||
CREATE TRIGGER Events_Month_update_trigger AFTER UPDATE ON Events_Month
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( diff ) THEN
|
||||
IF ( NEW.MonitorID != OLD.MonitorID ) THEN
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)-COALESCE(OLD.DiskSpace) WHERE Monitors.Id=OLD.MonitorId;
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+COALESCE(NEW.DiskSpace) WHERE Monitors.Id=NEW.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET MonthEventDiskSpace=COALESCE(MonthEventDiskSpace,0)+diff WHERE Monitors.Id=NEW.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
END;
|
||||
//
|
||||
|
||||
drop procedure if exists update_storage_stats//
|
||||
|
||||
drop trigger if exists event_update_trigger//
|
||||
|
||||
CREATE TRIGGER event_update_trigger AFTER UPDATE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
declare diff BIGINT default 0;
|
||||
|
||||
set diff = COALESCE(NEW.DiskSpace,0) - COALESCE(OLD.DiskSpace,0);
|
||||
IF ( NEW.StorageId = OLD.StorageID ) THEN
|
||||
IF ( diff ) THEN
|
||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + diff WHERE Id = OLD.StorageId;
|
||||
END IF;
|
||||
ELSE
|
||||
IF ( NEW.DiskSpace ) THEN
|
||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) + NEW.DiskSpace WHERE Id = NEW.StorageId;
|
||||
END IF;
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) - OLD.DiskSpace WHERE Id = OLD.StorageId;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
UPDATE Events_Hour SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Day SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Week SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Events_Month SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
|
||||
IF ( NEW.Archived != OLD.Archived ) THEN
|
||||
IF ( NEW.Archived ) THEN
|
||||
INSERT INTO Events_Archived (EventId,MonitorId,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.DiskSpace);
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)+1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=NEW.MonitorId;
|
||||
ELSEIF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET ArchivedEvents = COALESCE(ArchivedEvents,0)-1, ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
IF ( OLD.DiskSpace != NEW.DiskSpace ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END IF;
|
||||
ELSEIF ( NEW.Archived AND diff ) THEN
|
||||
UPDATE Events_Archived SET DiskSpace=NEW.DiskSpace WHERE EventId=NEW.Id;
|
||||
END IF;
|
||||
|
||||
IF ( diff ) THEN
|
||||
UPDATE Monitors SET TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0) + COALESCE(NEW.DiskSpace,0) WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
DROP TRIGGER IF EXISTS event_insert_trigger;
|
||||
|
||||
delimiter //
|
||||
/* The assumption is that when an Event is inserted, it has no size yet, so don't bother updating the DiskSpace, just the count.
|
||||
* The DiskSpace will get update in the Event Update Trigger
|
||||
*/
|
||||
CREATE TRIGGER event_insert_trigger AFTER INSERT ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
|
||||
INSERT INTO Events_Hour (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Day (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Week (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
INSERT INTO Events_Month (EventId,MonitorId,StartTime,DiskSpace) VALUES (NEW.Id,NEW.MonitorId,NEW.StartTime,0);
|
||||
UPDATE Monitors SET
|
||||
HourEvents = COALESCE(HourEvents,0)+1,
|
||||
DayEvents = COALESCE(DayEvents,0)+1,
|
||||
WeekEvents = COALESCE(WeekEvents,0)+1,
|
||||
MonthEvents = COALESCE(MonthEvents,0)+1,
|
||||
TotalEvents = COALESCE(TotalEvents,0)+1
|
||||
WHERE Id=NEW.MonitorId;
|
||||
END;
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS event_delete_trigger//
|
||||
|
||||
CREATE TRIGGER event_delete_trigger BEFORE DELETE ON Events
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF ( OLD.DiskSpace ) THEN
|
||||
UPDATE Storage SET DiskSpace = COALESCE(DiskSpace,0) - CAST(OLD.DiskSpace AS SIGNED) WHERE Id = OLD.StorageId;
|
||||
END IF;
|
||||
DELETE FROM Events_Hour WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Day WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Week WHERE EventId=OLD.Id;
|
||||
DELETE FROM Events_Month WHERE EventId=OLD.Id;
|
||||
IF ( OLD.Archived ) THEN
|
||||
DELETE FROM Events_Archived WHERE EventId=OLD.Id;
|
||||
UPDATE Monitors SET
|
||||
ArchivedEvents = COALESCE(ArchivedEvents,1) - 1,
|
||||
ArchivedEventDiskSpace = COALESCE(ArchivedEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0),
|
||||
TotalEvents = COALESCE(TotalEvents,1) - 1,
|
||||
TotalEventDiskSpace = COALESCE(TotalEventDiskSpace,0) - COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
ELSE
|
||||
UPDATE Monitors SET
|
||||
TotalEvents = COALESCE(TotalEvents,1)-1,
|
||||
TotalEventDiskSpace=COALESCE(TotalEventDiskSpace,0)-COALESCE(OLD.DiskSpace,0)
|
||||
WHERE Id=OLD.MonitorId;
|
||||
END IF;
|
||||
END;
|
||||
|
||||
//
|
||||
|
||||
DROP TRIGGER IF EXISTS Zone_Insert_Trigger//
|
||||
CREATE TRIGGER Zone_Insert_Trigger AFTER INSERT ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=NEW.MonitorId) WHERE Id=NEW.MonitorID;
|
||||
END
|
||||
//
|
||||
DROP TRIGGER IF EXISTS Zone_Delete_Trigger//
|
||||
CREATE TRIGGER Zone_Delete_Trigger AFTER DELETE ON Zones
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE Monitors SET ZoneCount=(SELECT COUNT(*) FROM Zones WHERE MonitorId=OLD.MonitorId) WHERE Id=OLD.MonitorID;
|
||||
END
|
||||
//
|
||||
|
||||
DELIMITER ;
|
||||
|
||||
REPLACE INTO Events_Day SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 day);
|
||||
REPLACE INTO Events_Week SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 week);
|
||||
REPLACE INTO Events_Month SELECT Id,MonitorId,StartTime,DiskSpace FROM Events WHERE StartTime > DATE_SUB(NOW(), INTERVAL 1 month);
|
||||
REPLACE INTO Events_Archived SELECT Id,MonitorId,DiskSpace FROM Events WHERE Archived=1;
|
||||
|
||||
UPDATE Monitors INNER JOIN (
|
||||
SELECT MonitorId,
|
||||
COUNT(Id) AS TotalEvents,
|
||||
SUM(DiskSpace) AS TotalEventDiskSpace,
|
||||
SUM(IF(Archived,1,0)) AS ArchivedEvents,
|
||||
SUM(IF(Archived,DiskSpace,0)) AS ArchivedEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),1,0)) AS HourEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 hour),DiskSpace,0)) AS HourEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),1,0)) AS DayEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 day),DiskSpace,0)) AS DayEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),1,0)) AS WeekEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 week),DiskSpace,0)) AS WeekEventDiskSpace,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),1,0)) AS MonthEvents,
|
||||
SUM(IF(StartTime > DATE_SUB(NOW(), INTERVAL 1 month),DiskSpace,0)) AS MonthEventDiskSpace
|
||||
FROM Events GROUP BY MonitorId
|
||||
) AS E ON E.MonitorId=Monitors.Id SET
|
||||
Monitors.TotalEvents = E.TotalEvents,
|
||||
Monitors.TotalEventDiskSpace = E.TotalEventDiskSpace,
|
||||
Monitors.ArchivedEvents = E.ArchivedEvents,
|
||||
Monitors.ArchivedEventDiskSpace = E.ArchivedEventDiskSpace,
|
||||
Monitors.HourEvents = E.HourEvents,
|
||||
Monitors.HourEventDiskSpace = E.HourEventDiskSpace,
|
||||
Monitors.DayEvents = E.DayEvents,
|
||||
Monitors.DayEventDiskSpace = E.DayEventDiskSpace,
|
||||
Monitors.WeekEvents = E.WeekEvents,
|
||||
Monitors.WeekEventDiskSpace = E.WeekEventDiskSpace,
|
||||
Monitors.MonthEvents = E.MonthEvents,
|
||||
Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace;
|
||||
|
||||
--
|
||||
-- Add Protocol column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'Protocol'
|
||||
) > 0,
|
||||
"SELECT 'Column Protocol already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `Protocol` TEXT AFTER `Id`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add PathToIndex column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'PathToIndex'
|
||||
) > 0,
|
||||
"SELECT 'Column PathToIndex already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `PathToIndex` TEXT AFTER `Hostname`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add PathToZMS column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'PathToZMS'
|
||||
) > 0,
|
||||
"SELECT 'Column PathToZMS already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `PathToZMS` TEXT AFTER `PathToIndex`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add PathToApi column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'PathToApi'
|
||||
) > 0,
|
||||
"SELECT 'Column PathToApi already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `PathToApi` TEXT AFTER `PathToZMS`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
||||
--
|
||||
-- Add Port column to Storage
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
|
||||
AND table_name = 'Servers'
|
||||
AND column_name = 'Port'
|
||||
) > 0,
|
||||
"SELECT 'Column Port already exists in Servers'",
|
||||
"ALTER TABLE Servers ADD `Port` INTEGER UNSIGNED AFTER `Hostname`"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
|
@ -0,0 +1,21 @@
|
|||
--
|
||||
-- This updates a 1.32.3 database to 1.33.0
|
||||
--
|
||||
--
|
||||
-- Remove DefaultView from Monitors table.
|
||||
--
|
||||
|
||||
SET @s = (SELECT IF(
|
||||
(SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE table_name = 'Monitors'
|
||||
AND table_schema = DATABASE()
|
||||
AND column_name = 'DefaultView'
|
||||
) > 0,
|
||||
"ALTER TABLE Monitors DROP COLUMN DefaultView",
|
||||
"SELECT 'Column DefaultView no longer exists in Monitors'"
|
||||
));
|
||||
|
||||
PREPARE stmt FROM @s;
|
||||
EXECUTE stmt;
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
# CMakeLists.txt for the Redhat Target Distros.
|
||||
|
||||
#
|
||||
# General strategy is to configure and install all files specific to Apache and Nginx
|
||||
# Then let the rpm specfile sort them into the appropriate sub-package
|
||||
#
|
||||
|
||||
# Display a message to show the RHEL build options are being processed.
|
||||
if(ZM_TARGET_DISTRO MATCHES "^el")
|
||||
message([STATUS] "Starting RHEL Build Options" ...)
|
||||
|
@ -9,33 +14,39 @@ else(ZM_TARGET_DISTRO MATCHES "^el")
|
|||
message([WARNING] "Unknown Build Option Detected" ...)
|
||||
endif(ZM_TARGET_DISTRO MATCHES "^el")
|
||||
|
||||
if((NOT ZM_TARGET_DISTRO MATCHES "^fc") AND (ZM_WEB_USER STREQUAL "nginx"))
|
||||
message([FATAL_ERROR] "Experimental Nginx support is currently only supported on Fedora" ...)
|
||||
endif((NOT ZM_TARGET_DISTRO MATCHES "^fc") AND (ZM_WEB_USER STREQUAL "nginx"))
|
||||
#
|
||||
# CONFIGURE STAGE
|
||||
#
|
||||
|
||||
# Configure the zoneminder service files
|
||||
configure_file(systemd/zoneminder.logrotate.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.logrotate @ONLY)
|
||||
if(ZM_WEB_USER STREQUAL "nginx")
|
||||
configure_file(nginx/zoneminder.service.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY)
|
||||
configure_file(nginx/zoneminder.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.conf @ONLY)
|
||||
configure_file(nginx/zoneminder.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.tmpfiles @ONLY)
|
||||
configure_file(nginx/zoneminder.php-fpm.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.php-fpm.conf @ONLY)
|
||||
configure_file(nginx/README.Fedora ${CMAKE_CURRENT_SOURCE_DIR}/readme/README COPYONLY)
|
||||
else(ZM_WEB_USER STREQUAL "nginx")
|
||||
configure_file(systemd/zoneminder.service.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY)
|
||||
configure_file(apache/zoneminder.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.conf @ONLY)
|
||||
configure_file(systemd/zoneminder.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.tmpfiles @ONLY)
|
||||
if( ZM_TARGET_DISTRO MATCHES "^fc")
|
||||
configure_file(readme/README.Fedora ${CMAKE_CURRENT_SOURCE_DIR}/readme/README COPYONLY)
|
||||
else( ZM_TARGET_DISTRO MATCHES "^fc")
|
||||
configure_file(readme/README.Redhat7 ${CMAKE_CURRENT_SOURCE_DIR}/readme/README COPYONLY)
|
||||
endif( ZM_TARGET_DISTRO MATCHES "^fc")
|
||||
endif(ZM_WEB_USER STREQUAL "nginx")
|
||||
|
||||
# Create several empty folders
|
||||
# Configure the common zoneminder files
|
||||
configure_file(common/zoneminder.logrotate.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.logrotate @ONLY)
|
||||
configure_file(common/zoneminder.service.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.service @ONLY)
|
||||
file(MAKE_DIRECTORY sock swap zoneminder zoneminder-upload events images temp)
|
||||
|
||||
# Install the empty folders
|
||||
# Configure the Apache zoneminder files
|
||||
configure_file(httpd/zm-httpd.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zm-httpd.conf @ONLY)
|
||||
configure_file(httpd/zoneminder.httpd.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.httpd.conf @ONLY)
|
||||
configure_file(httpd/zoneminder.httpd.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.httpd.tmpfiles.conf @ONLY)
|
||||
configure_file(httpd/com.zoneminder.systemctl.rules.httpd.in ${CMAKE_CURRENT_SOURCE_DIR}/com.zoneminder.systemctl.rules.httpd @ONLY)
|
||||
|
||||
# Configure the Nginx zoneminder files
|
||||
configure_file(nginx/zm-nginx.conf ${CMAKE_CURRENT_SOURCE_DIR}/zm-nginx.conf COPYONLY)
|
||||
configure_file(nginx/zoneminder.nginx.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.nginx.conf @ONLY)
|
||||
configure_file(nginx/redirect.nginx.conf ${CMAKE_CURRENT_SOURCE_DIR}/redirect.nginx.conf COPYONLY)
|
||||
configure_file(nginx/zoneminder.nginx.tmpfiles.in ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.nginx.tmpfiles.conf @ONLY)
|
||||
configure_file(nginx/zm-web-user.conf ${CMAKE_CURRENT_SOURCE_DIR}/zm-web-user.conf COPYONLY)
|
||||
configure_file(nginx/zoneminder.php-fpm.conf ${CMAKE_CURRENT_SOURCE_DIR}/zoneminder.php-fpm.conf COPYONLY)
|
||||
configure_file(nginx/com.zoneminder.systemctl.rules.nginx ${CMAKE_CURRENT_SOURCE_DIR}/com.zoneminder.systemctl.rules.nginx COPYONLY)
|
||||
|
||||
#
|
||||
# INSTALLATION STAGE
|
||||
#
|
||||
|
||||
|
||||
# Install the common zoneminder files
|
||||
install(FILES zoneminder.logrotate DESTINATION /etc/logrotate.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zoneminder.service DESTINATION /usr/lib/systemd/system PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
|
||||
install(DIRECTORY sock swap DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(DIRECTORY zoneminder DESTINATION /var/log DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(DIRECTORY zoneminder DESTINATION /var/run DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
|
@ -43,6 +54,23 @@ install(DIRECTORY zoneminder DESTINATION /var/cache DIRECTORY_PERMISSIONS OWNER_
|
|||
install(DIRECTORY zoneminder-upload DESTINATION /var/spool DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(DIRECTORY events images temp DESTINATION /var/lib/zoneminder DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
|
||||
# Install the Apache zoneminder files
|
||||
install(FILES zm-httpd.conf DESTINATION /usr/lib/systemd/system/zoneminder.service.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zoneminder.httpd.conf DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zoneminder.httpd.tmpfiles.conf DESTINATION /usr/lib/tmpfiles.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES com.zoneminder.systemctl.rules.httpd DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
|
||||
# Install the Nginx zoneminder files
|
||||
install(FILES zm-nginx.conf DESTINATION /usr/lib/systemd/system/zoneminder.service.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zoneminder.nginx.conf DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES redirect.nginx.conf DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zoneminder.nginx.tmpfiles.conf DESTINATION /usr/lib/tmpfiles.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES com.zoneminder.systemctl.rules.nginx DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zm-web-user.conf DESTINATION /etc/zm/conf.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zoneminder.php-fpm.conf DESTINATION /etc/php-fpm.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
|
||||
# Miscellaneous
|
||||
|
||||
# Symlink the cake php temp folder to the ZoneMinder temp folder
|
||||
install(CODE "execute_process(COMMAND ln -sf ../../../../../../var/lib/zoneminder/temp \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/api/app/tmp\")")
|
||||
|
||||
|
@ -50,16 +78,5 @@ install(CODE "execute_process(COMMAND ln -sf ../../../../../../var/lib/zoneminde
|
|||
install(CODE "execute_process(COMMAND ln -sf ../../java/cambozola.jar \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/cambozola.jar\")")
|
||||
|
||||
# Install auxiliary files
|
||||
install(FILES misc/redalert.wav DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/sounds PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
|
||||
# Install zoneminder service files
|
||||
install(FILES zoneminder.logrotate DESTINATION /etc/logrotate.d RENAME zoneminder PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zoneminder.conf DESTINATION /etc/zm/www PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
|
||||
if(ZM_WEB_USER STREQUAL "nginx")
|
||||
install(FILES zoneminder.php-fpm.conf DESTINATION /etc/php-fpm.d PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ RENAME zoneminder.conf)
|
||||
endif(ZM_WEB_USER STREQUAL "nginx")
|
||||
|
||||
install(FILES zoneminder.service DESTINATION /usr/lib/systemd/system PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES zoneminder.tmpfiles DESTINATION /usr/lib/tmpfiles.d RENAME zoneminder.conf PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)
|
||||
install(FILES common/redalert.wav DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/zoneminder/www/sounds PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
@ZM_LOGDIR@/*.log {
|
||||
missingok
|
||||
notifempty
|
||||
sharedscripts
|
||||
delaycompress
|
||||
compress
|
||||
postrotate
|
||||
@BINDIR@/zmpkg.pl logrot > /dev/null 2>/dev/null || true
|
||||
endscript
|
||||
daily
|
||||
rotate 7
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
# ZoneMinder systemd unit file for RedHat distros and clones
|
||||
# See drop-in folder for additional config directives
|
||||
|
||||
[Unit]
|
||||
Description=ZoneMinder CCTV recording and security system
|
||||
After=network.target mariadb.service httpd.service
|
||||
Requires=mariadb.service httpd.service
|
||||
After=network.target mariadb.service
|
||||
Requires=mariadb.service
|
||||
|
||||
[Service]
|
||||
User=@WEB_USER@
|
||||
Group=@WEB_GROUP@
|
||||
Type=forking
|
||||
ExecStart=@BINDIR@/zmpkg.pl start
|
||||
ExecReload=@BINDIR@/zmpkg.pl restart
|
|
@ -0,0 +1,7 @@
|
|||
polkit.addRule(function(action, subject) {
|
||||
if (action.id == "com.zoneminder.policykit.pkexec.run-zmsystemctl" &&
|
||||
subject.user != "@WEB_USER@") {
|
||||
return polkit.Result.NO;
|
||||
}
|
||||
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
# Additional config directives for ZoneMinder with Apache web server
|
||||
|
||||
[Unit]
|
||||
After=httpd.service
|
||||
|
||||
[Service]
|
||||
User=@WEB_USER@
|
||||
Group=@WEB_GROUP@
|
|
@ -3,3 +3,4 @@ D @ZM_SOCKDIR@ 0755 @WEB_USER@ @WEB_GROUP@
|
|||
D @ZM_CACHEDIR@ 0755 @WEB_USER@ @WEB_GROUP@
|
||||
d @ZM_DIR_EVENTS@ 0755 @WEB_USER@ @WEB_GROUP@
|
||||
D @ZM_DIR_IMAGES@ 0755 @WEB_USER@ @WEB_GROUP@
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
module local_zoneminder 1.2;
|
||||
|
||||
require {
|
||||
type afs_ka_port_t;
|
||||
type netsupport_port_t;
|
||||
type port_t;
|
||||
type presence_port_t;
|
||||
type postfix_master_t;
|
||||
type postfix_qmgr_t;
|
||||
type postfix_pickup_t;
|
||||
type httpd_t;
|
||||
type var_lib_t;
|
||||
type ionixnetmon_port_t;
|
||||
type glance_port_t;
|
||||
type mmcc_port_t;
|
||||
type postfix_master_t;
|
||||
type commplex_port_t;
|
||||
type syslogd_port_t;
|
||||
type dcc_port_t;
|
||||
type sip_port_t;
|
||||
type amqp_port_t;
|
||||
type condor_port_t;
|
||||
type afs_fs_port_t;
|
||||
type nodejs_debug_port_t;
|
||||
type httpd_var_lib_t;
|
||||
type websm_port_t;
|
||||
type afs_pt_port_t;
|
||||
type postfix_qmgr_t;
|
||||
type git_port_t;
|
||||
type ipp_port_t;
|
||||
type aol_port_t;
|
||||
type unconfined_t;
|
||||
type kernel_t;
|
||||
type init_t;
|
||||
type auditd_t;
|
||||
type mysqld_t;
|
||||
type httpd_log_t;
|
||||
type syslogd_t;
|
||||
type httpd_t;
|
||||
type initrc_state_t;
|
||||
type initrc_t;
|
||||
type var_lib_t;
|
||||
type udev_t;
|
||||
type mysqld_safe_t;
|
||||
type sshd_t;
|
||||
type crond_t;
|
||||
type getty_t;
|
||||
type httpd_var_lib_t;
|
||||
type initrc_var_run_t;
|
||||
type tmpfs_t;
|
||||
type dhcpc_t;
|
||||
type v4l_device_t;
|
||||
type file_t;
|
||||
class sock_file { write create unlink };
|
||||
class unix_stream_socket { read connectto };
|
||||
class lnk_file { write create getattr read lock unlink };
|
||||
class dir {search getattr };
|
||||
class udp_socket name_bind;
|
||||
class file { write getattr read lock unlink open };
|
||||
class shm { unix_read unix_write associate read write getattr };
|
||||
class chr_file getattr;
|
||||
}
|
||||
|
||||
#============= httpd_t ==============
|
||||
allow httpd_t auditd_t:dir { search getattr };
|
||||
allow httpd_t auditd_t:file { read getattr open };
|
||||
allow httpd_t crond_t:dir { search getattr };
|
||||
allow httpd_t crond_t:file { read getattr open };
|
||||
allow httpd_t dhcpc_t:dir { search getattr };
|
||||
allow httpd_t dhcpc_t:file { read getattr open };
|
||||
allow httpd_t getty_t:dir { search getattr };
|
||||
allow httpd_t getty_t:file { read getattr open };
|
||||
allow httpd_t httpd_log_t:file write;
|
||||
allow httpd_t httpd_var_lib_t:lnk_file { write getattr read lock unlink };
|
||||
allow httpd_t init_t:dir { search getattr };
|
||||
allow httpd_t init_t:file { read getattr open };
|
||||
#!!!! The source type 'httpd_t' can write to a 'file' of the following types:
|
||||
#squirrelmail_spool_t, mirrormanager_var_run_t, dirsrvadmin_config_t, httpd_lock_t, httpd_tmp_t, dirsrv_config_t, dirsrvadmin_tmp_t, httpd_cache_t, httpd_tmpfs_t, httpd_squirrelmail_t, dirsrv_var_run_t, dirsrv_var_log_t, httpd_var_lib_t, httpd_var_run_t, zarafa_var_lib_t, httpd_prewikka_rw_content_t, httpd_mediawiki_rw_content_t, httpd_squid_rw_content_t, passenger_var_run_t, httpd_smokeping_cgi_rw_content_t, httpd_openshift_rw_content_t, httpd_dirsrvadmin_rw_content_t, httpd_w3c_validator_rw_content_t, httpd_collectd_rw_content_t, cluster_var_lib_t, cluster_var_run_t, httpd_user_rw_content_t, httpd_awstats_rw_content_t, httpdcontent, root_t, httpd_cobbler_rw_content_t, httpd_munin_rw_content_t, cluster_conf_t, httpd_bugzilla_rw_content_t, passenger_tmp_t, httpd_cvs_rw_content_t, httpd_git_rw_content_t, httpd_sys_rw_content_t, httpd_sys_rw_content_t, httpd_nagios_rw_content_t, httpd_apcupsd_cgi_rw_content_t, httpd_nutups_cgi_rw_content_t, httpd_dspam_rw_content_t
|
||||
|
||||
allow httpd_t initrc_state_t:file { read write getattr unlink open };
|
||||
allow httpd_t initrc_t:unix_stream_socket connectto;
|
||||
allow httpd_t initrc_t:shm { unix_read unix_write associate read write getattr };
|
||||
allow httpd_t initrc_var_run_t:file { write read lock open };
|
||||
allow httpd_t kernel_t:dir { search getattr };
|
||||
allow httpd_t kernel_t:file { read getattr open };
|
||||
allow httpd_t mysqld_safe_t:dir { search getattr };
|
||||
allow httpd_t mysqld_safe_t:file { read getattr open };
|
||||
allow httpd_t mysqld_t:dir { search getattr };
|
||||
allow httpd_t mysqld_t:file { read getattr open };
|
||||
allow httpd_t sshd_t:dir { search getattr };
|
||||
allow httpd_t sshd_t:file { read getattr open };
|
||||
allow httpd_t syslogd_t:dir { search getattr };
|
||||
allow httpd_t syslogd_t:file { read getattr open };
|
||||
allow httpd_t tmpfs_t:sock_file write;
|
||||
allow httpd_t udev_t:dir { search getattr };
|
||||
allow httpd_t udev_t:file { read getattr open };
|
||||
allow httpd_t unconfined_t:dir { search getattr };
|
||||
allow httpd_t unconfined_t:file { read getattr open };
|
||||
allow httpd_t var_lib_t:lnk_file { write getattr read lock unlink };
|
||||
allow httpd_t var_lib_t:sock_file { write unlink };
|
||||
allow httpd_t v4l_device_t:chr_file getattr;
|
||||
allow httpd_t afs_fs_port_t:udp_socket name_bind;
|
||||
allow httpd_t afs_ka_port_t:udp_socket name_bind;
|
||||
allow httpd_t afs_pt_port_t:udp_socket name_bind;
|
||||
allow httpd_t amqp_port_t:udp_socket name_bind;
|
||||
allow httpd_t aol_port_t:udp_socket name_bind;
|
||||
allow httpd_t commplex_port_t:udp_socket name_bind;
|
||||
allow httpd_t condor_port_t:udp_socket name_bind;
|
||||
allow httpd_t dcc_port_t:udp_socket name_bind;
|
||||
allow httpd_t git_port_t:udp_socket name_bind;
|
||||
allow httpd_t glance_port_t:udp_socket name_bind;
|
||||
allow httpd_t httpd_var_lib_t:lnk_file create;
|
||||
allow httpd_t ionixnetmon_port_t:udp_socket name_bind;
|
||||
allow httpd_t ipp_port_t:udp_socket name_bind;
|
||||
allow httpd_t mmcc_port_t:udp_socket name_bind;
|
||||
allow httpd_t netsupport_port_t:udp_socket name_bind;
|
||||
allow httpd_t nodejs_debug_port_t:udp_socket name_bind;
|
||||
allow httpd_t port_t:udp_socket name_bind;
|
||||
allow httpd_t postfix_master_t:dir { search getattr };
|
||||
allow httpd_t postfix_master_t:file { read getattr open };
|
||||
allow httpd_t postfix_pickup_t:dir { search getattr };
|
||||
allow httpd_t postfix_pickup_t:file { read getattr open };
|
||||
allow httpd_t postfix_qmgr_t:dir { search getattr };
|
||||
allow httpd_t postfix_qmgr_t:file { read getattr open };
|
||||
allow httpd_t presence_port_t:udp_socket name_bind;
|
|
@ -1,165 +0,0 @@
|
|||
What's New
|
||||
==========
|
||||
|
||||
1. This is an *experimental* build of zoneminder which uses the
|
||||
nginx web server.
|
||||
|
||||
2. The Apache ScriptAlias has been changed from "/cgi-bin/zm/zms" to
|
||||
"/cgi-bin-zm/zms". This has been to done to avoid this bug:
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=973067
|
||||
|
||||
IMPORTANT: You must manually inspect the value for PATH_ZMS under Options
|
||||
and verify it is set to "/cgi-bin-zm/nph-zms". Failure to do so will result
|
||||
in a broken system. You have been warned.
|
||||
|
||||
3. Due to the active state of the ZoneMinder project, we now recommend granting
|
||||
ALL permission to the ZoneMinder mysql account. This change must be done
|
||||
manually before ZoneMinder will run. See the installation steps below.
|
||||
|
||||
4. This package uses the HTTPS protocol by default to access the web portal.
|
||||
Requests using HTTP will auto-redirect to HTTPS. See README.https for
|
||||
more information.
|
||||
|
||||
5. This package ships with the new ZoneMinder API enabled.
|
||||
|
||||
New installs
|
||||
============
|
||||
|
||||
1. This package supports either community-mysql-server or mariadb-server with
|
||||
mariadb being the preferred choice. Unless you are already using MariaDB or
|
||||
Mysql server, you need to ensure that the server is configured to start
|
||||
during boot and properly secured by running:
|
||||
|
||||
sudo dnf install mariadb-server
|
||||
sudo systemctl enable mariadb
|
||||
sudo systemctl start mariadb.service
|
||||
mysql_secure_installation
|
||||
|
||||
2. Assuming the database is local and using the password for the root account
|
||||
set during the previous step, you will need to create the ZoneMinder
|
||||
database and configure a database account for ZoneMinder to use:
|
||||
|
||||
mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
|
||||
mysql -uroot -p -e "grant all on zm.* to \
|
||||
'zmuser'@localhost identified by 'zmpass';"
|
||||
mysqladmin -uroot -p reload
|
||||
|
||||
The database account credentials, zmuser/zmpass, are arbitrary. Set them to
|
||||
anything that suits your environment.
|
||||
|
||||
3. If you have chosen to change the zoneminder database account credentials to
|
||||
something other than zmuser/zmpass, you must now edit /etc/zm/zm.conf.
|
||||
Change ZM_DB_USER and ZM_DB_PASS to the values you created in the previous
|
||||
step.
|
||||
|
||||
This version of zoneminder no longer requires you to make a similar change
|
||||
to the credentials in /usr/share/zoneminder/www/api/app/Config/database.php
|
||||
This now happens dynamically. Do *not* make any changes to this file.
|
||||
|
||||
4. Edit /etc/php.ini, uncomment the date.timezone line, and add your local
|
||||
timezone. PHP will complain loudly if this is not set, or if it is set
|
||||
incorrectly, and these complaints will show up in the zoneminder logging
|
||||
system as errors.
|
||||
|
||||
If you are not sure of the proper timezone specification to use, look at
|
||||
http://php.net/date.timezone
|
||||
|
||||
5. Disable SELinux
|
||||
|
||||
We currently do not have the resources to create and maintain an accurate
|
||||
SELinux policy for ZoneMinder on Fedora. We will gladly accept pull
|
||||
reqeusts from anyone who wishes to do the work. In the meantime, SELinux
|
||||
will need to be disabled or put into permissive mode.
|
||||
|
||||
To immediately disbale SELinux for the current seesion, issue the following
|
||||
from the command line:
|
||||
|
||||
sudo setenforce 0
|
||||
|
||||
To permanently disable SELinux, edit /etc/selinux/config and change the
|
||||
SELINUX line from "enforcing" to "disabled". This change will take
|
||||
effect after a reboot.
|
||||
|
||||
6. This package comes preconfigured for HTTPS using the default self signed
|
||||
certificate on your system. We recommend you keep this configuration.
|
||||
|
||||
If this does not meet your needs, then read README.https to
|
||||
learn about alternatives.
|
||||
|
||||
7. Edit /etc/sysconfig/fcgiwrap and set DAEMON_PROCS to the maximum number of
|
||||
simulatneous streams the server should support. Generally, a good minimum
|
||||
value for this equals the total number of cameras you expect to view at the
|
||||
same time.
|
||||
|
||||
8. Now start the web server:
|
||||
|
||||
sudo systemctl enable nginx
|
||||
sudo systemctl start nginx
|
||||
|
||||
9. Now start zoneminder:
|
||||
|
||||
sudo systemctl enable zoneminder
|
||||
sudo systemctl start zoneminder
|
||||
|
||||
10.The Fedora repos have a ZoneMinder package available, but it does not
|
||||
support ffmpeg or libvlc, which many modern IP cameras require. Most users
|
||||
will want to prevent the ZoneMinder package in the Fedora repos from
|
||||
overwriting the ZoneMinder package in zmrepo, during a future dnf update. To
|
||||
prevent that from happening you must edit /etc/yum.repos.d/fedora.repo
|
||||
and /etc/yum.repos.d/fedora-updates.repo. Add the line "exclude=zoneminder*"
|
||||
without the quotes under the [fedora] and [fedora-updates] blocks,
|
||||
respectively.
|
||||
|
||||
Upgrades
|
||||
========
|
||||
|
||||
1. Verify /etc/zm/zm.conf.
|
||||
|
||||
If zm.conf was manually edited before running the upgrade, the installation
|
||||
may not overwrite it. In this case, it will create the file
|
||||
/etc/zm/zm.conf.rpmnew.
|
||||
|
||||
For example, this will happen if you are using database account credentials
|
||||
other than zmuser/zmpass.
|
||||
|
||||
Compare /etc/zm/zm.conf to /etc/zm/zm.conf.rpmnew. Verify that zm.conf
|
||||
contains any new config settings that may be in zm.conf.rpmnew.
|
||||
|
||||
This version of zoneminder no longer requires you to make a similar change
|
||||
to the credentials in /usr/share/zoneminder/www/api/app/Config/database.php
|
||||
This now happens dynamically. Do *not* make any changes to this file.
|
||||
|
||||
2. Verify permissions of the zmuser account.
|
||||
|
||||
Over time, the database account permissions required for normal operation
|
||||
have increased. Verify the zmuser database account has been granted all
|
||||
permission to the ZoneMinder database:
|
||||
|
||||
mysql -uroot -p -e "show grants for zmuser@localhost;"
|
||||
|
||||
See step 2 of the Installation section to add missing permissions.
|
||||
|
||||
3. Verify the ZoneMinder Apache configuration file in the folder
|
||||
/etc/httpd/conf.d. You will have a file called "zoneminder.conf" and there
|
||||
may also be a file called "zoneminder.conf.rpmnew". If the rpmnew file
|
||||
exists, inspect it and merge anything new in that file with zoneminder.conf.
|
||||
Verify the SSL REquirements meet your needs. Read README.https if necessary.
|
||||
|
||||
4. Upgrade the database before starting ZoneMinder.
|
||||
|
||||
Most upgrades can be performed by executing the following command:
|
||||
|
||||
sudo zmupdate.pl
|
||||
|
||||
Recent versions of ZoneMinder don't require any parameters added to the
|
||||
zmupdate command. However, if ZoneMinder complains, you may need to call
|
||||
zmupdate in the following manner:
|
||||
|
||||
sudo zmupdate.pl --user=root --pass=<mysql_root_pwd> --version=<from version>
|
||||
|
||||
5. Now restart nginx and php-fpm then start and zoneminder:
|
||||
|
||||
sudo systemctl restart nginx
|
||||
sudo systemctl restart php-fpm
|
||||
sudo systemctl start zoneminder
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
polkit.addRule(function(action, subject) {
|
||||
if (action.id == "com.zoneminder.policykit.pkexec.run-zmsystemctl" &&
|
||||
subject.user != "nginx") {
|
||||
return polkit.Result.NO;
|
||||
}
|
||||
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
# Auto redirect to https
|
||||
return 301 https://$host$request_uri;
|
|
@ -0,0 +1,9 @@
|
|||
# Additional config directives for ZoneMinder with Nginx web server
|
||||
|
||||
[Unit]
|
||||
After=nginx.service php-fpm.service fcgiwrap.service
|
||||
Requires=php-fpm.service fcgiwrap@nginx.service
|
||||
|
||||
[Service]
|
||||
User=nginx
|
||||
Group=nginx
|
|
@ -0,0 +1,3 @@
|
|||
ZM_WEB_USER=nginx
|
||||
ZM_WEB_GROUP=nginx
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
ssl_certificate "/etc/pki/tls/certs/localhost.crt";
|
||||
ssl_certificate_key "/etc/pki/tls/private/localhost.key";
|
||||
ssl_session_cache shared:SSL:1m;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_ciphers PROFILE=SYSTEM;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Auto-redirect HTTP requests to HTTPS
|
||||
if ($scheme != "https") {
|
||||
rewrite ^/?(zm)(.*)$ https://$host/$1$2 permanent;
|
||||
}
|
||||
|
||||
location /cgi-bin-zm {
|
||||
gzip off;
|
||||
alias "@ZM_CGIDIR@";
|
||||
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_pass unix:/run/fcgiwrap.sock;
|
||||
}
|
||||
|
||||
location /zm {
|
||||
gzip off;
|
||||
alias "@ZM_WEBDIR@";
|
||||
index index.php;
|
||||
|
||||
location ~ \.php$ {
|
||||
if (!-f $request_filename) { return 404; }
|
||||
expires epoch;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_pass unix:/run/php-fpm/www.sock;
|
||||
}
|
||||
|
||||
location ~ \.(jpg|jpeg|gif|png|ico)$ {
|
||||
access_log off;
|
||||
expires 33d;
|
||||
}
|
||||
|
||||
location /zm/api/ {
|
||||
alias "@ZM_WEBDIR@";
|
||||
rewrite ^/zm/api(.+)$ /zm/api/index.php?p=$1 last;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
server {
|
||||
listen 443 ssl default_server;
|
||||
listen [::]:443 ssl default_server;
|
||||
server_name = localhost $hostname;
|
||||
|
||||
ssl_certificate "/etc/pki/tls/certs/localhost.crt";
|
||||
ssl_certificate_key "/etc/pki/tls/private/localhost.key";
|
||||
ssl_session_cache shared:SSL:1m;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_ciphers PROFILE=SYSTEM;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Auto redirect to server/zm when no url suffix was given
|
||||
location = / {
|
||||
return 301 zm;
|
||||
}
|
||||
|
||||
location /cgi-bin-zm {
|
||||
gzip off;
|
||||
alias "@ZM_CGIDIR@";
|
||||
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_pass unix:/run/fcgiwrap.sock;
|
||||
}
|
||||
|
||||
location /zm/cache {
|
||||
alias "@ZM_CACHEDIR@";
|
||||
}
|
||||
|
||||
location /zm {
|
||||
gzip off;
|
||||
alias "@ZM_WEBDIR@";
|
||||
index index.php;
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
expires epoch;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_pass unix:/run/php-fpm/www.sock;
|
||||
}
|
||||
|
||||
location ~ \.(jpg|jpeg|gif|png|ico)$ {
|
||||
access_log off;
|
||||
expires 33d;
|
||||
}
|
||||
|
||||
location /zm/api/ {
|
||||
alias "@ZM_WEBDIR@";
|
||||
rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
D @ZM_TMPDIR@ 0755 nginx nginx
|
||||
D @ZM_SOCKDIR@ 0755 nginx nginx
|
||||
D @ZM_CACHEDIR@ 0755 nginx nginx
|
||||
d @ZM_DIR_EVENTS@ 0755 nginx nginx
|
||||
D @ZM_DIR_IMAGES@ 0755 nginx nginx
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
; This config file is needed when using ZoneMinder with web servers other
|
||||
; than Apache. You can ignore this file if you are using Apache web server.
|
||||
; Change the user and group of the default pool to the web server account
|
||||
[www]
|
||||
|
||||
user = nginx
|
||||
group = nginx
|
||||
|
||||
; These parameters are typically a tradoff between performance and memory
|
||||
; consumption. See the contents of www.conf for details.
|
||||
|
||||
pm = ondemand
|
||||
pm.max_children = 50
|
||||
pm.process_idle_timeout = 10s
|
|
@ -1,10 +0,0 @@
|
|||
# Change the user and group of the default pool to the web server account
|
||||
[www]
|
||||
|
||||
user = @WEB_USER@
|
||||
group = @WEB_GROUP@
|
||||
|
||||
# Uncomment these on machines with little memory
|
||||
#pm = ondemand
|
||||
#pm.max_children = 10
|
||||
#pm.process_idle_timeout = 10s
|
|
@ -1,22 +0,0 @@
|
|||
# ZoneMinder systemd unit file for Fedora
|
||||
# Replace mariadb with community-mysql if using mysql service instead of mariadb
|
||||
|
||||
[Unit]
|
||||
Description=ZoneMinder CCTV recording and security system
|
||||
After=network.target mariadb.service nginx.service php-fpm.service fcgiwrap.service
|
||||
Requires=mariadb.service nginx.service php-fpm.service fcgiwrap.service
|
||||
|
||||
[Service]
|
||||
User=@WEB_USER@
|
||||
Group=@WEB_GROUP@
|
||||
Type=forking
|
||||
ExecStart=@BINDIR@/zmpkg.pl start
|
||||
ExecReload=@BINDIR@/zmpkg.pl restart
|
||||
ExecStop=@BINDIR@/zmpkg.pl stop
|
||||
PIDFile=@ZM_RUNDIR@/zm.pid
|
||||
Environment=TZ=/etc/localtime
|
||||
RuntimeDirectory=zoneminder
|
||||
RuntimeDirectoryMode=0755
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,5 +0,0 @@
|
|||
D @ZM_TMPDIR@ 0755 @WEB_USER@ @WEB_GROUP@
|
||||
D @ZM_SOCKDIR@ 0755 @WEB_USER@ @WEB_GROUP@
|
||||
D /var/lib/php/session 770 root @WEB_GROUP@
|
||||
D /var/lib/php/wsdlcache 770 root @WEB_GROUP@
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
What's New
|
||||
==========
|
||||
|
||||
1. See the ZoneMinder release notes for a list of new features:
|
||||
https://github.com/ZoneMinder/zoneminder/releases
|
||||
|
||||
2. The contents of the ZoneMinder Apache config file have changed. In
|
||||
addition, this ZoneMinder package now requires you to manually symlink the
|
||||
ZoneMinder Apache config file. See new install step 6 and upgrade step 3
|
||||
in the appropriate README for details.
|
||||
|
||||
3. This package has been split into sub-packages to allow compatibility with
|
||||
other web servers. Here is a breakdown of the available packages:
|
||||
|
||||
zoneminder - Meta-package installs zoneminder-common and zoneminder-httpd
|
||||
This exists soley for backwards compatibility.
|
||||
zoneminder-common - Common files that do not differ based on the web server
|
||||
zoneminder-httpd - Files needed for compatibility with the Apache web server
|
||||
zoneminder-nginx - Files needed for compatibility with the Nginx web server
|
||||
|
||||
You can switch between different subpackages with dnf/yum. Be advised that,
|
||||
switching between httpd <-> nginx requires manaully changing ownership of
|
||||
all event folders and the php session folder after the change.
|
||||
|
||||
4. If you have installed ZoneMinder from the FedBerry repositories, this build
|
||||
of ZoneMinder has support for Raspberry Pi hardware acceleration when using
|
||||
ffmpeg. Unforunately, there is a problem with the same hardware acceleration
|
||||
when using libvlc. Consequently, libvlc support in this build of ZoneMinder
|
||||
has been disabled until the problem is resolved. See the following bug
|
||||
report for details: https://trac.videolan.org/vlc/ticket/18594
|
||||
|
||||
5. Continue on to the next README that corresponds to the chosen webserver:
|
||||
|
||||
README.httpd - Follow these steps when using Apache
|
||||
README.nginx - Follow these steps when using Nginx
|
||||
|
|
@ -1,17 +1,8 @@
|
|||
What's New
|
||||
==========
|
||||
|
||||
1. See the ZoneMinder release notes for a list of new features:
|
||||
https://github.com/ZoneMinder/zoneminder/releases
|
||||
|
||||
2. The contents of the ZoneMinder Apache config file have changed. In
|
||||
addition, this ZoneMinder package now requires you to manually symlink the
|
||||
ZoneMinder Apache config file. See new install step 6 and upgrade step 3
|
||||
below for details.
|
||||
|
||||
New installs
|
||||
============
|
||||
|
||||
NOTE: EL7 users should replace "dnf" with "yum" in the instructions below.
|
||||
|
||||
1. Unless you are already using MariaDB server, you need to ensure that the
|
||||
server is configured to start during boot and properly secured by running:
|
||||
|
||||
|
@ -77,14 +68,14 @@ New installs
|
|||
|
||||
Inspect the web server configuration file and verify it meets your needs:
|
||||
|
||||
/etc/zm/www/zoneminder.conf
|
||||
/etc/zm/www/zoneminder.httpd.conf
|
||||
|
||||
If you are running other web enabled services then you may need to edit
|
||||
this file to suite. See README.https to learn about other alternatives.
|
||||
|
||||
When in doubt, proceed with the default:
|
||||
|
||||
sudo ln -s /etc/zm/www/zoneminder.conf /etc/httpd/conf.d/
|
||||
sudo ln -sf /etc/zm/www/zoneminder.httpd.conf /etc/httpd/conf.d/
|
||||
sudo dnf install mod_ssl
|
||||
|
||||
7. Now start the web server:
|
||||
|
@ -146,15 +137,23 @@ Upgrades
|
|||
See step 2 of the Installation section to add missing permissions.
|
||||
|
||||
3. Verify the ZoneMinder Apache configuration file in the folder
|
||||
/etc/zm/www. You will have a file called "zoneminder.conf" and there
|
||||
may also be a file called "zoneminder.conf.rpmnew". If the rpmnew file
|
||||
/etc/zm/www. You will have a file called "zoneminder.httpd.conf" and there
|
||||
may also be one or more files with "rpmnew" extenstion. If the rpmnew file
|
||||
exists, inspect it and merge anything new in that file with zoneminder.conf.
|
||||
Verify the SSL REquirements meet your needs. Read README.https if necessary.
|
||||
Verify the SSL Requirements meet your needs. Read README.https if necessary.
|
||||
|
||||
The contents of this file must be merged into your Apache configuration.
|
||||
See step 6 of the installation section if you have not already done this
|
||||
during a previous upgrade.
|
||||
|
||||
<<<<<<< HEAD
|
||||
If this step is not performed correctly, the web console will appear
|
||||
mostly empty and/or significantly corrupted post-upgrade.
|
||||
=======
|
||||
IMPORTANT: Failure to complete this step properly will result in a mostly
|
||||
empty or significantly corrupted web console post-upgrade.
|
||||
>>>>>>> 5b211d250910918782d20bf32b0e33a38a0df4dd
|
||||
|
||||
4. Upgrade the database before starting ZoneMinder.
|
||||
|
||||
Most upgrades can be performed by executing the following command:
|
|
@ -20,7 +20,8 @@ experience.
|
|||
to do this: https://wiki.centos.org/HowTos/Https . Additionally, Googling
|
||||
"centos certificate" reveals many articles on the subject.
|
||||
|
||||
3. You can turn off HTTPS entirely by simply commenting out the SSLRequireSSL
|
||||
directives found in /etc/httpd/conf.d/zoneminder.conf. You should also
|
||||
comment out the HTTP -> HTTPS Rewrite rule.
|
||||
3. When using Apache, you can turn off HTTPS entirely by simply commenting
|
||||
out the SSLRequireSSL directives found in
|
||||
/etc/zm/www/zoneminder.apache.conf. You should also comment out the
|
||||
HTTP -> HTTPS Rewrite rule.
|
||||
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
What's New
|
||||
==========
|
||||
|
||||
1. See the ZoneMinder release notes for a list of new features:
|
||||
https://github.com/ZoneMinder/zoneminder/releases
|
||||
|
||||
2. The contents of the ZoneMinder Apache config file have changed. In
|
||||
addition, this ZoneMinder package now requires you to manually symlink the
|
||||
ZoneMinder Apache config file. See new install step 6 and upgrade step 3
|
||||
below for details.
|
||||
|
||||
New installs
|
||||
============
|
||||
|
||||
1. Unless you are already using MariaDB server, you need to ensure that the
|
||||
server is configured to start during boot and properly secured by running:
|
||||
|
||||
sudo yum install mariadb-server
|
||||
sudo dnf install mariadb-server
|
||||
sudo systemctl enable mariadb
|
||||
sudo systemctl start mariadb.service
|
||||
mysql_secure_installation
|
||||
|
||||
2. Using the password for the root account set during the previous step, you
|
||||
will need to create the ZoneMinder database and configure a database
|
||||
account for ZoneMinder to use:
|
||||
2. Assuming the database is local and using the password for the root account
|
||||
set during the previous step, you will need to create the ZoneMinder
|
||||
database and configure a database account for ZoneMinder to use:
|
||||
|
||||
mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
|
||||
mysql -uroot -p -e "grant all on zm.* to \
|
||||
|
@ -42,7 +31,7 @@ New installs
|
|||
|
||||
Once the file has been saved, set proper file & ownership permissions on it:
|
||||
|
||||
sudo chown root:apache *.conf
|
||||
sudo chown root:nginx *.conf
|
||||
sudo chmod 640 *.conf
|
||||
|
||||
4. Edit /etc/php.ini, uncomment the date.timezone line, and add your local
|
||||
|
@ -56,7 +45,7 @@ New installs
|
|||
5. Disable SELinux
|
||||
|
||||
We currently do not have the resources to create and maintain an accurate
|
||||
SELinux policy for ZoneMinder on CentOS 7. We will gladly accept pull
|
||||
SELinux policy for ZoneMinder on Fedora. We will gladly accept pull
|
||||
reqeusts from anyone who wishes to do the work. In the meantime, SELinux
|
||||
will need to be disabled or put into permissive mode.
|
||||
|
||||
|
@ -72,8 +61,7 @@ New installs
|
|||
6. Configure the web server
|
||||
|
||||
This package uses the HTTPS protocol by default to access the web portal,
|
||||
using the default self signed certificate on your system. Requests using
|
||||
HTTP will auto-redirect to HTTPS.
|
||||
using the default self signed certificate on your system.
|
||||
|
||||
Inspect the web server configuration file and verify it meets your needs:
|
||||
|
||||
|
@ -82,22 +70,30 @@ New installs
|
|||
If you are running other web enabled services then you may need to edit
|
||||
this file to suite. See README.https to learn about other alternatives.
|
||||
|
||||
If you wish http requests to auto-redirect to https requests, then link or
|
||||
copy /etc/zm/www/redirect.nginx.conf into /etc/nginx/default.d folder.
|
||||
|
||||
When in doubt, proceed with the default:
|
||||
|
||||
sudo ln -s /etc/zm/www/zoneminder.conf /etc/httpd/conf.d/
|
||||
sudo yum install mod_ssl
|
||||
sudo ln -sf /etc/zm/www/zoneminder.nginx.conf /etc/nginx/conf.d/
|
||||
sudo ln -sf /etc/zm/www/redirect.nginx.conf /etc/nginx/default.d/
|
||||
|
||||
7. Now start the web server:
|
||||
7. Edit /etc/sysconfig/fcgiwrap and set DAEMON_PROCS to the maximum number of
|
||||
simulatneous streams the server should support. Generally, a good minimum
|
||||
value for this equals the total number of cameras you expect to view at the
|
||||
same time.
|
||||
|
||||
sudo systemctl enable httpd
|
||||
sudo systemctl start httpd
|
||||
8. Now start the web server:
|
||||
|
||||
8. Now start zoneminder:
|
||||
sudo systemctl enable nginx
|
||||
sudo systemctl start nginx
|
||||
|
||||
9. Now start zoneminder:
|
||||
|
||||
sudo systemctl enable zoneminder
|
||||
sudo systemctl start zoneminder
|
||||
|
||||
9. Optionally configure the firewall
|
||||
10. Optionally configure the firewall
|
||||
|
||||
All Redhat distros ship with the firewall enabled. That means you will not
|
||||
be able to access the ZoneMinder web console from a remote machine until
|
||||
|
@ -117,7 +113,7 @@ New installs
|
|||
security requirements and how you use the system. It is up to you to verify
|
||||
these commands are sufficient.
|
||||
|
||||
10. Access the ZoneMinder web console
|
||||
11. Access the ZoneMinder web console
|
||||
|
||||
You may now access the ZoneMinder web console from your web browser using
|
||||
an appropriate url. Here are some examples:
|
||||
|
@ -145,13 +141,13 @@ Upgrades
|
|||
|
||||
See step 2 of the Installation section to add missing permissions.
|
||||
|
||||
3. Verify the ZoneMinder Apache configuration file in the folder
|
||||
3. Verify the ZoneMinder Nginx configuration file in the folder
|
||||
/etc/zm/www. You will have a file called "zoneminder.conf" and there
|
||||
may also be a file called "zoneminder.conf.rpmnew". If an rpmnew file
|
||||
may also be a file called "zoneminder.conf.rpmnew". If the rpmnew file
|
||||
exists, inspect it and merge anything new in that file with zoneminder.conf.
|
||||
Verify the SSL REquirements meet your needs. Read README.https if necessary.
|
||||
|
||||
The contents of this file must be merged into your Apache configuration.
|
||||
The contents of this file must be merged into your Nginx configuration.
|
||||
See step 6 of the installation section if you have not already done this
|
||||
during a previous upgrade.
|
||||
|
||||
|
@ -167,9 +163,9 @@ Upgrades
|
|||
|
||||
sudo zmupdate.pl --user=root --pass=<mysql_root_pwd> --version=<from version>
|
||||
|
||||
5. Now restart the web server then start zoneminder:
|
||||
5. Now restart nginx and php-fpm then start zoneminder:
|
||||
|
||||
sudo systemctl restart httpd
|
||||
sudo systemctl restart nginx
|
||||
sudo systemctl restart php-fpm
|
||||
sudo systemctl start zoneminder
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
@ZM_LOGDIR@/*.log {
|
||||
missingok
|
||||
notifempty
|
||||
sharedscripts
|
||||
postrotate
|
||||
@BINDIR@/zmpkg.pl logrot 2> /dev/null > /dev/null || :
|
||||
endscript
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
# Leaving this to allow one to build zoneminder-http subpackage using arbitrary user account
|
||||
%global zmuid_final apache
|
||||
%global zmgid_final apache
|
||||
|
||||
|
@ -7,10 +8,6 @@
|
|||
# CakePHP-Enum-Behavior is configured as a git submodule
|
||||
%global ceb_version 1.0-zm
|
||||
|
||||
%if "%{zmuid_final}" == "nginx"
|
||||
%global with_nginx 1
|
||||
%endif
|
||||
|
||||
%global sslcert %{_sysconfdir}/pki/tls/certs/localhost.crt
|
||||
%global sslkey %{_sysconfdir}/pki/tls/private/localhost.key
|
||||
|
||||
|
@ -22,10 +19,11 @@
|
|||
%global with_apcu_bc 1
|
||||
%endif
|
||||
|
||||
# The default for everything but el7 these days
|
||||
%global _hardened_build 1
|
||||
|
||||
Name: zoneminder
|
||||
Version: 1.32.1
|
||||
Version: 1.33.0
|
||||
Release: 1%{?dist}
|
||||
Summary: A camera monitoring and analysis tool
|
||||
Group: System Environment/Daemons
|
||||
|
@ -44,7 +42,7 @@ BuildRequires: systemd-devel
|
|||
BuildRequires: mariadb-devel
|
||||
BuildRequires: perl-podlators
|
||||
BuildRequires: polkit-devel
|
||||
BuildRequires: cmake >= 2.8.7
|
||||
BuildRequires: cmake3
|
||||
BuildRequires: gnutls-devel
|
||||
BuildRequires: bzip2-devel
|
||||
BuildRequires: pcre-devel
|
||||
|
@ -74,6 +72,7 @@ BuildRequires: vlc-devel
|
|||
BuildRequires: libcurl-devel
|
||||
BuildRequires: libv4l-devel
|
||||
BuildRequires: desktop-file-utils
|
||||
BuildRequires: gzip
|
||||
|
||||
# ZoneMinder looks for and records the location of the ffmpeg binary during build
|
||||
BuildRequires: ffmpeg
|
||||
|
@ -83,11 +82,25 @@ BuildRequires: ffmpeg-devel
|
|||
BuildRequires: libmp4v2-devel
|
||||
BuildRequires: x264-devel
|
||||
|
||||
%{?with_nginx:Requires: nginx}
|
||||
%{?with_nginx:Requires: fcgiwrap}
|
||||
%{?with_nginx:Requires: php-fpm}
|
||||
%{!?with_nginx:Requires: httpd}
|
||||
%{!?with_nginx:Requires: php}
|
||||
# Allow existing user base to seamlessly transition to sub-packages
|
||||
Requires: %{name}-common%{?_isa} = %{version}-%{release}
|
||||
Requires: %{name}-httpd%{?_isa} = %{version}-%{release}
|
||||
|
||||
%description
|
||||
ZoneMinder is a set of applications which is intended to provide a complete
|
||||
solution allowing you to capture, analyze, record and monitor any cameras you
|
||||
have attached to a Linux based machine. It is designed to run on kernels which
|
||||
support the Video For Linux (V4L) interface and has been tested with cameras
|
||||
attached to BTTV cards, various USB cameras and IP network cameras. It is
|
||||
designed to support as many cameras as you can attach to your computer without
|
||||
too much degradation of performance.
|
||||
|
||||
This is a meta package for backwards compatibility with the existing
|
||||
ZoneMinder user base.
|
||||
|
||||
%package common
|
||||
Summary: Common files for ZoneMinder, not tied to a specific web server
|
||||
|
||||
Requires: php-mysqli
|
||||
Requires: php-common
|
||||
Requires: php-gd
|
||||
|
@ -112,16 +125,12 @@ Requires: perl(Net::FTP)
|
|||
Requires: perl(LWP::Protocol::https)
|
||||
Requires: ca-certificates
|
||||
Requires: zip
|
||||
|
||||
Requires(post): systemd
|
||||
Requires(post): systemd-sysv
|
||||
Requires(preun): systemd
|
||||
Requires(postun): systemd
|
||||
%{?systemd_requires}
|
||||
|
||||
Requires(post): %{_bindir}/gpasswd
|
||||
Requires(post): %{_bindir}/less
|
||||
Requires(post): %{_bindir}/chown
|
||||
|
||||
%description
|
||||
%description common
|
||||
ZoneMinder is a set of applications which is intended to provide a complete
|
||||
solution allowing you to capture, analyze, record and monitor any cameras you
|
||||
have attached to a Linux based machine. It is designed to run on kernels which
|
||||
|
@ -130,15 +139,57 @@ attached to BTTV cards, various USB cameras and IP network cameras. It is
|
|||
designed to support as many cameras as you can attach to your computer without
|
||||
too much degradation of performance.
|
||||
|
||||
This is a meta-package that exists solely to allow the existing user base to
|
||||
seamlessly transition to sub-packages.
|
||||
|
||||
%package httpd
|
||||
Summary: ZoneMinder configuration for Apache web server
|
||||
Requires: %{name}-common%{?_isa} = %{version}-%{release}
|
||||
Requires: httpd
|
||||
Requires: php
|
||||
|
||||
Conflicts: %{name}-nginx
|
||||
|
||||
%description httpd
|
||||
ZoneMinder is a set of applications which is intended to provide a complete
|
||||
solution allowing you to capture, analyze, record and monitor any cameras you
|
||||
have attached to a Linux based machine. It is designed to run on kernels which
|
||||
support the Video For Linux (V4L) interface and has been tested with cameras
|
||||
attached to BTTV cards, various USB cameras and IP network cameras. It is
|
||||
designed to support as many cameras as you can attach to your computer without
|
||||
too much degradation of performance.
|
||||
|
||||
This sub-package contains configuration specific to Apache web server
|
||||
|
||||
%package nginx
|
||||
Summary: ZoneMinder configuration for Nginx web server
|
||||
Requires: %{name}-common%{?_isa} = %{version}-%{release}
|
||||
Requires: nginx
|
||||
Requires: php-fpm
|
||||
Requires: fcgiwrap
|
||||
|
||||
Conflicts: %{name}-httpd
|
||||
|
||||
%description nginx
|
||||
ZoneMinder is a set of applications which is intended to provide a complete
|
||||
solution allowing you to capture, analyze, record and monitor any cameras you
|
||||
have attached to a Linux based machine. It is designed to run on kernels which
|
||||
support the Video For Linux (V4L) interface and has been tested with cameras
|
||||
attached to BTTV cards, various USB cameras and IP network cameras. It is
|
||||
designed to support as many cameras as you can attach to your computer without
|
||||
too much degradation of performance.
|
||||
|
||||
This sub-package contains support for ZoneMinder with the Nginx web server
|
||||
|
||||
%prep
|
||||
%autosetup -p 1 -a 1 -n ZoneMinder-%{version}
|
||||
%{__rm} -rf ./web/api/app/Plugin/Crud
|
||||
%{__mv} -f crud-%{crud_version} ./web/api/app/Plugin/Crud
|
||||
%autosetup -p 1 -a 1
|
||||
rm -rf ./web/api/app/Plugin/Crud
|
||||
mv -f crud-%{crud_version} ./web/api/app/Plugin/Crud
|
||||
|
||||
# The all powerful autosetup macro does not work after the second source tarball
|
||||
%{__gzip} -dc %{_sourcedir}/cakephp-enum-behavior-%{ceb_version}.tar.gz | tar -xvvf -
|
||||
%{__rm} -rf ./web/api/app/Plugin/CakePHP-Enum-Behavior
|
||||
%{__mv} -f CakePHP-Enum-Behavior-%{ceb_version} ./web/api/app/Plugin/CakePHP-Enum-Behavior
|
||||
gzip -dc %{_sourcedir}/cakephp-enum-behavior-%{ceb_version}.tar.gz | tar -xvvf -
|
||||
rm -rf ./web/api/app/Plugin/CakePHP-Enum-Behavior
|
||||
mv -f CakePHP-Enum-Behavior-%{ceb_version} ./web/api/app/Plugin/CakePHP-Enum-Behavior
|
||||
|
||||
# Change the following default values
|
||||
./utils/zmeditconfigdata.sh ZM_OPT_CAMBOZOLA yes
|
||||
|
@ -149,9 +200,9 @@ too much degradation of performance.
|
|||
./utils/zmeditconfigdata.sh ZM_OPT_FAST_DELETE no
|
||||
|
||||
%build
|
||||
%cmake \
|
||||
%cmake3 \
|
||||
-DZM_WEB_USER="%{zmuid_final}" \
|
||||
-DZM_WEB_GROUP="%{zmuid_final}" \
|
||||
-DZM_WEB_GROUP="%{zmgid_final}" \
|
||||
-DZM_TARGET_DISTRO="%{zmtargetdistro}" \
|
||||
.
|
||||
|
||||
|
@ -173,10 +224,13 @@ find %{buildroot} \( -name .htaccess -or -name .editorconfig -or -name .packlist
|
|||
find %{buildroot}%{_datadir}/zoneminder/www/api \( -name cake -or -name cake.php \) -type f -exec sed -i 's\^#!/usr/bin/env bash$\#!%{_buildshell}\' {} \; -exec %{__chmod} 755 {} \;
|
||||
|
||||
# Use the system cacert file rather then the one bundled with CakePHP
|
||||
%{__rm} -f %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem
|
||||
%{__ln_s} ../../../../../../../..%{_sysconfdir}/pki/tls/certs/ca-bundle.crt %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem
|
||||
rm -f %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem
|
||||
ln -s ../../../../../../../..%{_sysconfdir}/pki/tls/certs/ca-bundle.crt %{buildroot}%{_datadir}/zoneminder/www/api/lib/Cake/Config/cacert.pem
|
||||
|
||||
%post
|
||||
# Handle the polkit file differently for web server agnostic support (see post)
|
||||
rm -f %{buildroot}%{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules
|
||||
|
||||
%post common
|
||||
# Initial installation
|
||||
if [ $1 -eq 1 ] ; then
|
||||
%systemd_post %{name}.service
|
||||
|
@ -184,28 +238,48 @@ fi
|
|||
|
||||
# Upgrade from a previous version of zoneminder
|
||||
if [ $1 -eq 2 ] ; then
|
||||
|
||||
# Add any new PTZ control configurations to the database (will not overwrite)
|
||||
%{_bindir}/zmcamtool.pl --import >/dev/null 2>&1 || :
|
||||
|
||||
# Freshen the database
|
||||
%{_bindir}/zmupdate.pl -f >/dev/null 2>&1 || :
|
||||
|
||||
# We can't run this automatically when new sql account permissions need to
|
||||
# be manually added first
|
||||
# Run zmupdate non-interactively
|
||||
# zmupdate.pl --nointeractive
|
||||
fi
|
||||
|
||||
# Warn the end user to read the README file
|
||||
echo -e "\nVERY IMPORTANT: Before starting ZoneMinder, you must read the README file\nto finish the installation or upgrade!"
|
||||
echo -e "\nThe README file is located here: %{_pkgdocdir}-common/README\n"
|
||||
|
||||
%post httpd
|
||||
# For the case of changing from nginx <-> httpd, files in these folders must change ownership if they exist
|
||||
%{_bindir}/chown -R %{zmuid_final}:%{zmgid_final} %{_sharedstatedir}/php/session/* >/dev/null 2>&1 || :
|
||||
%{_bindir}/chown -R %{zmuid_final}:%{zmgid_final} %{_localstatedir}/log/zoneminder/* >/dev/null 2>&1 || :
|
||||
|
||||
ln -sf %{_sysconfdir}/zm/www/com.zoneminder.systemctl.rules.httpd %{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules
|
||||
# backwards compatibility
|
||||
ln -sf %{_sysconfdir}/zm/www/zoneminder.httpd.conf %{_sysconfdir}/zm/www/zoneminder.conf
|
||||
|
||||
# Allow zoneminder access to local video sources, serial ports, and x10
|
||||
%{_bindir}/gpasswd -a %{zmuid_final} video >/dev/null 2>&1 || :
|
||||
%{_bindir}/gpasswd -a %{zmuid_final} dialout >/dev/null 2>&1 || :
|
||||
|
||||
# Warn the end user to read the README file
|
||||
echo -e "\nVERY IMPORTANT: Before starting ZoneMinder, you must read the README file\nto finish the installation or upgrade!"
|
||||
echo -e "\nThe README file is located here: %{_pkgdocdir}/README\n"
|
||||
%post nginx
|
||||
|
||||
# Php package owns the session folder and sets group ownership to apache account
|
||||
# We could override the folder permission, but adding nginx to the apache group works better
|
||||
%{_bindir}/gpasswd -a nginx apache >/dev/null 2>&1 || :
|
||||
|
||||
# For the case of changing from httpd <-> nginx, files in these folders must change ownership if they exist
|
||||
%{_bindir}/chown -R nginx:nginx %{_sharedstatedir}/php/session/* >/dev/null 2>&1 || :
|
||||
%{_bindir}/chown -R nginx:nginx %{_localstatedir}/log/zoneminder/* >/dev/null 2>&1 || :
|
||||
|
||||
ln -sf %{_sysconfdir}/zm/www/com.zoneminder.systemctl.rules.nginx %{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules
|
||||
# backwards compatibility
|
||||
ln -sf %{_sysconfdir}/zm/www/zoneminder.nginx.conf %{_sysconfdir}/zm/www/zoneminder.conf
|
||||
|
||||
# Allow zoneminder access to local video sources, serial ports, and x10
|
||||
%{_bindir}/gpasswd -a nginx video >/dev/null 2>&1 || :
|
||||
%{_bindir}/gpasswd -a nginx dialout >/dev/null 2>&1 || :
|
||||
|
||||
%if 0%{?with_nginx}
|
||||
# Nginx does not create an SSL certificate like the apache package does so lets do that here
|
||||
if [ -f %{sslkey} -o -f %{sslcert} ]; then
|
||||
exit 0
|
||||
|
@ -231,7 +305,6 @@ SomeOrganizationalUnit
|
|||
${FQDN}
|
||||
root@${FQDN}
|
||||
EOF
|
||||
%endif
|
||||
|
||||
%preun
|
||||
%systemd_preun %{name}.service
|
||||
|
@ -239,19 +312,12 @@ EOF
|
|||
%postun
|
||||
%systemd_postun_with_restart %{name}.service
|
||||
|
||||
%triggerun -- zoneminder < 1.25.0-4
|
||||
# Save the current service runlevel info
|
||||
# User must manually run systemd-sysv-convert --apply zoneminder
|
||||
# to migrate them to systemd targets
|
||||
%{_bindir}/systemd-sysv-convert --save zoneminder >/dev/null 2>&1 ||:
|
||||
|
||||
# Run these because the SysV package being removed won't do them
|
||||
/sbin/chkconfig --del zoneminder >/dev/null 2>&1 || :
|
||||
/bin/systemctl try-restart zoneminder.service >/dev/null 2>&1 || :
|
||||
|
||||
%files
|
||||
# nothing
|
||||
|
||||
%files common
|
||||
%license COPYING
|
||||
%doc AUTHORS README.md distros/redhat/readme/README distros/redhat/readme/README.https
|
||||
%doc AUTHORS README.md distros/redhat/readme/README distros/redhat/readme/README.httpd distros/redhat/readme/README.nginx distros/redhat/readme/README.https
|
||||
|
||||
# We want these two folders to have "normal" read permission
|
||||
# compared to the folder contents
|
||||
|
@ -261,21 +327,11 @@ EOF
|
|||
# Config folder contents contain sensitive info
|
||||
# and should not be readable by normal users
|
||||
%{_sysconfdir}/zm/conf.d/README
|
||||
%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/zm.conf
|
||||
%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/*.conf
|
||||
%ghost %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/zmcustom.conf
|
||||
|
||||
%config(noreplace) %attr(644,root,root) /etc/zm/www/zoneminder.conf
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/zoneminder
|
||||
|
||||
%if 0%{?with_nginx}
|
||||
%config(noreplace) %{_sysconfdir}/php-fpm.d/zoneminder.conf
|
||||
%endif
|
||||
|
||||
%{_tmpfilesdir}/zoneminder.conf
|
||||
%{_unitdir}/zoneminder.service
|
||||
%{_datadir}/polkit-1/actions/com.zoneminder.systemctl.policy
|
||||
%{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules
|
||||
%{_bindir}/zmsystemctl.pl
|
||||
|
||||
%{_bindir}/zma
|
||||
|
@ -306,8 +362,19 @@ EOF
|
|||
|
||||
%{_libexecdir}/zoneminder/
|
||||
%{_datadir}/zoneminder/
|
||||
%{_datadir}/applications/*%{name}.desktop
|
||||
%{_datadir}/applications/*zoneminder.desktop
|
||||
|
||||
%files httpd
|
||||
%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/zm.conf
|
||||
%config(noreplace) %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/0*.conf
|
||||
%ghost %attr(640,root,%{zmgid_final}) %{_sysconfdir}/zm/conf.d/zmcustom.conf
|
||||
%config(noreplace) %{_sysconfdir}/zm/www/zoneminder.httpd.conf
|
||||
%ghost %{_sysconfdir}/zm/www/zoneminder.conf
|
||||
%config(noreplace) %{_sysconfdir}/zm/www/com.zoneminder.systemctl.rules.httpd
|
||||
%ghost %{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules
|
||||
|
||||
%{_unitdir}/zoneminder.service.d/zm-httpd.conf
|
||||
%{_tmpfilesdir}/zoneminder.httpd.tmpfiles.conf
|
||||
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder
|
||||
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder/events
|
||||
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_sharedstatedir}/zoneminder/images
|
||||
|
@ -317,9 +384,51 @@ EOF
|
|||
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/cache/zoneminder
|
||||
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/log/zoneminder
|
||||
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/spool/zoneminder-upload
|
||||
%dir %attr(755,%{zmuid_final},%{zmgid_final}) %{_localstatedir}/run/zoneminder
|
||||
|
||||
%files nginx
|
||||
%config(noreplace) %attr(640,root,nginx) %{_sysconfdir}/zm/zm.conf
|
||||
%config(noreplace) %attr(640,root,nginx) %{_sysconfdir}/zm/conf.d/*.conf
|
||||
%ghost %attr(640,root,nginx) %{_sysconfdir}/zm/conf.d/zmcustom.conf
|
||||
%config(noreplace) %{_sysconfdir}/zm/www/zoneminder.nginx.conf
|
||||
%config(noreplace) %{_sysconfdir}/zm/www/redirect.nginx.conf
|
||||
%ghost %{_sysconfdir}/zm/www/zoneminder.conf
|
||||
%config(noreplace) %{_sysconfdir}/zm/www/com.zoneminder.systemctl.rules.nginx
|
||||
%ghost %{_datadir}/polkit-1/rules.d/com.zoneminder.systemctl.rules
|
||||
|
||||
%config(noreplace) %{_sysconfdir}/php-fpm.d/zoneminder.php-fpm.conf
|
||||
|
||||
|
||||
%{_unitdir}/zoneminder.service.d/zm-nginx.conf
|
||||
%{_tmpfilesdir}/zoneminder.nginx.tmpfiles.conf
|
||||
%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder
|
||||
%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/events
|
||||
%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/images
|
||||
%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/sock
|
||||
%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/swap
|
||||
%dir %attr(755,nginx,nginx) %{_sharedstatedir}/zoneminder/temp
|
||||
%dir %attr(755,nginx,nginx) %{_localstatedir}/cache/zoneminder
|
||||
%dir %attr(755,nginx,nginx) %{_localstatedir}/log/zoneminder
|
||||
%dir %attr(755,nginx,nginx) %{_localstatedir}/spool/zoneminder-upload
|
||||
|
||||
%changelog
|
||||
* Tue Dec 11 2018 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.33.0-1
|
||||
- Bump tp 1.33.0 Development
|
||||
|
||||
* Sat Dec 08 2018 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.32.3-1
|
||||
- 1.32.3 Release
|
||||
- Break into sub-packages
|
||||
|
||||
* Tue Nov 13 2018 Antonio Trande <sagitter@fedoraproject.org> - 1.32.2-2
|
||||
- Rebuild for ffmpeg-3.4.5 on el7
|
||||
- Use CMake3
|
||||
|
||||
* Sat Oct 13 2018 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.32.2-1
|
||||
- 1.32.2 release
|
||||
- Bug fix release
|
||||
|
||||
* Thu Oct 04 2018 Sérgio Basto <sergio@serjux.com> - 1.32.1-2
|
||||
- Mass rebuild for x264 and/or x265
|
||||
|
||||
* Tue Oct 2 2018 Andrew Bauer <zonexpertconsulting@outlook.com> - 1.32.1-1
|
||||
- 1.32.1 release
|
||||
- Bug fix release
|
||||
|
|
|
@ -3,7 +3,7 @@ Section: net
|
|||
Priority: optional
|
||||
Maintainer: Dmitry Smirnov <onlyjob@debian.org>
|
||||
Uploaders: Vagrant Cascadian <vagrant@debian.org>
|
||||
Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree
|
||||
Build-Depends: debhelper (>= 9), dh-systemd, python-sphinx | python3-sphinx, apache2-dev, dh-linktree, dh-systemd, dh-apache2
|
||||
,cmake
|
||||
,libx264-dev, libmp4v2-dev
|
||||
,libavdevice-dev (>= 6:10~)
|
||||
|
@ -41,7 +41,7 @@ Package: zoneminder
|
|||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}
|
||||
,javascript-common
|
||||
,libmp4v2-2, libx264-142|libx264-148|libx264-152, libswscale-ffmpeg3|libswscale4|libswscale3
|
||||
,libmp4v2-2, libx264-142|libx264-148|libx264-152, libswscale-ffmpeg3|libswscale4|libswscale3|libswscale5
|
||||
,ffmpeg | libav-tools
|
||||
,libdate-manip-perl, libmime-lite-perl, libmime-tools-perl
|
||||
,libdbd-mysql-perl
|
||||
|
|
196
docs/api.rst
196
docs/api.rst
|
@ -5,7 +5,6 @@ This document will provide an overview of ZoneMinder's API. This is work in prog
|
|||
|
||||
Overview
|
||||
^^^^^^^^
|
||||
|
||||
In an effort to further 'open up' ZoneMinder, an API was needed. This will
|
||||
allow quick integration with and development of ZoneMinder.
|
||||
|
||||
|
@ -13,6 +12,78 @@ The API is built in CakePHP and lives under the ``/api`` directory. It
|
|||
provides a RESTful service and supports CRUD (create, retrieve, update, delete)
|
||||
functions for Monitors, Events, Frames, Zones and Config.
|
||||
|
||||
Streaming Interface
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
Developers working on their application often ask if there is an "API" to receive live streams, or recorded event streams.
|
||||
It is possible to stream both live and recorded streams. This isn't strictly an "API" per-se (that is, it is not integrated
|
||||
into the Cake PHP based API layer discussed here) and also why we've used the term "Interface" instead of an "API".
|
||||
|
||||
Live Streams
|
||||
~~~~~~~~~~~~~~
|
||||
What you need to know is that if you want to display "live streams", ZoneMinder sends you streaming JPEG images (MJPEG)
|
||||
which can easily be rendered in a browser using an ``img src`` tag.
|
||||
|
||||
For example:
|
||||
|
||||
::
|
||||
|
||||
<img src="https://yourserver/zm/cgi-bin/nph-zms?scale=50&width=640p&height=480px&mode=jpeg&maxfps=5&buffer=1000&&monitor=1&auth=b54a589e09f330498f4ae2203&connkey=36139" />
|
||||
|
||||
will display a live feed from monitor id 1, scaled down by 50% in quality and resized to 640x480px.
|
||||
|
||||
* This assumes ``/zm/cgi-bin`` is your CGI_BIN path. Change it to what is correct in your system
|
||||
* The "auth" token you see above is required if you use ZoneMinder authentication. To understand how to get the auth token, please read the "Login, Logout & API security" section below.
|
||||
* The "connkey" parameter is essentially a random number which uniquely identifies a stream. If you don't specify a connkey, ZM will generate its own. It is recommended to generate a connkey because you can then use it to "control" the stream (pause/resume etc.)
|
||||
* Instead of dealing with the "auth" token, you can also use ``&user=username&pass=password`` where "username" and "password" are your ZoneMinder username and password respectively. Note that this is not recommended because you are transmitting them in a URL and even if you use HTTPS, they may show up in web server logs.
|
||||
|
||||
|
||||
PTZ on live streams
|
||||
-------------------
|
||||
PTZ commands are pretty cryptic in ZoneMinder. This is not meant to be an exhaustive guide, but just something to whet your appetite:
|
||||
|
||||
|
||||
Lets assume you have a monitor, with ID=6. Let's further assume you want to pan it left.
|
||||
|
||||
You'd need to send a:
|
||||
``POST`` command to ``https://yourserver/zm/index.php`` with the following data payload in the command (NOT in the URL)
|
||||
|
||||
``view=request&request=control&id=6&control=moveConLeft&xge=30&yge=30``
|
||||
|
||||
Obviously, if you are using authentication, you need to be logged in for this to work.
|
||||
|
||||
Like I said, at this stage, this is only meant to get you started. Explore the ZoneMinder code and use "Inspect source" as you use PTZ commands in the ZoneMinder source code.
|
||||
`control_functions.php <https://github.com/ZoneMinder/zoneminder/blob/10531df54312f52f0f32adec3d4720c063897b62/web/skins/classic/includes/control_functions.php>`__ is a great place to start.
|
||||
|
||||
|
||||
Pre-recorded (past event) streams
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Similar to live playback, if you have chosen to store events in JPEG mode, you can play it back using:
|
||||
|
||||
::
|
||||
|
||||
<img src="https://yourserver/zm/cgi-bin/nph-zms?mode=jpeg&frame=1&replay=none&source=event&event=293820&connkey=77493&auth=b54a58f5f4ae2203" />
|
||||
|
||||
|
||||
* This assumes ``/zm/cgi-bin`` is your CGI_BIN path. Change it to what is correct in your system
|
||||
* This will playback event 293820, starting from frame 1 as an MJPEG stream
|
||||
* Like before, you can add more parameters like ``scale`` etc.
|
||||
* auth and connkey have the same meaning as before, and yes, you can replace auth by ``&user=usename&pass=password`` as before and the same security concerns cited above apply.
|
||||
|
||||
If instead, you have chosen to use the MP4 (Video) storage mode for events, you can directly play back the saved video file:
|
||||
|
||||
::
|
||||
|
||||
<video src="https://yourserver/zm/index.php?view=view_video&eid=294690&auth=33f3d558af84cf08" type="video/mp4"></video>
|
||||
|
||||
* This will play back the video recording for event 294690
|
||||
|
||||
What other parameters are supported?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
The best way to answer this question is to play with ZoneMinder console. Open a browser, play back live or recorded feed, and do an "Inspect Source" to see what parameters
|
||||
are generated. Change and observe.
|
||||
|
||||
|
||||
Enabling API
|
||||
^^^^^^^^^^^^
|
||||
A default ZoneMinder installs with APIs enabled. You can explictly enable/disable the APIs
|
||||
|
@ -132,6 +203,22 @@ Return a list of all monitors
|
|||
|
||||
curl http://server/zm/api/monitors.json
|
||||
|
||||
It is worthwhile to note that starting ZM 1.32.3 and beyond, this API also returns a ``Monitor_Status`` object per monitor. It looks like this:
|
||||
|
||||
::
|
||||
|
||||
"Monitor_Status": {
|
||||
"MonitorId": "2",
|
||||
"Status": "Connected",
|
||||
"CaptureFPS": "1.67",
|
||||
"AnalysisFPS": "1.67",
|
||||
"CaptureBandwidth": "52095"
|
||||
}
|
||||
|
||||
|
||||
If you don't see this in your API, you are running an older version of ZM. This gives you a very convenient way to check monitor status without calling the ``daemonCheck`` API described later.
|
||||
|
||||
|
||||
Retrieve monitor 1
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -149,6 +236,13 @@ This API changes monitor 1 to Modect and Enabled
|
|||
|
||||
curl -XPOST http://server/zm/api/monitors/1.json -d "Monitor[Function]=Modect&Monitor[Enabled]=1"
|
||||
|
||||
Get Daemon Status of Monitor 1
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
::
|
||||
|
||||
curl http://server/zm/api/monitors/daemonStatus/id:1/daemon:zmc.json
|
||||
|
||||
Add a monitor
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -384,11 +478,13 @@ Create a Zone
|
|||
&Zone[MaxBlobs]=\
|
||||
&Zone[OverloadFrames]=0"
|
||||
|
||||
PTZ Control APIs
|
||||
^^^^^^^^^^^^^^^^
|
||||
PTZ Control Meta-Data APIs
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
PTZ controls associated with a monitor are stored in the Controls table and not the Monitors table inside ZM. What that means is when you get the details of a Monitor, you will only know if it is controllable (isControllable:true) and the control ID.
|
||||
To be able to retrieve PTZ information related to that Control ID, you need to use the controls API
|
||||
|
||||
Note that these APIs only retrieve control data related to PTZ. They don't actually move the camera. See the "PTZ on live streams" section to move the camera.
|
||||
|
||||
This returns all the control definitions:
|
||||
::
|
||||
|
||||
|
@ -406,7 +502,97 @@ ZM APIs have various APIs that help you in determining host (aka ZM) daemon stat
|
|||
|
||||
::
|
||||
|
||||
curl -XGET http://server/zm/api/host/daemonCheck.json # 1 = ZM running 0=not running
|
||||
curl -XGET http://server/zm/api/host/getLoad.json # returns current load of ZM
|
||||
curl -XGET http://server/zm/api/host/getDiskPercent.json # returns in GB (not percentage), disk usage per monitor (that is, space taken to store various event related information,images etc. per monitor)
|
||||
|
||||
# Note that ZM 1.32.3 onwards has the same information in Monitors.json which is more reliable and works for multi-server too.
|
||||
curl -XGET http://server/zm/api/host/daemonCheck.json # 1 = ZM running 0=not running
|
||||
|
||||
# The API below uses "du" to calculate disk space. We no longer recommend you use it if you have many events. Use the Storage APIs instead, described later
|
||||
curl -XGET http://server/zm/api/host/getDiskPercent.json # returns in GB (not percentage), disk usage per monitor (that is,space taken to store various event related information,images etc. per monitor)
|
||||
|
||||
|
||||
Storage and Server APIs
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ZoneMinder introduced many new options that allowed you to configure multiserver/multistorage configurations. While a part of this was available in previous versions, a lot of rework was done as part of ZM 1.31 and 1.32. As part of that work, a lot of new and useful APIs were added. Some of these are part of ZM 1.32 and others will be part of ZM 1.32.3 (of course, if you build from master, you can access them right away, or wait till a stable release is out.
|
||||
|
||||
|
||||
|
||||
This returns storage data for my single server install. If you are using multi-storage, you'll see many such "Storage" entries, one for each storage defined:
|
||||
|
||||
::
|
||||
|
||||
curl http://server/zm/api/storage.json
|
||||
|
||||
Returns:
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
"storage": [
|
||||
{
|
||||
"Storage": {
|
||||
"Id": "0",
|
||||
"Path": "\/var\/cache\/zoneminder\/events",
|
||||
"Name": "Default",
|
||||
"Type": "local",
|
||||
"Url": null,
|
||||
"DiskSpace": "364705447651",
|
||||
"Scheme": "Medium",
|
||||
"ServerId": null,
|
||||
"DoDelete": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
"DiskSpace" is the disk used in bytes. While this doesn't return disk space data as rich as ``/host/getDiskPercent``, it is much more efficient.
|
||||
|
||||
Similarly,
|
||||
|
||||
::
|
||||
|
||||
curl http://server/zm/api/servers.json
|
||||
|
||||
Returns:
|
||||
|
||||
::
|
||||
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"Server": {
|
||||
"Id": "1",
|
||||
"Name": "server1",
|
||||
"Hostname": "server1.mydomain.com",
|
||||
"State_Id": null,
|
||||
"Status": "Running",
|
||||
"CpuLoad": "0.9",
|
||||
"TotalMem": "6186237952",
|
||||
"FreeMem": "156102656",
|
||||
"TotalSwap": "536866816",
|
||||
"FreeSwap": "525697024",
|
||||
"zmstats": false,
|
||||
"zmaudit": false,
|
||||
"zmtrigger": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
This only works if you have a multiserver setup in place. If you don't it will return an empty array.
|
||||
|
||||
|
||||
Further Reading
|
||||
^^^^^^^^^^^^^^^^
|
||||
As described earlier, treat this document as an "introduction" to the important parts of the API and streaming interfaces.
|
||||
There are several details that haven't yet been documented. Till they are, here are some resources:
|
||||
|
||||
* zmNinja, the open source mobile app for ZoneMinder is 100% based on ZM APIs. Explore its `source code <https://github.com/pliablepixels/zmNinja>`__ to see how things work.
|
||||
* Launch up ZM console in a browser, and do an "Inspect source". See how images are being rendered. Go to the networks tab of the inspect source console and look at network requests that are made when you pause/play/forward streams.
|
||||
* If you still can't find an answer, post your question in the `forums <https://forums.zoneminder.com/index.php>`__ (not the github repo).
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -311,7 +311,7 @@ There are a number of specific reasons why processor loads can be high either by
|
|||
|
||||
The main causes are.
|
||||
|
||||
* Using a video palette other than greyscale or RGB24. This can cause a relatively minor performace hit, though still significant. Although some cameras and cards require using planar palettes ZM currently doesn't support this format internally and each frame is converted to an RGB representation prior to processing. Unless you have compelling reasons for using YUV or reduced RGB type palettes such as hitting USB transfer limits I would experiment to see if RGB24 or greyscale is quicker. Put your monitors into 'Monitor' mode so that only the capture daemons are running and monitor the process load of these (the 'zmc' processes) using top. Try it with various palettes to see if it makes a difference.
|
||||
* Using a video palette other than greyscale or RGB24. This can cause a relatively minor performance hit, though still significant. Although some cameras and cards require using planar palettes ZM currently doesn't support this format internally and each frame is converted to an RGB representation prior to processing. Unless you have compelling reasons for using YUV or reduced RGB type palettes such as hitting USB transfer limits I would experiment to see if RGB24 or greyscale is quicker. Put your monitors into 'Monitor' mode so that only the capture daemons are running and monitor the process load of these (the 'zmc' processes) using top. Try it with various palettes to see if it makes a difference.
|
||||
* Big image sizes. A image of 640x480 requires at least four times the processing of a 320x240 image. Experiment with different sizes to see what effect it may have. Sometimes a large image is just two interlaced smaller frames so has no real benefit anyway. This is especially true for analog cameras/cards as image height over 320 (NTSC) or 352 PAL) are invariably interlaced.
|
||||
* Capture frame rates. Unless there's a compelling reason in your case there is often little benefit in running cameras at 25fps when 5-10fps would often get you results just as good. Try changing your monitor settings to limit your cameras to lower frame rates. You can still configure ZM to ignore these limits and capture as fast as possible when motion is detected.
|
||||
* Run function. Obviously running in Record or Mocord modes or in Modect with lots of events generates a lot of DB and file activity and so CPU and load will increase.
|
||||
|
|
|
@ -49,7 +49,7 @@ guide you with a quick search.
|
|||
|
||||
add-apt-repository ppa:iconnor/zoneminder-1.32
|
||||
|
||||
If you are on trusty, you may want to add both, as there are some packages for dependencies included in the old ppa.
|
||||
If you are on Trusty or Xenial, you may want to add both, as there are some packages for dependencies included in the old ppa.
|
||||
|
||||
|
||||
Update repo and upgrade.
|
||||
|
@ -138,9 +138,9 @@ Set /etc/zm/zm.conf to root:www-data 740 and www-data access to content
|
|||
|
||||
::
|
||||
|
||||
a2enconf zoneminder
|
||||
a2enmod cgi
|
||||
a2enmod rewrite
|
||||
a2enconf zoneminder
|
||||
|
||||
You may also want to enable to following modules to improve caching performance
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ Maximum FPS
|
|||
Alarm Maximum FPS
|
||||
If you have specified a Maximum FPS it may be that you don’t want this limitation to apply when your monitor is recording motion or other event. This setting allows you to override the Maximum FPS value if this circumstance occurs. As with the Maximum FPS setting leaving this blank implies no limit so if you have set a maximum fps in the previous option then when an alarm occurs this limit would be ignored and ZoneMinder would capture as fast as possible for the duration of the alarm, returning to the limited value after the alarm has concluded. Equally you could set this to the same, or higher (or even lower) value than Maximum FPS for more precise control over the capture rate in the event of an alarm.
|
||||
|
||||
**IMPORTANT:** This field is subject to the same limitations as the Maxium FPS field. Ignoring these limitations will produce undesriable results.
|
||||
**IMPORTANT:** This field is subject to the same limitations as the Maximum FPS field. Ignoring these limitations will produce undesriable results.
|
||||
|
||||
Reference Image Blend %ge
|
||||
Each analysed image in ZoneMinder is a composite of previous images and is formed by applying the current image as a certain percentage of the previous reference image. Thus, if we entered the value of 10 here, each image’s part in the reference image will diminish by a factor of 0.9 each time round. So a typical reference image will be 10% the previous image, 9% the one before that and then 8.1%, 7.2%, 6.5% and so on of the rest of the way. An image will effectively vanish around 25 images later than when it was added. This blend value is what is specified here and if higher will make slower progressing events less detectable as the reference image would change more quickly. Similarly events will be deemed to be over much sooner as the reference image adapts to the new images more quickly. In signal processing terms the higher this value the steeper the event attack and decay of the signal. It depends on your particular requirements what the appropriate value would be for you but start with 10 here and adjust it (usually down) later if necessary.
|
||||
|
@ -164,6 +164,29 @@ Height (pixels)
|
|||
Web Site Refresh
|
||||
If the website in question has static content, optionally enter a time period in seconds for ZoneMinder to refresh the content.
|
||||
|
||||
Storage Tab
|
||||
-----------
|
||||
|
||||
The storage section allows for each monitor to configure if and how video and audio are recorded.
|
||||
|
||||
Save JPEGs
|
||||
Records video in individual JPEG frames. Storing JPEG frames requires more storage space than h264 but it allows to view an event anytime while it is being recorded.
|
||||
|
||||
* Disabled – video is not recorded as JPEG frames. If this setting is selected, then "Video Writer" should be enabled otherwise there is no video recording at all.
|
||||
* Frames only – video is recorded in individual JPEG frames.
|
||||
* Analysis images only (if available) – video is recorded in invidual JPEG frames with an overlay of the motion detection analysis information. Note that this overlay remains permanently visible in the frames.
|
||||
* Frames + Analysis images (if available) – video is recorded twice, once as normal individual JPEG frames and once in invidual JPEG frames with analysis information overlaid.
|
||||
|
||||
Video Writer
|
||||
Records video in real video format. It provides much better compression results than saving JPEGs, thus longer video history can be stored.
|
||||
|
||||
* Disabled – video is not recorded in video format. If this setting is selected, then "Save JPEGs" should be enabled otherwise there is no video recording at all.
|
||||
* X264 Encode – the video or picture frames received from the camera are transcoded into h264 and stored as a video. This option is useful if the camera cannot natively stream h264.
|
||||
* H264 Camera Passthrough – this option assumes that the camera is already sending an h264 stream. Video will be recorded as is, without any post-processing in zoneminder. Video characteristics such as bitrate, encoding mode, etc. should be set directly in the camera.
|
||||
|
||||
Recording Audio
|
||||
Check the box labeled "Whether to store the audio stream when saving an event." in order to save audio (if available) when events are recorded.
|
||||
|
||||
Timestamp Tab
|
||||
-------------
|
||||
|
||||
|
@ -182,7 +205,8 @@ Warm-up Frames
|
|||
Pre/Post Event Image Buffer
|
||||
These options determine how many frames from before and after an event should be preserved with it. This allows you to view what happened immediately prior and subsequent to the event. A value of 10 for both of these will get you started but if you get a lot of short events and would prefer them to run together to form fewer longer ones then increase the Post Event buffer size. The pre-event buffer is a true buffer and should not really exceed half the ring buffer size. However the post-event buffer is just a count that is applied to captured frames and so can be managed more flexibly. You should also bear in mind the frame rate of the camera when choosing these values. For instance a network camera capturing at 1FPS will give you 10 seconds before and after each event if you chose 10 here. This may well be too much and pad out events more than necessary. However a fast video card may capture at 25FPS and you will want to ensure that this setting enables you to view a reasonable time frame pre and post event.
|
||||
Stream Replay Image Buffer
|
||||
This option ...
|
||||
The number of frames buffered to allow pausing and rewinding of the stream when live viewing a monitor. A value of 0 disables the feature.
|
||||
Frames are buffered to ZM_PATH_SWAP. If this path points to a physical drive, a lot of IO will be caused during live view / montage. If you experience high system load in those situations, either disable the feature or use a RAM drive for ZM_PATH_SWAP.
|
||||
Alarm Frame Count
|
||||
This option allows you to specify how many consecutive alarm frames must occur before an alarm event is generated. The usual, and default, value is 1 which implies that any alarm frame will cause or participate in an event. You can enter any value up to 16 here to eliminate bogus events caused perhaps by screen flickers or other transients. Values over 3 or 4 are unlikely to be useful however. Please note that if you have statistics recording enabled then currently statistics are not recorded for the first ‘Alarm Frame Count’-1 frames of an event. So if you set this value to 5 then the first 4 frames will be missing statistics whereas the more usual value of 1 will ensure that all alarm frames have statistics recorded.
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
Welcome to ZoneMinder, the all-in-one Linux GPL'd security camera solution.
|
||||
Welcome to ZoneMinder, the all-in-one security camera solution for Linux with GPL License.
|
||||
|
||||
Most commercial "security systems" are designed as a monitoring system that also records. Recording quality can vary from bad to unusable, locating the relevant video can range from challenging to impractical, and exporting can often only be done with the manual present. ZoneMinder was designed primarily to record, and allow easy searches and exporting. Recordings are of the best possible quality, easy to filter and find, and simple to export using any system with a web browser. It also monitors.
|
||||
Commercial "security systems" are often designed as a monitoring system with little attention to recording quality. In such a system, locating and exporting relevant video can be challenging and often requires extensive human intervention. ZoneMinder was designed to provide the best possible record quality while allowing easy searching, filtering and exporting of security footage.
|
||||
|
||||
ZoneMinder is designed around a series of independent components that only function when necessary limiting any wasted resource and maximising the efficiency of your machine. A fairly ancient Pentium II PC should be able to track one camera per device at up to 25 frames per second with this dropping by half approximately for each additional camera on the same device. Additional cameras on other devices do not interact so can maintain this frame rate. Even monitoring several cameras still will not overload the CPU as frame processing is designed to synchronise with capture and not stall it.
|
||||
ZoneMinder is designed around a series of independent components that only function when necessary, limiting any wasted resource and maximising the efficiency of your machine. An outdated Pentium II PC can have multiple recording devices connected to it, and it is able to track one camera per device at up to 25 frames per second, which drops by approximately half for each additional camera on the same device. Additional cameras on devices that do not interact with other devices can maintain the 25 frame rate per second. Monitoring several cameras will not overload the CPU as frame processing is designed to synchronise with capture.
|
||||
|
||||
As well as being fast ZoneMinder is designed to be friendly and even more than that, actually useful. As well as the fast video interface core it also comes with a user friendly and comprehensive PHP based web interface allowing you to control and monitor your cameras from home, at work, on the road, or even a web enabled cell phone. It supports variable web capabilities based on available bandwidth. The web interface also allows you to view events that your cameras have captured and archive them or review them time and again, or delete the ones you no longer wish to keep. The web pages directly interact with the core daemons ensuring full co-operation at all times. ZoneMinder can even be installed as a system service ensuring it is right there if your computer has to reboot for any reason.
|
||||
A fast video interface core, a user-friendly and comprehensive PHP based web interface allows ZoneMinder to be efficient, friendly and most importantly useful. You can control and monitor your cameras from home, at work, on the road, or a web-enabled cell phone. It supports variable web capabilities based on available bandwidth. The web interface also allows you to view events that your cameras have captured, which can be archived, reviewed or deleted. The web application directly interacts with the core daemons ensuring full co-operation at all times. ZoneMinder can also be installed as a system service to reboot a system remotely.
|
||||
|
||||
The core of ZoneMinder is the capture and analysis of images and there is a highly configurable set of parameters that allow you to ensure that you can eliminate false positives whilst ensuring that anything you don't want to miss will be captured and saved. ZoneMinder allows you to define a set of 'zones' for each camera of varying sensitivity and functionality. This allows you to eliminate regions that you don't wish to track or define areas that will alarm if various thresholds are exceeded in conjunction with other zones.
|
||||
|
||||
ZoneMinder is free, but if you do find it useful then please feel free to visit http://www.zoneminder.com/donate.html and help to fund future improvements to ZoneMinder.
|
||||
The core of ZoneMinder is the capture and analysis of images and a highly configurable set of parameters that eliminate false positives whilst ensuring minimum loss of footage. For example, you can define a set of 'zones' for each camera of varying sensitivity and functionality. This eliminates zones that you don't wish to track or define areas that will alarm if various thresholds are exceeded in conjunction with other zones.
|
||||
|
||||
ZoneMinder is free under GPL License, but if you do find it useful, then please feel free to visit http://www.zoneminder.com/donate.html and help us fund our future improvements.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
# Create files from the .in files
|
||||
configure_file(apache.conf.in "${CMAKE_CURRENT_BINARY_DIR}/apache.conf" @ONLY)
|
||||
configure_file(nginx.conf.in "${CMAKE_CURRENT_BINARY_DIR}/nginx.conf" @ONLY)
|
||||
configure_file(logrotate.conf.in "${CMAKE_CURRENT_BINARY_DIR}/logrotate.conf" @ONLY)
|
||||
configure_file(syslog.conf.in "${CMAKE_CURRENT_BINARY_DIR}/syslog.conf" @ONLY)
|
||||
configure_file(com.zoneminder.systemctl.policy.in "${CMAKE_CURRENT_BINARY_DIR}/com.zoneminder.systemctl.policy" @ONLY)
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
#
|
||||
# PLEASE NOTE THAT THIS FILE IS INTENDED FOR GUIDANCE ONLY AND MAY NOT BE APPROPRIATE FOR YOUR DISTRIBUTION
|
||||
#
|
||||
|
||||
server {
|
||||
listen 443 ssl default_server;
|
||||
listen [::]:443 ssl default_server;
|
||||
server_name = localhost $hostname;
|
||||
|
||||
ssl_certificate "/etc/pki/tls/certs/localhost.crt";
|
||||
ssl_certificate_key "/etc/pki/tls/private/localhost.key";
|
||||
ssl_session_cache shared:SSL:1m;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_ciphers PROFILE=SYSTEM;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Auto redirect to server/zm when no url suffix was given
|
||||
location = / {
|
||||
return 301 zm;
|
||||
}
|
||||
|
||||
location /cgi-bin-zm {
|
||||
gzip off;
|
||||
alias "@ZM_CGIDIR@";
|
||||
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_pass unix:/run/fcgiwrap.sock;
|
||||
}
|
||||
|
||||
location /zm/cache {
|
||||
alias "@ZM_CACHEDIR@";
|
||||
}
|
||||
|
||||
location /zm {
|
||||
gzip off;
|
||||
alias "@ZM_WEBDIR@";
|
||||
index index.php;
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
expires epoch;
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_pass unix:/run/php-fpm/www.sock;
|
||||
}
|
||||
|
||||
location ~ \.(jpg|jpeg|gif|png|ico)$ {
|
||||
access_log off;
|
||||
expires 33d;
|
||||
}
|
||||
|
||||
location /zm/api/ {
|
||||
alias "@ZM_WEBDIR@";
|
||||
rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -25,9 +25,7 @@ sub GetServices {
|
|||
soap_action => 'http://www.onvif.org/ver10/device/wsdl/GetServices',
|
||||
style => 'document',
|
||||
body => {
|
||||
|
||||
|
||||
'use' => 'literal',
|
||||
use => 'literal',
|
||||
namespace => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
||||
encodingStyle => '',
|
||||
parts => [qw( ONVIF::Device::Elements::GetServices )],
|
||||
|
@ -50,9 +48,7 @@ sub GetServiceCapabilities {
|
|||
soap_action => 'http://www.onvif.org/ver10/device/wsdl/GetServiceCapabilities',
|
||||
style => 'document',
|
||||
body => {
|
||||
|
||||
|
||||
'use' => 'literal',
|
||||
use => 'literal',
|
||||
namespace => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
||||
encodingStyle => '',
|
||||
parts => [qw( ONVIF::Device::Elements::GetServiceCapabilities )],
|
||||
|
@ -3059,7 +3055,7 @@ Returns a L<ONVIF::Device::Elements::SetClientCertificateModeResponse|ONVIF::Dev
|
|||
|
||||
=head3 GetRelayOutputs
|
||||
|
||||
This method has been depricated with version 2.0. Refer to the DeviceIO service.
|
||||
This method has been deprecated with version 2.0. Refer to the DeviceIO service.
|
||||
|
||||
Returns a L<ONVIF::Device::Elements::GetRelayOutputsResponse|ONVIF::Device::Elements::GetRelayOutputsResponse> object.
|
||||
|
||||
|
@ -3069,7 +3065,7 @@ Returns a L<ONVIF::Device::Elements::GetRelayOutputsResponse|ONVIF::Device::Elem
|
|||
|
||||
=head3 SetRelayOutputSettings
|
||||
|
||||
This method has been depricated with version 2.0. Refer to the DeviceIO service.
|
||||
This method has been deprecated with version 2.0. Refer to the DeviceIO service.
|
||||
|
||||
Returns a L<ONVIF::Device::Elements::SetRelayOutputSettingsResponse|ONVIF::Device::Elements::SetRelayOutputSettingsResponse> object.
|
||||
|
||||
|
@ -3085,7 +3081,7 @@ Returns a L<ONVIF::Device::Elements::SetRelayOutputSettingsResponse|ONVIF::Devic
|
|||
|
||||
=head3 SetRelayOutputState
|
||||
|
||||
This method has been depricated with version 2.0. Refer to the DeviceIO service.
|
||||
This method has been deprecated with version 2.0. Refer to the DeviceIO service.
|
||||
|
||||
Returns a L<ONVIF::Device::Elements::SetRelayOutputStateResponse|ONVIF::Device::Elements::SetRelayOutputStateResponse> object.
|
||||
|
||||
|
|
|
@ -830,7 +830,7 @@ Returns a L<ONVIF::PTZ::Elements::SetPresetResponse|ONVIF::PTZ::Elements::SetPre
|
|||
|
||||
=head3 RemovePreset
|
||||
|
||||
Operation to remove a PTZ preset for the Node in the selected profile. The operation is supported if the PresetPosition capability exists for teh Node in the selected profile.
|
||||
Operation to remove a PTZ preset for the Node in the selected profile. The operation is supported if the PresetPosition capability exists for the Node in the selected profile.
|
||||
|
||||
Returns a L<ONVIF::PTZ::Elements::RemovePresetResponse|ONVIF::PTZ::Elements::RemovePresetResponse> object.
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ configure_file(zm.in "${CMAKE_CURRENT_BINARY_DIR}/zm" @ONLY)
|
|||
file(GLOB perlscripts "*.pl")
|
||||
FOREACH(PERLSCRIPT ${perlscripts})
|
||||
get_filename_component(PERLSCRIPTNAME ${PERLSCRIPT} NAME)
|
||||
POD2MAN(${PERLSCRIPT} zoneminder-${PERLSCRIPTNAME} 8)
|
||||
POD2MAN(${PERLSCRIPT} zoneminder-${PERLSCRIPTNAME} 8 ${ZM_MANPAGE_DEST_PREFIX})
|
||||
ENDFOREACH(PERLSCRIPT ${perlscripts})
|
||||
|
||||
# Install the perl scripts
|
||||
|
|
|
@ -309,6 +309,8 @@ saving configuration is a convenient way to ensure that the configuration
|
|||
held in the database corresponds with the most recent definitions and that
|
||||
all components are using the same set of configuration.
|
||||
|
||||
=back
|
||||
|
||||
=head2 EXPORT
|
||||
|
||||
None by default.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
|
|
|
@ -0,0 +1,365 @@
|
|||
package ZoneMinder::Control::PSIA;
|
||||
|
||||
use 5.006;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
require ZoneMinder::Base;
|
||||
require ZoneMinder::Control;
|
||||
|
||||
our @ISA = qw(ZoneMinder::Control);
|
||||
|
||||
our $REALM = 'TV-IP450PI';
|
||||
our $USERNAME = 'admin';
|
||||
our $PASSWORD = '';
|
||||
our $ADDRESS = '';
|
||||
our $PROTOCOL = 'http://';
|
||||
|
||||
use ZoneMinder::Logger qw(:all);
|
||||
use ZoneMinder::Config qw(:all);
|
||||
use ZoneMinder::Database qw(zmDbConnect);
|
||||
|
||||
sub open
|
||||
{
|
||||
my $self = shift;
|
||||
$self->loadMonitor();
|
||||
|
||||
if ( ( $self->{Monitor}->{ControlAddress} =~ /^(?<PROTOCOL>https?:\/\/)?(?<USERNAME>[^:@]+)?:?(?<PASSWORD>[^\/@]+)?@?(?<ADDRESS>.*)$/ ) ) {
|
||||
$PROTOCOL = $+{PROTOCOL} if $+{PROTOCOL};
|
||||
$USERNAME = $+{USERNAME} if $+{USERNAME};
|
||||
$PASSWORD = $+{PASSWORD} if $+{PASSWORD};
|
||||
$ADDRESS = $+{ADDRESS} if $+{ADDRESS};
|
||||
} else {
|
||||
Error('Failed to parse auth from address ' . $self->{Monitor}->{ControlAddress});
|
||||
$ADDRESS = $self->{Monitor}->{ControlAddress};
|
||||
}
|
||||
if ( !($ADDRESS =~ /:/) ) {
|
||||
Error('You generally need to also specify the port. I will append :80');
|
||||
$ADDRESS .= ':80';
|
||||
}
|
||||
|
||||
use LWP::UserAgent;
|
||||
$self->{ua} = LWP::UserAgent->new;
|
||||
$self->{ua}->agent( "ZoneMinder Control Agent/".$ZoneMinder::Base::ZM_VERSION );
|
||||
$self->{state} = 'closed';
|
||||
Debug( "sendCmd credentials control address:'".$ADDRESS
|
||||
."' realm:'" . $REALM
|
||||
. "' username:'" . $USERNAME
|
||||
. "' password:'".$PASSWORD
|
||||
."'"
|
||||
);
|
||||
$self->{ua}->credentials($ADDRESS, $REALM, $USERNAME, $PASSWORD);
|
||||
|
||||
# Detect REALM
|
||||
my $req = HTTP::Request->new(GET=>$PROTOCOL . $ADDRESS . "/PSIA/PTZ/channels");
|
||||
my $res = $self->{ua}->request($req);
|
||||
|
||||
if ($res->is_success) {
|
||||
$self->{state} = 'open';
|
||||
return;
|
||||
} elsif (! $res->is_success) {
|
||||
Debug("Need newer REALM");
|
||||
if ( $res->status_line() eq '401 Unauthorized' ) {
|
||||
my $headers = $res->headers();
|
||||
foreach my $k ( keys %$headers ) {
|
||||
Debug("Initial Header $k => $$headers{$k}");
|
||||
} # end foreach
|
||||
if ( $$headers{'www-authenticate'} ) {
|
||||
my ($auth, $tokens) = $$headers{'www-authenticate'} =~ /^(\w+)\s+(.*)$/;
|
||||
if ($tokens =~ /\w+="([^"]+)"/i) {
|
||||
$REALM = $1;
|
||||
Debug("Changing REALM to $REALM");
|
||||
$self->{ua}->credentials($ADDRESS, $REALM, $USERNAME, $PASSWORD);
|
||||
} # end if
|
||||
} else {
|
||||
Debug("No WWW-Authenticate header");
|
||||
} # end if www-authenticate header
|
||||
} # end if $res->status_line() eq '401 Unauthorized'
|
||||
} # end elsif ! $res->is_success
|
||||
}
|
||||
|
||||
sub close
|
||||
{
|
||||
my $self = shift;
|
||||
$self->{state} = 'closed';
|
||||
}
|
||||
|
||||
sub printMsg
|
||||
{
|
||||
my $self = shift;
|
||||
my $msg = shift;
|
||||
my $msg_len = length($msg);
|
||||
|
||||
Debug( $msg."[".$msg_len."]" );
|
||||
}
|
||||
|
||||
sub sendGetRequest {
|
||||
my $self = shift;
|
||||
my $url_path = shift;
|
||||
|
||||
my $result = undef;
|
||||
|
||||
my $url = $PROTOCOL . $ADDRESS . $url_path;
|
||||
my $req = HTTP::Request->new(GET=>$url);
|
||||
|
||||
my $res = $self->{ua}->request($req);
|
||||
|
||||
if ($res->is_success) {
|
||||
$result = !undef;
|
||||
} else {
|
||||
if ( $res->status_line() eq '401 Unauthorized' ) {
|
||||
Error( "Error check failed, trying again: USERNAME: $USERNAME realm: $REALM password: " . $PASSWORD );
|
||||
Error("Content was " . $res->content() );
|
||||
my $res = $self->{ua}->request($req);
|
||||
if ( $res->is_success ) {
|
||||
$result = !undef;
|
||||
} else {
|
||||
Error("Content was " . $res->content() );
|
||||
}
|
||||
}
|
||||
if ( ! $result ) {
|
||||
Error("Error check failed: '".$res->status_line());
|
||||
}
|
||||
}
|
||||
return($result);
|
||||
}
|
||||
sub sendPutRequest {
|
||||
my $self = shift;
|
||||
my $url_path = shift;
|
||||
my $content = shift;
|
||||
|
||||
my $result = undef;
|
||||
|
||||
my $url = $PROTOCOL . $ADDRESS . $url_path;
|
||||
my $req = HTTP::Request->new(PUT=>$url);
|
||||
if(defined($content)) {
|
||||
$req->content_type("application/x-www-form-urlencoded; charset=UTF-8");
|
||||
$req->content('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . $content);
|
||||
}
|
||||
|
||||
my $res = $self->{ua}->request($req);
|
||||
|
||||
if ($res->is_success) {
|
||||
$result = !undef;
|
||||
} else {
|
||||
if ( $res->status_line() eq '401 Unauthorized' ) {
|
||||
Error( "Error check failed, trying again: USERNAME: $USERNAME realm: $REALM password: " . $PASSWORD );
|
||||
Error("Content was " . $res->content() );
|
||||
my $res = $self->{ua}->request($req);
|
||||
if ( $res->is_success ) {
|
||||
$result = !undef;
|
||||
} else {
|
||||
Error("Content was " . $res->content() );
|
||||
}
|
||||
}
|
||||
if ( ! $result ) {
|
||||
Error( "Error check failed: '".$res->status_line()."' cmd:'".$cmd."'" );
|
||||
}
|
||||
}
|
||||
return($result);
|
||||
}
|
||||
sub sendDeleteRequest {
|
||||
my $self = shift;
|
||||
my $url_path = shift;
|
||||
|
||||
my $result = undef;
|
||||
|
||||
my $url = $PROTOCOL . $ADDRESS . $url_path;
|
||||
my $req = HTTP::Request->new(DELETE=>$url);
|
||||
my $res = $self->{ua}->request($req);
|
||||
if ($res->is_success) {
|
||||
$result = !undef;
|
||||
} else {
|
||||
if ( $res->status_line() eq '401 Unauthorized' ) {
|
||||
Error( "Error check failed, trying again: USERNAME: $USERNAME realm: $REALM password: " . $PASSWORD );
|
||||
Error("Content was " . $res->content() );
|
||||
my $res = $self->{ua}->request($req);
|
||||
if ( $res->is_success ) {
|
||||
$result = !undef;
|
||||
} else {
|
||||
Error("Content was " . $res->content() );
|
||||
}
|
||||
}
|
||||
if ( ! $result ) {
|
||||
Error( "Error check failed: '".$res->status_line()."' cmd:'".$cmd."'" );
|
||||
}
|
||||
}
|
||||
return($result);
|
||||
}
|
||||
|
||||
sub move
|
||||
{
|
||||
my $self = shift;
|
||||
my $panPercentage = shift;
|
||||
my $tiltPercentage = shift;
|
||||
my $zoomPercentage = shift;
|
||||
|
||||
my $cmd = "set_relative_pos&posX=$panSteps&posY=$tiltSteps";
|
||||
my $ptzdata = '<PTZData version="1.0" xmlns="urn:psialliance-org">';
|
||||
$ptzdata .= '<pan>' . $panPercentage . '</pan>';
|
||||
$ptzdata .= '<tilt>' . $tiltPercentage . '</tilt>';
|
||||
$ptzdata .= '<zoom>' . $zoomPercentage . '</zoom>';
|
||||
$ptzdata .= '<Momentary><duration>500</duration></Momentary>';
|
||||
$ptzdata .= '</PTZData>';
|
||||
$self->sendPutRequest("/PSIA/PTZ/channels/1/momentary", $ptzdata);
|
||||
}
|
||||
|
||||
sub moveRelUpLeft
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Move Up Left" );
|
||||
$self->move(-50, 50, 0);
|
||||
}
|
||||
|
||||
sub moveRelUp
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Move Up" );
|
||||
$self->move(0, 50, 0);
|
||||
}
|
||||
|
||||
sub moveRelUpRight
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Move Up Right" );
|
||||
$self->move(50, 50, 0);
|
||||
}
|
||||
|
||||
sub moveRelLeft
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Move Left" );
|
||||
$self->move(-50, 0, 0);
|
||||
}
|
||||
|
||||
sub moveRelRight
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Move Right" );
|
||||
$self->move(50, 0, 0);
|
||||
}
|
||||
|
||||
sub moveRelDownLeft
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Move Down Left" );
|
||||
$self->move(-50, -50, 0);
|
||||
}
|
||||
|
||||
sub moveRelDown
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Move Down" );
|
||||
$self->move(0, -50, 0);
|
||||
}
|
||||
|
||||
sub moveRelDownRight
|
||||
{
|
||||
my $self = shift;
|
||||
Debug( "Move Down Right" );
|
||||
$self->move(50, -50, 0);
|
||||
}
|
||||
|
||||
sub zoomRelTele
|
||||
{
|
||||
my $self = shift;
|
||||
Debug("Zoom Relative Tele");
|
||||
$self->move(0, 0, 50);
|
||||
}
|
||||
|
||||
sub zoomRelWide
|
||||
{
|
||||
my $self = shift;
|
||||
Debug("Zoom Relative Wide");
|
||||
$self->move(0, 0, -50);
|
||||
}
|
||||
|
||||
|
||||
sub presetClear
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
my $preset_id = $self->getParam($params, 'preset');
|
||||
my $url_path = "/PSIA/PTZ/channels/1/presets/" . $preset_id;
|
||||
$self->sendDeleteRequest($url_path);
|
||||
}
|
||||
|
||||
|
||||
sub presetSet
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
|
||||
my $preset_id = $self->getParam($params, 'preset');
|
||||
|
||||
my $dbh = zmDbConnect(1);
|
||||
my $sql = 'SELECT * FROM ControlPresets WHERE MonitorId = ? AND Preset = ?';
|
||||
my $sth = $dbh->prepare($sql)
|
||||
or Fatal("Can't prepare sql '$sql': " . $dbh->errstr());
|
||||
my $res = $sth->execute($self->{Monitor}->{Id}, $preset_id)
|
||||
or Fatal("Can't execute sql '$sql': " . $sth->errstr());
|
||||
my $control_preset_row = $sth->fetchrow_hashref();
|
||||
my $new_label_name = $control_preset_row->{'Label'};
|
||||
|
||||
my $url_path = "/PSIA/PTZ/channels/1/presets/" . $preset_id;
|
||||
my $ptz_preset_data = '<PTZPreset>';
|
||||
$ptz_preset_data .= '<id>' . $preset_id . '</id>';
|
||||
$ptz_preset_data .= '<presetName>' . $new_label_name . '</presetName>';
|
||||
$ptz_preset_data .= '</PTZPreset>';
|
||||
$self->sendPutRequest($url_path, $ptz_preset_data);
|
||||
}
|
||||
|
||||
sub presetGoto
|
||||
{
|
||||
my $self = shift;
|
||||
my $params = shift;
|
||||
my $preset_id = $self->getParam($params, 'preset');
|
||||
|
||||
my $url_path = '/PSIA/PTZ/channels/1/presets/' . $preset_id . '/goto';
|
||||
|
||||
$self->sendPutRequest($url_path);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ZoneMinder::Control::PSIA - Perl module for cameras implementing the PSIA
|
||||
(Physical Security Interoperability Alliance), IP Media Devices API
|
||||
specification
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use ZoneMinder::Control::PSIA;
|
||||
place this in /usr/share/perl5/ZoneMinder/Control
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This has so far been tested with:
|
||||
- Trendnet TV-IP450PI
|
||||
|
||||
=head2 EXPORT
|
||||
|
||||
None by default.
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (C) 2018 ZoneMinder LLC
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
=cut
|
|
@ -16,7 +16,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
|
|
|
@ -41,17 +41,18 @@ our @ISA = qw(Exporter ZoneMinder::Base);
|
|||
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
|
||||
# will save memory.
|
||||
our %EXPORT_TAGS = (
|
||||
'functions' => [ qw(
|
||||
functions => [ qw(
|
||||
zmDbConnect
|
||||
zmDbDisconnect
|
||||
zmDbGetMonitors
|
||||
zmDbGetMonitor
|
||||
zmDbGetMonitorAndControl
|
||||
zmDbDo
|
||||
) ]
|
||||
);
|
||||
push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS;
|
||||
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{all} } );
|
||||
|
||||
our @EXPORT = qw();
|
||||
|
||||
|
@ -66,8 +67,6 @@ our $VERSION = $ZoneMinder::Base::VERSION;
|
|||
use ZoneMinder::Logger qw(:all);
|
||||
use ZoneMinder::Config qw(:all);
|
||||
|
||||
use Carp;
|
||||
|
||||
our $dbh = undef;
|
||||
|
||||
sub zmDbConnect {
|
||||
|
@ -93,7 +92,7 @@ sub zmDbConnect {
|
|||
|
||||
my $sslOptions = '';
|
||||
if ( $Config{ZM_DB_SSL_CA_CERT} ) {
|
||||
$sslOptions = ';'.join(';',
|
||||
$sslOptions = join(';','',
|
||||
'mysql_ssl=1',
|
||||
'mysql_ssl_ca_file='.$Config{ZM_DB_SSL_CA_CERT},
|
||||
'mysql_ssl_client_key='.$Config{ZM_DB_SSL_CLIENT_KEY},
|
||||
|
@ -102,8 +101,9 @@ sub zmDbConnect {
|
|||
}
|
||||
|
||||
eval {
|
||||
$dbh = DBI->connect( 'DBI:mysql:database='.$Config{ZM_DB_NAME}
|
||||
.$socket . $sslOptions . ($options?';'.join(';', map { $_.'='.$$options{$_} } keys %{$options} ) : '')
|
||||
$dbh = DBI->connect(
|
||||
'DBI:mysql:database='.$Config{ZM_DB_NAME}
|
||||
.$socket . $sslOptions . ($options?join(';', '', map { $_.'='.$$options{$_} } keys %{$options} ) : '')
|
||||
, $Config{ZM_DB_USER}
|
||||
, $Config{ZM_DB_PASS}
|
||||
);
|
||||
|
@ -125,7 +125,7 @@ sub zmDbConnect {
|
|||
|
||||
sub zmDbDisconnect {
|
||||
if ( defined( $dbh ) ) {
|
||||
$dbh->disconnect();
|
||||
$dbh->disconnect() or Error('Error disconnecting db? ' . $dbh->errstr());
|
||||
$dbh = undef;
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ sub zmDbGetMonitors {
|
|||
zmDbConnect();
|
||||
|
||||
my $function = shift || DB_MON_ALL;
|
||||
my $sql = "select * from Monitors";
|
||||
my $sql = 'SELECT * FROM Monitors';
|
||||
|
||||
if ( $function ) {
|
||||
if ( $function == DB_MON_CAPT ) {
|
||||
|
@ -156,26 +156,38 @@ sub zmDbGetMonitors {
|
|||
$sql .= " where Function = 'Nodect'";
|
||||
}
|
||||
}
|
||||
my $sth = $dbh->prepare_cached( $sql )
|
||||
or croak( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
my $res = $sth->execute()
|
||||
or croak( "Can't execute '$sql': ".$sth->errstr() );
|
||||
my $sth = $dbh->prepare_cached( $sql );
|
||||
if ( ! $sth ) {
|
||||
Error("Can't prepare '$sql': ".$dbh->errstr());
|
||||
return undef;
|
||||
}
|
||||
my $res = $sth->execute();
|
||||
if ( ! $res ) {
|
||||
Error("Can't execute '$sql': ".$sth->errstr());
|
||||
return undef;
|
||||
}
|
||||
|
||||
my @monitors;
|
||||
while( my $monitor = $sth->fetchrow_hashref() ) {
|
||||
push( @monitors, $monitor );
|
||||
}
|
||||
$sth->finish();
|
||||
return( \@monitors );
|
||||
return \@monitors;
|
||||
}
|
||||
|
||||
sub zmSQLExecute {
|
||||
my $sql = shift;
|
||||
|
||||
my $sth = $dbh->prepare_cached( $sql )
|
||||
or croak( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
my $res = $sth->execute( @_ )
|
||||
or croak( "Can't execute '$sql': ".$sth->errstr() );
|
||||
my $sth = $dbh->prepare_cached( $sql );
|
||||
if ( ! $sth ) {
|
||||
Error("Can't prepare '$sql': ".$dbh->errstr());
|
||||
return undef;
|
||||
}
|
||||
my $res = $sth->execute( @_ );
|
||||
if ( ! $res ) {
|
||||
Error("Can't execute '$sql': ".$sth->errstr());
|
||||
return undef;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -185,17 +197,22 @@ sub zmDbGetMonitor {
|
|||
my $id = shift;
|
||||
|
||||
if ( !defined($id) ) {
|
||||
croak("Undefined id in zmDbgetMonitor");
|
||||
Error('Undefined id in zmDbgetMonitor');
|
||||
return undef ;
|
||||
}
|
||||
|
||||
my $sql = 'SELECT * FROM Monitors WHERE Id = ?';
|
||||
my $sth = $dbh->prepare_cached($sql)
|
||||
or croak("Can't prepare '$sql': ".$dbh->errstr());
|
||||
my $res = $sth->execute($id)
|
||||
or croak("Can't execute '$sql': ".$sth->errstr());
|
||||
my $sth = $dbh->prepare_cached($sql);
|
||||
if ( !$sth ) {
|
||||
Error("Can't prepare '$sql': ".$dbh->errstr());
|
||||
return undef;
|
||||
}
|
||||
my $res = $sth->execute($id);
|
||||
if ( !$res ) {
|
||||
Error("Can't execute '$sql': ".$sth->errstr());
|
||||
return undef;
|
||||
}
|
||||
my $monitor = $sth->fetchrow_hashref();
|
||||
|
||||
return $monitor;
|
||||
}
|
||||
|
||||
|
@ -204,25 +221,28 @@ sub zmDbGetMonitorAndControl {
|
|||
|
||||
my $id = shift;
|
||||
|
||||
return( undef ) if ( !defined($id) );
|
||||
return undef if !defined($id);
|
||||
|
||||
my $sql = "SELECT C.*,M.*,C.Protocol
|
||||
my $sql = 'SELECT C.*,M.*,C.Protocol
|
||||
FROM Monitors as M
|
||||
INNER JOIN Controls as C on (M.ControlId = C.Id)
|
||||
WHERE M.Id = ?"
|
||||
WHERE M.Id = ?'
|
||||
;
|
||||
my $sth = $dbh->prepare_cached( $sql )
|
||||
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
my $res = $sth->execute( $id )
|
||||
or Fatal( "Can't execute '$sql': ".$sth->errstr() );
|
||||
my $sth = $dbh->prepare_cached($sql);
|
||||
if ( !$sth ) {
|
||||
Error("Can't prepare '$sql': ".$dbh->errstr());
|
||||
return undef;
|
||||
}
|
||||
my $res = $sth->execute( $id );
|
||||
if ( !$res ) {
|
||||
Error("Can't execute '$sql': ".$sth->errstr());
|
||||
return undef;
|
||||
}
|
||||
my $monitor = $sth->fetchrow_hashref();
|
||||
|
||||
return( $monitor );
|
||||
return $monitor;
|
||||
}
|
||||
|
||||
sub start_transaction {
|
||||
#my ( $caller, undef, $line ) = caller;
|
||||
#$openprint::log->debug("Called start_transaction from $caller : $line");
|
||||
my $d = shift;
|
||||
$d = $dbh if ! $d;
|
||||
my $ac = $d->{AutoCommit};
|
||||
|
@ -231,20 +251,29 @@ sub start_transaction {
|
|||
} # end sub start_transaction
|
||||
|
||||
sub end_transaction {
|
||||
#my ( $caller, undef, $line ) = caller;
|
||||
#$openprint::log->debug("Called end_transaction from $caller : $line");
|
||||
my ( $d, $ac ) = @_;
|
||||
if ( ! defined $ac ) {
|
||||
Error("Undefined ac");
|
||||
}
|
||||
$d = $dbh if ! $d;
|
||||
if ( $ac ) {
|
||||
#$log->debug("Committing");
|
||||
$d->commit();
|
||||
} # end if
|
||||
$d->{AutoCommit} = $ac;
|
||||
} # end sub end_transaction
|
||||
|
||||
# Basic execution of $dbh->do but with some pretty logging of the sql on error.
|
||||
# Returns 1 on success, 0 on error
|
||||
sub zmDbDo {
|
||||
my $sql = shift;
|
||||
if ( ! $dbh->do($sql, undef, @_) ) {
|
||||
$sql =~ s/\?/'%s'/;
|
||||
Error(sprintf("Failed $sql :", @_).$dbh->errstr());
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
@ -266,6 +295,7 @@ zmDbDisconnect
|
|||
zmDbGetMonitors
|
||||
zmDbGetMonitor
|
||||
zmDbGetMonitorAndControl
|
||||
zmDbDo
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ $serial = $primary_key = 'Id';
|
|||
Frames
|
||||
AlarmFrames
|
||||
DefaultVideo
|
||||
SaveJPEGs
|
||||
TotScore
|
||||
AvgScore
|
||||
MaxScore
|
||||
|
@ -83,6 +84,7 @@ $serial = $primary_key = 'Id';
|
|||
StateId
|
||||
Orientation
|
||||
DiskSpace
|
||||
Scheme
|
||||
);
|
||||
|
||||
use POSIX;
|
||||
|
@ -168,6 +170,8 @@ sub Path {
|
|||
|
||||
sub Scheme {
|
||||
my $self = shift;
|
||||
$$self{Scheme} = shift if @_;
|
||||
|
||||
if ( ! $$self{Scheme} ) {
|
||||
if ( $$self{RelativePath} ) {
|
||||
if ( $$self{RelativePath} =~ /^\d+\/\d{4}\-\d{2}\-\d{2}\/\d+$/ ) {
|
||||
|
@ -316,11 +320,11 @@ sub GenerateVideo {
|
|||
my $file_size = 'S'.$size;
|
||||
push( @file_parts, $file_size );
|
||||
}
|
||||
my $video_file = "$video_name-".$file_parts[0]."-".$file_parts[1].".$format";
|
||||
my $video_file = join('-', $video_name, $file_parts[0], $file_parts[1] ).'.'.$format;
|
||||
if ( $overwrite || !-s $video_file ) {
|
||||
Info( "Creating video file $video_file for event $self->{Id}\n" );
|
||||
Info("Creating video file $video_file for event $self->{Id}");
|
||||
|
||||
my $frame_rate = sprintf( "%.2f", $self->{Frames}/$self->{FullLength} );
|
||||
my $frame_rate = sprintf('%.2f', $self->{Frames}/$self->{FullLength});
|
||||
if ( $rate ) {
|
||||
if ( $rate != 1.0 ) {
|
||||
$frame_rate *= $rate;
|
||||
|
@ -351,19 +355,19 @@ sub GenerateVideo {
|
|||
.$Config{ZM_FFMPEG_OUTPUT_OPTIONS}
|
||||
." '$video_file' > ffmpeg.log 2>&1"
|
||||
;
|
||||
Debug( $command."\n" );
|
||||
Debug($command);
|
||||
my $output = qx($command);
|
||||
|
||||
my $status = $? >> 8;
|
||||
if ( $status ) {
|
||||
Error( "Unable to generate video, check $event_path/ffmpeg.log for details");
|
||||
Error("Unable to generate video, check $event_path/ffmpeg.log for details");
|
||||
return;
|
||||
}
|
||||
|
||||
Info( "Finished $video_file\n" );
|
||||
Info("Finished $video_file");
|
||||
return $event_path.'/'.$video_file;
|
||||
} else {
|
||||
Info( "Video file $video_file already exists for event $self->{Id}\n" );
|
||||
Info("Video file $video_file already exists for event $self->{Id}");
|
||||
return $event_path.'/'.$video_file;
|
||||
}
|
||||
return;
|
||||
|
@ -371,57 +375,49 @@ sub GenerateVideo {
|
|||
|
||||
sub delete {
|
||||
my $event = $_[0];
|
||||
if ( ! ( $event->{Id} and $event->{MonitorId} and $event->{StartTime} ) ) {
|
||||
my ( $caller, undef, $line ) = caller;
|
||||
Warning("Can't Delete event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime} from $caller:$line\n");
|
||||
return;
|
||||
}
|
||||
if ( ! -e $event->Storage()->Path() ) {
|
||||
Warning("Not deleting event because storage path doesn't exist");
|
||||
return;
|
||||
}
|
||||
Info("Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}\n");
|
||||
$ZoneMinder::Database::dbh->ping();
|
||||
|
||||
$ZoneMinder::Database::dbh->begin_work();
|
||||
#$event->lock_and_load();
|
||||
my $in_zmaudit = ( $0 =~ 'zmaudit.pl$');
|
||||
|
||||
{
|
||||
my $sql = 'DELETE FROM Frames WHERE EventId=?';
|
||||
my $sth = $ZoneMinder::Database::dbh->prepare_cached($sql)
|
||||
or Error( "Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr() );
|
||||
my $res = $sth->execute($event->{Id})
|
||||
or Error( "Can't execute '$sql': ".$sth->errstr() );
|
||||
$sth->finish();
|
||||
if ( ! $in_zmaudit ) {
|
||||
if ( ! ( $event->{Id} and $event->{MonitorId} and $event->{StartTime} ) ) {
|
||||
# zmfilter shouldn't delete anything in an odd situation. zmaudit will though.
|
||||
my ( $caller, undef, $line ) = caller;
|
||||
Warning("$0 Can't Delete event $event->{Id} from Monitor $event->{MonitorId} StartTime:".
|
||||
(defined($event->{StartTime})?$event->{StartTime}:'undef')." from $caller:$line");
|
||||
return;
|
||||
}
|
||||
if ( !($event->Storage()->Path() and -e $event->Storage()->Path()) ) {
|
||||
Warning('Not deleting event because storage path doesn\'t exist');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $$event{Id} ) {
|
||||
# Need to have an event Id if we are to delete from the db.
|
||||
Info("Deleting event $event->{Id} from Monitor $event->{MonitorId} StartTime:$event->{StartTime}");
|
||||
$ZoneMinder::Database::dbh->ping();
|
||||
|
||||
$ZoneMinder::Database::dbh->begin_work();
|
||||
#$event->lock_and_load();
|
||||
|
||||
ZoneMinder::Database::zmDbDo('DELETE FROM Frames WHERE EventId=?', $$event{Id});
|
||||
if ( $ZoneMinder::Database::dbh->errstr() ) {
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
return;
|
||||
}
|
||||
ZoneMinder::Database::zmDbDo('DELETE FROM Stats WHERE EventId=?', $$event{Id});
|
||||
if ( $ZoneMinder::Database::dbh->errstr() ) {
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = 'DELETE FROM Stats WHERE EventId=?';
|
||||
$sth = $ZoneMinder::Database::dbh->prepare_cached($sql)
|
||||
or Error("Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr());
|
||||
$res = $sth->execute($event->{Id})
|
||||
or Error("Can't execute '$sql': ".$sth->errstr());
|
||||
$sth->finish();
|
||||
if ( $ZoneMinder::Database::dbh->errstr() ) {
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
return;
|
||||
}
|
||||
# Do it individually to avoid locking up the table for new events
|
||||
ZoneMinder::Database::zmDbDo('DELETE FROM Events WHERE Id=?', $$event{Id});
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
}
|
||||
|
||||
# Do it individually to avoid locking up the table for new events
|
||||
{
|
||||
my $sql = 'DELETE FROM Events WHERE Id=?';
|
||||
my $sth = $ZoneMinder::Database::dbh->prepare_cached($sql)
|
||||
or Error("Can't prepare '$sql': ".$ZoneMinder::Database::dbh->errstr());
|
||||
my $res = $sth->execute($event->{Id})
|
||||
or Error("Can't execute '$sql': ".$sth->errstr());
|
||||
$sth->finish();
|
||||
}
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
if ( (! $Config{ZM_OPT_FAST_DELETE}) and $event->Storage()->DoDelete() ) {
|
||||
$event->delete_files( );
|
||||
if ( ( $in_zmaudit or (!$Config{ZM_OPT_FAST_DELETE})) and $event->Storage()->DoDelete() ) {
|
||||
$event->delete_files();
|
||||
} else {
|
||||
Debug('Not deleting event files from '.$event->Path().' for speed.');
|
||||
}
|
||||
|
@ -430,11 +426,11 @@ sub delete {
|
|||
sub delete_files {
|
||||
my $event = shift;
|
||||
|
||||
my $Storage = @_ ? $_[0] : new ZoneMinder::Storage( $$event{StorageId} );
|
||||
my $Storage = @_ ? $_[0] : new ZoneMinder::Storage($$event{StorageId});
|
||||
my $storage_path = $Storage->Path();
|
||||
|
||||
if ( ! $storage_path ) {
|
||||
Error("Empty storage path when deleting files for event $$event{Id} with storage id $$event{StorageId} ");
|
||||
Error("Empty storage path when deleting files for event $$event{Id} with storage id $$event{StorageId}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -466,14 +462,14 @@ sub delete_files {
|
|||
if ( $bucket->delete_key($event_path) ) {
|
||||
$deleted = 1;
|
||||
} else {
|
||||
Error("Failed to delete from S3:".$s3->err . ": " . $s3->errstr);
|
||||
Error('Failed to delete from S3:'.$s3->err . ': ' . $s3->errstr);
|
||||
}
|
||||
};
|
||||
Error($@) if $@;
|
||||
}
|
||||
if ( ! $deleted ) {
|
||||
if ( !$deleted ) {
|
||||
my $command = "/bin/rm -rf $storage_path/$event_path";
|
||||
ZoneMinder::General::executeShellCommand( $command );
|
||||
ZoneMinder::General::executeShellCommand($command);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,7 +478,7 @@ sub delete_files {
|
|||
Debug("Deleting link for Event $$event{Id} from $storage_path/$link_path.");
|
||||
if ( $link_path ) {
|
||||
( $link_path ) = ( $link_path =~ /^(.*)$/ ); # De-taint
|
||||
unlink($storage_path.'/'.$link_path) or Error( "Unable to unlink '$storage_path/$link_path': $!" );
|
||||
unlink($storage_path.'/'.$link_path) or Error("Unable to unlink '$storage_path/$link_path': $!");
|
||||
}
|
||||
}
|
||||
} # end sub delete_files
|
||||
|
@ -502,7 +498,7 @@ sub check_for_in_filesystem {
|
|||
if ( $path ) {
|
||||
if ( -e $path ) {
|
||||
my @files = glob "$path/*";
|
||||
Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found " . scalar @files . " files");
|
||||
Debug("Checking for files for event $_[0]{Id} at $path using glob $path/* found " . scalar @files . ' files');
|
||||
return 1 if @files;
|
||||
} else {
|
||||
Warning("Path not found for Event $_[0]{Id} at $path");
|
||||
|
@ -573,7 +569,7 @@ sub MoveTo {
|
|||
|
||||
if ( $$OldStorage{Id} != $$self{StorageId} ) {
|
||||
$ZoneMinder::Database::dbh->commit();
|
||||
return "Old Storage path changed, Event has moved somewhere else.";
|
||||
return 'Old Storage path changed, Event has moved somewhere else.';
|
||||
}
|
||||
|
||||
$$self{Storage} = $NewStorage;
|
||||
|
@ -617,11 +613,11 @@ Debug("Files to move @files");
|
|||
Debug("Moving file $file to $NewPath");
|
||||
my $size = -s $file;
|
||||
if ( ! $size ) {
|
||||
Info("Not moving file with 0 size");
|
||||
Info('Not moving file with 0 size');
|
||||
}
|
||||
my $file_contents = File::Slurp::read_file($file);
|
||||
if ( ! $file_contents ) {
|
||||
die "Loaded empty file, but it had a size. Giving up";
|
||||
die 'Loaded empty file, but it had a size. Giving up';
|
||||
}
|
||||
|
||||
my $filename = $event_path.'/'.File::Basename::basename($file);
|
||||
|
@ -629,7 +625,7 @@ Debug("Files to move @files");
|
|||
die "Unable to add key for $filename";
|
||||
}
|
||||
my $duration = time - $starttime;
|
||||
Debug("PUT to S3 " . Number::Bytes::Human::format_bytes($size) . " in $duration seconds = " . Number::Bytes::Human::format_bytes($duration?$size/$duration:$size) . '/sec');
|
||||
Debug('PUT to S3 ' . Number::Bytes::Human::format_bytes($size) . " in $duration seconds = " . Number::Bytes::Human::format_bytes($duration?$size/$duration:$size) . '/sec');
|
||||
} # end foreach file.
|
||||
|
||||
$moved = 1;
|
||||
|
|
|
@ -1,27 +1,3 @@
|
|||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder General Utility Module, $Date$, $Revision$
|
||||
# Copyright (C) 2001-2008 Philip Coombes
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
# This module contains the common definitions and functions used by the rest
|
||||
# of the ZoneMinder scripts
|
||||
#
|
||||
package ZoneMinder::General;
|
||||
|
||||
use 5.006;
|
||||
|
@ -42,7 +18,7 @@ our @ISA = qw(Exporter ZoneMinder::Base);
|
|||
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
|
||||
# will save memory.
|
||||
our %EXPORT_TAGS = (
|
||||
'functions' => [ qw(
|
||||
functions => [ qw(
|
||||
executeShellCommand
|
||||
getCmdFormat
|
||||
runCommand
|
||||
|
@ -56,7 +32,7 @@ our %EXPORT_TAGS = (
|
|||
);
|
||||
push( @{$EXPORT_TAGS{all}}, @{$EXPORT_TAGS{$_}} ) foreach keys %EXPORT_TAGS;
|
||||
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{all} } );
|
||||
|
||||
our @EXPORT = qw();
|
||||
|
||||
|
@ -80,74 +56,74 @@ sub executeShellCommand {
|
|||
my $output = qx( $command );
|
||||
my $status = $? >> 8;
|
||||
if ( $status || logDebugging() ) {
|
||||
Debug( "Command: $command\n" );
|
||||
Debug("Command: $command");
|
||||
chomp( $output );
|
||||
Debug( "Output: $output\n" );
|
||||
Debug("Output: $output");
|
||||
}
|
||||
return( $status );
|
||||
return $status;
|
||||
}
|
||||
|
||||
sub getCmdFormat {
|
||||
Debug( "Testing valid shell syntax\n" );
|
||||
Debug("Testing valid shell syntax");
|
||||
|
||||
my ( $name ) = getpwuid( $> );
|
||||
if ( $name eq $Config{ZM_WEB_USER} ) {
|
||||
Debug( "Running as '$name', su commands not needed\n" );
|
||||
return( "" );
|
||||
Debug("Running as '$name', su commands not needed");
|
||||
return '';
|
||||
}
|
||||
|
||||
my $null_command = "true";
|
||||
my $null_command = 'true';
|
||||
|
||||
my $prefix = "sudo -u ".$Config{ZM_WEB_USER}." ";
|
||||
my $suffix = "";
|
||||
my $prefix = 'sudo -u '.$Config{ZM_WEB_USER}.' ';
|
||||
my $suffix = '';
|
||||
my $command = $prefix.$null_command.$suffix;
|
||||
Debug( "Testing \"$command\"\n" );
|
||||
Debug("Testing \"$command\"");
|
||||
my $output = qx($command 2>&1);
|
||||
my $status = $? >> 8;
|
||||
$output //= $!;
|
||||
|
||||
if ( !$status ) {
|
||||
Debug( "Test ok, using format \"$prefix<command>$suffix\"\n" );
|
||||
Debug("Test ok, using format \"$prefix<command>$suffix\"");
|
||||
return( $prefix, $suffix );
|
||||
} else {
|
||||
chomp( $output );
|
||||
Debug( "Test failed, '$output'\n" );
|
||||
Debug("Test failed, '$output'");
|
||||
|
||||
$prefix = "su ".$Config{ZM_WEB_USER}." --shell=/bin/sh --command='";
|
||||
$suffix = "'";
|
||||
$prefix = 'su '.$Config{ZM_WEB_USER}.q` --shell=/bin/sh --command='`;
|
||||
$suffix = q`'`;
|
||||
$command = $prefix.$null_command.$suffix;
|
||||
Debug( "Testing \"$command\"\n" );
|
||||
Debug("Testing \"$command\"");
|
||||
my $output = qx($command 2>&1);
|
||||
my $status = $? >> 8;
|
||||
$output //= $!;
|
||||
|
||||
if ( !$status ) {
|
||||
Debug( "Test ok, using format \"$prefix<command>$suffix\"\n" );
|
||||
Debug("Test ok, using format \"$prefix<command>$suffix\"");
|
||||
return( $prefix, $suffix );
|
||||
} else {
|
||||
chomp( $output );
|
||||
Debug( "Test failed, '$output'\n" );
|
||||
chomp($output);
|
||||
Debug("Test failed, '$output'");
|
||||
|
||||
$prefix = "su ".$Config{ZM_WEB_USER}." -c '";
|
||||
$suffix = "'";
|
||||
$command = $prefix.$null_command.$suffix;
|
||||
Debug( "Testing \"$command\"\n" );
|
||||
Debug("Testing \"$command\"");
|
||||
$output = qx($command 2>&1);
|
||||
$status = $? >> 8;
|
||||
$output //= $!;
|
||||
|
||||
if ( !$status ) {
|
||||
Debug( "Test ok, using format \"$prefix<command>$suffix\"\n" );
|
||||
Debug("Test ok, using format \"$prefix<command>$suffix\"");
|
||||
return( $prefix, $suffix );
|
||||
} else {
|
||||
chomp( $output );
|
||||
Debug( "Test failed, '$output'\n" );
|
||||
chomp($output);
|
||||
Debug("Test failed, '$output'");
|
||||
}
|
||||
}
|
||||
}
|
||||
Error( "Unable to find valid 'su' syntax\n" );
|
||||
exit( -1 );
|
||||
}
|
||||
Error("Unable to find valid 'su' syntax");
|
||||
exit -1;
|
||||
} # end sub getCmdFormat
|
||||
|
||||
our $testedShellSyntax = 0;
|
||||
our ( $cmdPrefix, $cmdSuffix );
|
||||
|
@ -161,23 +137,23 @@ sub runCommand {
|
|||
}
|
||||
|
||||
my $command = shift;
|
||||
$command = $Config{ZM_PATH_BIN}."/".$command;
|
||||
$command = $Config{ZM_PATH_BIN}.'/'.$command;
|
||||
if ( $cmdPrefix ) {
|
||||
$command = $cmdPrefix.$command.$cmdSuffix;
|
||||
}
|
||||
Debug( "Command: $command\n" );
|
||||
Debug("Command: $command");
|
||||
my $output = qx($command);
|
||||
my $status = $? >> 8;
|
||||
chomp( $output );
|
||||
chomp($output);
|
||||
if ( $status || logDebugging() ) {
|
||||
if ( $status ) {
|
||||
Error( "Unable to run \"$command\", output is \"$output\", status is $status\n" );
|
||||
Error("Unable to run \"$command\", output is \"$output\", status is $status");
|
||||
} else {
|
||||
Debug( "Output: $output\n" );
|
||||
Debug("Output: $output");
|
||||
}
|
||||
}
|
||||
return( $output );
|
||||
}
|
||||
return $output;
|
||||
} # end sub runCommand
|
||||
|
||||
sub createEventPath {
|
||||
my $event = shift;
|
||||
|
@ -210,7 +186,7 @@ sub _checkProcessOwner {
|
|||
$_setFileOwner = 0;
|
||||
}
|
||||
}
|
||||
return( $_setFileOwner );
|
||||
return $_setFileOwner;
|
||||
}
|
||||
|
||||
sub setFileOwner {
|
||||
|
@ -219,7 +195,7 @@ sub setFileOwner {
|
|||
if ( _checkProcessOwner() ) {
|
||||
chown( $_ownerUid, $_ownerGid, $file )
|
||||
or Fatal( "Can't change ownership of file '$file' to '"
|
||||
.$Config{ZM_WEB_USER}.":".$Config{ZM_WEB_GROUP}."': $!"
|
||||
.$Config{ZM_WEB_USER}.':'.$Config{ZM_WEB_GROUP}."': $!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -234,13 +210,13 @@ sub _checkForImageInfo {
|
|||
};
|
||||
$_hasImageInfo = $@?0:1;
|
||||
}
|
||||
return( $_hasImageInfo );
|
||||
return $_hasImageInfo;
|
||||
}
|
||||
|
||||
sub createEvent {
|
||||
my $event = shift;
|
||||
|
||||
Debug( "Creating event" );
|
||||
Debug('Creating event');
|
||||
#print( Dumper( $event )."\n" );
|
||||
|
||||
_checkForImageInfo();
|
||||
|
@ -561,38 +537,33 @@ __END__
|
|||
|
||||
=head1 NAME
|
||||
|
||||
ZoneMinder::Database - Perl extension for blah blah blah
|
||||
ZoneMinder::General - Utility Functions for ZoneMinder
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use ZoneMinder::Database;
|
||||
use ZoneMinder::General;
|
||||
blah blah blah
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Stub documentation for ZoneMinder, created by h2xs. It looks like the
|
||||
author of the extension was negligent enough to leave the stub
|
||||
unedited.
|
||||
|
||||
Blah blah blah.
|
||||
This module contains the common definitions and functions used by the rest
|
||||
of the ZoneMinder scripts
|
||||
|
||||
=head2 EXPORT
|
||||
|
||||
None by default.
|
||||
functions => [ qw(
|
||||
executeShellCommand
|
||||
getCmdFormat
|
||||
runCommand
|
||||
setFileOwner
|
||||
createEventPath
|
||||
createEvent
|
||||
makePath
|
||||
jsonEncode
|
||||
jsonDecode
|
||||
) ]
|
||||
|
||||
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
Mention other useful documentation such as the documentation of
|
||||
related modules or operating system documentation (such as man pages
|
||||
in UNIX), or any relevant external documentation such as RFCs or
|
||||
standards.
|
||||
|
||||
If you have a mailing list set up for your module, mention it here.
|
||||
|
||||
If you have a web site set up for your module, mention it here.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Philip Coombes, E<lt>philip.coombes@zoneminder.comE<gt>
|
||||
|
@ -601,9 +572,18 @@ Philip Coombes, E<lt>philip.coombes@zoneminder.comE<gt>
|
|||
|
||||
Copyright (C) 2001-2008 Philip Coombes
|
||||
|
||||
This library is free software; you can redistribute it and/or modify
|
||||
it under the same terms as Perl itself, either Perl version 5.8.3 or,
|
||||
at your option, any later version of Perl 5 you may have available.
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
=cut
|
||||
|
|
|
@ -310,7 +310,7 @@ sub reinitialise {
|
|||
|
||||
# Bit of a nasty hack to reopen connections to log files and the DB
|
||||
my $syslogLevel = $this->syslogLevel();
|
||||
$this->syslogLevel( NOLOG );
|
||||
$this->syslogLevel(NOLOG);
|
||||
$this->syslogLevel($syslogLevel) if $syslogLevel > NOLOG;
|
||||
|
||||
my $logfileLevel = $this->fileLevel();
|
||||
|
@ -321,11 +321,10 @@ sub reinitialise {
|
|||
$this->databaseLevel(NOLOG);
|
||||
$this->databaseLevel($databaseLevel) if $databaseLevel > NOLOG;
|
||||
|
||||
my $screenLevel = $this->termLevel();
|
||||
$this->{hasTerm} = -t STDERR;
|
||||
my $termLevel = $this->termLevel();
|
||||
$this->termLevel(NOLOG);
|
||||
$this->termLevel($screenLevel) if $screenLevel > NOLOG;
|
||||
|
||||
$this->{sth} = undef;
|
||||
$this->termLevel($termLevel) if $termLevel > NOLOG;
|
||||
}
|
||||
|
||||
# Prevents undefined logging levels
|
||||
|
@ -439,16 +438,13 @@ sub databaseLevel {
|
|||
my $databaseLevel = shift;
|
||||
if ( defined($databaseLevel) ) {
|
||||
$databaseLevel = $this->limit($databaseLevel);
|
||||
if ( $this->{databaseLevel} != $databaseLevel ) {
|
||||
if ( ( $databaseLevel > NOLOG ) and ( $this->{databaseLevel} <= NOLOG ) ) {
|
||||
if ( !$this->{dbh} ) {
|
||||
$this->{dbh} = ZoneMinder::Database::zmDbConnect();
|
||||
}
|
||||
} elsif ( $databaseLevel <= NOLOG && $this->{databaseLevel} > NOLOG ) {
|
||||
undef($this->{dbh});
|
||||
}
|
||||
$this->{databaseLevel} = $databaseLevel;
|
||||
if ( $databaseLevel > NOLOG ) {
|
||||
$this->{dbh} = ZoneMinder::Database::zmDbConnect();
|
||||
} else {
|
||||
undef($this->{dbh});
|
||||
}
|
||||
$this->{sth} = undef;
|
||||
$this->{databaseLevel} = $databaseLevel;
|
||||
}
|
||||
return $this->{databaseLevel};
|
||||
}
|
||||
|
@ -558,12 +554,12 @@ sub logPrint {
|
|||
}
|
||||
|
||||
if ( $level <= $this->{databaseLevel} ) {
|
||||
if ( ! ( $this->{dbh} and $this->{dbh}->ping() ) ) {
|
||||
if ( ! ( $ZoneMinder::Database::dbh and $ZoneMinder::Database::dbh->ping() ) ) {
|
||||
$this->{sth} = undef;
|
||||
# Turn this off because zDbConnect will do logging calls.
|
||||
my $oldlevel = $this->{databaseLevel};
|
||||
$this->{databaseLevel} = NOLOG;
|
||||
if ( ! ( $this->{dbh} = ZoneMinder::Database::zmDbConnect() ) ) {
|
||||
if ( ! ZoneMinder::Database::zmDbConnect() ) {
|
||||
#print(STDERR "Can't log to database: ");
|
||||
return;
|
||||
}
|
||||
|
@ -571,10 +567,10 @@ sub logPrint {
|
|||
}
|
||||
|
||||
my $sql = 'INSERT INTO Logs ( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, NULL )';
|
||||
$this->{sth} = $this->{dbh}->prepare_cached($sql) if ! $this->{sth};
|
||||
$this->{sth} = $ZoneMinder::Database::dbh->prepare_cached($sql) if ! $this->{sth};
|
||||
if ( !$this->{sth} ) {
|
||||
$this->{databaseLevel} = NOLOG;
|
||||
Error("Can't prepare log entry '$sql': ".$this->{dbh}->errstr());
|
||||
Error("Can't prepare log entry '$sql': ".$ZoneMinder::Database::dbh->errstr());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -590,7 +586,7 @@ sub logPrint {
|
|||
);
|
||||
if ( !$res ) {
|
||||
$this->{databaseLevel} = NOLOG;
|
||||
Error("Can't execute log entry '$sql': ".$this->{dbh}->errstr());
|
||||
Error("Can't execute log entry '$sql': ".$ZoneMinder::Database::dbh->errstr());
|
||||
}
|
||||
} # end if doing db logging
|
||||
} # end if level < effectivelevel
|
||||
|
@ -705,7 +701,7 @@ sub Fatal( @ ) {
|
|||
$SIG{TERM}();
|
||||
}
|
||||
# I think if we don't disconnect we will leave sockets around in TIME_WAIT
|
||||
zmDbDisconnect();
|
||||
ZoneMinder::Database::zmDbDisconnect();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,6 @@ our $mem_data = {
|
|||
format => { type=>'uint8', seq=>$mem_seq++ },
|
||||
imagesize => { type=>'uint32', seq=>$mem_seq++ },
|
||||
epadding1 => { type=>'uint32', seq=>$mem_seq++ },
|
||||
epadding2 => { type=>'uint32', seq=>$mem_seq++ },
|
||||
startup_time => { type=>'time_t64', seq=>$mem_seq++ },
|
||||
last_write_time => { type=>'time_t64', seq=>$mem_seq++ },
|
||||
last_read_time => { type=>'time_t64', seq=>$mem_seq++ },
|
||||
|
@ -813,7 +812,7 @@ shared_data The general mapped memory section
|
|||
size The size, in bytes, of this section
|
||||
valid Flag indicating whether this section has been initialised
|
||||
active Flag indicating whether this monitor is active (enabled/disabled)
|
||||
signal Flag indicating whether this monitor is reciving a valid signal
|
||||
signal Flag indicating whether this monitor is receiving a valid signal
|
||||
state The current monitor state, see the STATE constants below
|
||||
last_write_index The last index, in the image buffer, that an image has been saved to
|
||||
last_read_index The last index, in the image buffer, that an image has been analysed from
|
||||
|
|
|
@ -456,7 +456,7 @@ sub transform {
|
|||
sub to_string {
|
||||
my $type = ref($_[0]);
|
||||
my $fields = eval '\%'.$type.'::fields';
|
||||
return $type . ': '. join(' ' , map { $_[0]{$_} ? "$_ => $_[0]{$_}" : () } keys %$fields );
|
||||
return $type . ': '. join(' ' , map { $_[0]{$_} ? "$_ => $_[0]{$_}" : () } sort { $a cmp $b } keys %$fields );
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
|
|
|
@ -384,7 +384,7 @@ MAIN: while( $loop ) {
|
|||
Debug("Checking for Medium Scheme Events under $$Storage{Path}/$monitor_dir");
|
||||
{
|
||||
my @event_dirs = glob("$monitor_dir/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/*");
|
||||
Debug(qq`glob("$monitor_dir/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/*") returned ` . scalar @event_dirs . " entries." );
|
||||
Debug(qq`glob("$monitor_dir/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/*") returned ` . scalar @event_dirs . ' entries.' );
|
||||
foreach my $event_dir ( @event_dirs ) {
|
||||
if ( ! -d $event_dir ) {
|
||||
Debug( "$event_dir is not a dir. Skipping" );
|
||||
|
@ -403,6 +403,7 @@ MAIN: while( $loop ) {
|
|||
$$Event{RelativePath} = $event_dir;
|
||||
$Event->MonitorId( $monitor_dir );
|
||||
$Event->StorageId( $Storage->Id() );
|
||||
$Event->StartTime( POSIX::strftime('%Y-%m-%d %H:%M:%S', gmtime(time_of_youngest_file($$Event{Path})) ) );
|
||||
} # end foreach event
|
||||
}
|
||||
|
||||
|
@ -428,7 +429,7 @@ MAIN: while( $loop ) {
|
|||
} # end foreach event
|
||||
chdir( $Storage->Path() );
|
||||
} # if USE_DEEP_STORAGE
|
||||
Debug( 'Got '.int(keys(%$fs_events))." filesystem events for monitor $monitor_dir\n" );
|
||||
Debug( 'Got '.int(keys(%$fs_events))." filesystem events for monitor $monitor_dir" );
|
||||
|
||||
delete_empty_subdirs($$Storage{Path}.'/'.$monitor_dir);
|
||||
} # end foreach monitor
|
||||
|
@ -446,13 +447,19 @@ MAIN: while( $loop ) {
|
|||
next;
|
||||
}
|
||||
my @event_ids = keys %$fs_events;
|
||||
Debug("Have " .scalar @event_ids . " events for monitor $monitor_id");
|
||||
Debug('Have ' .scalar @event_ids . " events for monitor $monitor_id");
|
||||
|
||||
foreach my $fs_event_id ( sort { $a <=> $b } keys %$fs_events ) {
|
||||
|
||||
my $Event = $fs_events->{$fs_event_id};
|
||||
|
||||
if ( ! defined( $db_events->{$fs_event_id} ) ) {
|
||||
# Long running zmaudits can find events that were created after we loaded all db events.
|
||||
# So do a secondary lookup
|
||||
if ( ZoneMinder::Event->find_one(Id=>$fs_event_id) ) {
|
||||
Debug("$$Event{Id} found in secondary lookup.");
|
||||
next;
|
||||
}
|
||||
my $age = $Event->age();
|
||||
|
||||
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||
|
@ -490,7 +497,11 @@ MAIN: while( $loop ) {
|
|||
}
|
||||
}
|
||||
} # end foreach Storage Area
|
||||
redo MAIN if ( $cleaned );
|
||||
|
||||
if ( $cleaned ) {
|
||||
Debug("Events were deleted, starting again.");
|
||||
redo MAIN;
|
||||
}
|
||||
|
||||
$cleaned = 0;
|
||||
my $deleteMonitorSql = 'DELETE LOW_PRIORITY FROM Monitors WHERE Id = ?';
|
||||
|
@ -508,68 +519,88 @@ MAIN: while( $loop ) {
|
|||
|
||||
# Foreach database monitor and it's list of events.
|
||||
while ( my ( $db_monitor, $db_events ) = each(%$db_monitors) ) {
|
||||
Debug("Checking db events for monitor $db_monitor");
|
||||
if ( ! $db_events ) {
|
||||
Debug("Skipping db events for $db_monitor because there are none");
|
||||
next;
|
||||
}
|
||||
|
||||
# If we found the monitor in the file system
|
||||
if ( my $fs_events = $fs_monitors->{$db_monitor} ) {
|
||||
next if ! $db_events;
|
||||
my $fs_events = $fs_monitors->{$db_monitor};
|
||||
|
||||
while ( my ( $db_event, $age ) = each( %$db_events ) ) {
|
||||
if ( ! defined( $fs_events->{$db_event} ) ) {
|
||||
my $Event = ZoneMinder::Event->find_one( Id=>$db_event );
|
||||
if ( ! $Event ) {
|
||||
Debug("Event $db_event is no longer in db. Filter probably deleted it while we were auditing.");
|
||||
next;
|
||||
while ( my ( $db_event, $age ) = each( %$db_events ) ) {
|
||||
if ( ! ($fs_events and defined( $fs_events->{$db_event} ) ) ) {
|
||||
Debug("Don't have an fs event for $db_event");
|
||||
my $Event = ZoneMinder::Event->find_one( Id=>$db_event );
|
||||
if ( ! $Event ) {
|
||||
Debug("Event $db_event is no longer in db. Filter probably deleted it while we were auditing.");
|
||||
next;
|
||||
}
|
||||
Debug("Event $db_event is not in fs. Should have been at ".$Event->Path());
|
||||
if ( $Event->Archived() ) {
|
||||
Warning("Event $$Event{Id} is Archived. Taking no further action on it.");
|
||||
next;
|
||||
}
|
||||
if ( ! $Event->StartTime() ) {
|
||||
Info("Event $$Event{Id} has no start time.");
|
||||
if ( confirm() ) {
|
||||
$Event->delete();
|
||||
$cleaned = 1;
|
||||
}
|
||||
Debug("Event $db_event is not in fs. Should have been at ".$Event->Path());
|
||||
if ( $Event->Archived() ) {
|
||||
Warning("Event $$Event{Id} is Archived. Taking no further action on it.");
|
||||
next;
|
||||
}
|
||||
if ( ! $Event->StartTime() ) {
|
||||
Info("Event $$Event{Id} has no start time. deleting it.");
|
||||
next;
|
||||
}
|
||||
if ( ! $Event->EndTime() ) {
|
||||
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||
Info("Event $$Event{Id} has no end time and is $age seconds old. deleting it.");
|
||||
if ( confirm() ) {
|
||||
$Event->delete();
|
||||
$cleaned = 1;
|
||||
}
|
||||
next;
|
||||
}
|
||||
if ( ! $Event->EndTime() ) {
|
||||
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||
Info("Event $$Event{Id} has no end time and is $age seconds old. deleting it.");
|
||||
if ( confirm() ) {
|
||||
$Event->delete();
|
||||
$cleaned = 1;
|
||||
}
|
||||
next;
|
||||
}
|
||||
if ( $Event->check_for_in_filesystem() ) {
|
||||
Debug("Database event $$Event{Id} apparently exists at " . $Event->Path() );
|
||||
} else {
|
||||
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||
aud_print( "Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem, deleting' );
|
||||
if ( confirm() ) {
|
||||
$Event->delete();
|
||||
$cleaned = 1;
|
||||
}
|
||||
}
|
||||
if ( $Event->check_for_in_filesystem() ) {
|
||||
Debug("Database event $$Event{Id} apparently exists at " . $Event->Path() );
|
||||
} else {
|
||||
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
|
||||
aud_print( "Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem, deleting' );
|
||||
if ( confirm() ) {
|
||||
$Event->delete();
|
||||
$cleaned = 1;
|
||||
}
|
||||
aud_print( "Database event '".$Event->Path()." monitor:$db_monitor event:$db_event' does not exist in filesystem but too young to delete age: $age > MIN $Config{ZM_AUDIT_MIN_AGE}.\n" );
|
||||
}
|
||||
} # end if exists in filesystem
|
||||
} else {
|
||||
Debug("Found fs event for $db_event, $age at " . $$fs_events{$db_event}->Path());
|
||||
my $Event = new ZoneMinder::Event( $db_event );
|
||||
if ( ! $Event->check_for_in_filesystem() ) {
|
||||
Warning("Not found at " . $Event->Path() . ' was found at ' . $$fs_events{$db_event}->Path() );
|
||||
Warning($Event->to_string());
|
||||
Warning($$fs_events{$db_event}->to_string());
|
||||
if ( $$fs_events{$db_event}->Scheme() ne $Event->Scheme() ) {
|
||||
Info("Updating scheme on event $$Event{Id} from $$Event{Scheme} to $$fs_events{$db_event}{Scheme}");
|
||||
$Event->Scheme($$fs_events{$db_event}->Scheme());
|
||||
}
|
||||
if ( $$fs_events{$db_event}->StorageId() != $Event->StorageId() ) {
|
||||
Info("Updating storage area on event $$Event{Id} from $$Event{StorageId} to $$fs_events{$db_event}{StorageId}");
|
||||
$Event->StorageId($$fs_events{$db_event}->StorageId());
|
||||
}
|
||||
if ( $$fs_events{$db_event}->StartTime() ne $Event->StartTime() ) {
|
||||
Info("Updating StartTime on event $$Event{Id} from $$Event{StartTime} to $$fs_events{$db_event}{StartTime}");
|
||||
if ( $$Event{Scheme} eq 'Deep' ) {
|
||||
$Event->StartTime($$fs_events{$db_event}->StartTime());
|
||||
} else {
|
||||
aud_print( "Database event '".$Event->Path()." monitor:$db_monitor event:$db_event' does not exist in filesystem but too young to delete age: $age > MIN $Config{ZM_AUDIT_MIN_AGE}.\n" );
|
||||
$Event->StartTime($$fs_events{$db_event}->StartTime());
|
||||
}
|
||||
} # end if exists in filesystem
|
||||
} # end if ! in fs_events
|
||||
} # foreach db_event
|
||||
#} else {
|
||||
#my $Monitor = new ZoneMinder::Monitor( $db_monitor );
|
||||
#my $Storage = $Monitor->Storage();
|
||||
#aud_print( "Database monitor '$db_monitor' does not exist in filesystem, should have been at ".$Storage->Path().'/'.$Monitor->Id()."\n" );
|
||||
#if ( confirm() )
|
||||
#{
|
||||
# We don't actually do this in case it's new
|
||||
#my $res = $deleteMonitorSth->execute( $db_monitor )
|
||||
# or Fatal( "Can't execute: ".$deleteMonitorSth->errstr() );
|
||||
#$cleaned = 1;
|
||||
#}
|
||||
}
|
||||
$Event->save();
|
||||
}
|
||||
|
||||
$Event->save();
|
||||
}
|
||||
} # end if ! in fs_events
|
||||
} # foreach db_event
|
||||
} # end foreach db_monitor
|
||||
if ( $cleaned ) {
|
||||
Debug("Have done some cleaning, restarting.");
|
||||
|
@ -954,7 +985,7 @@ sub delete_empty_directories {
|
|||
return;
|
||||
}
|
||||
my @contents = map { ( $_ eq '.' or $_ eq '..' ) ? () : $_ } readdir( $DIR );
|
||||
Debug("delete_empty_directories $_[0] has " . @contents .' entries:' . ( @contents <= 2 ? join(',',@contents) : '' ));
|
||||
#Debug("delete_empty_directories $_[0] has " . @contents .' entries:' . ( @contents <= 2 ? join(',',@contents) : '' ));
|
||||
my @dirs = map { -d $_[0].'/'.$_ ? $_ : () } @contents;
|
||||
if ( @dirs ) {
|
||||
Debug("Have " . @dirs . " dirs");
|
||||
|
@ -975,6 +1006,25 @@ sub delete_empty_directories {
|
|||
}
|
||||
} # end sub delete_empty_directories
|
||||
|
||||
sub time_of_youngest_file {
|
||||
my $dir = shift;
|
||||
|
||||
if ( ! opendir(DIR, $dir) ) {
|
||||
Error("Can't open directory '$dir': $!");
|
||||
return;
|
||||
}
|
||||
my $youngest = (stat($dir))[9];
|
||||
Debug("stat of $dir is $youngest");
|
||||
foreach my $file ( readdir( DIR ) ) {
|
||||
next if $file =~ /^\./;
|
||||
$_ = (stat($dir))[9];
|
||||
$youngest = $_ if $_ and ( $_ < $youngest );
|
||||
#Debug("stat of $dir is $_ < $youngest");
|
||||
}
|
||||
Debug("stat of $dir is $youngest");
|
||||
return $youngest;
|
||||
} # end sub time_of_youngest_file
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
|
@ -438,7 +438,7 @@ sub start {
|
|||
|
||||
$dbh = zmDbConnect(1);
|
||||
# This logReinit is required. Not sure why.
|
||||
#logReinit();
|
||||
logReinit();
|
||||
|
||||
$process->{pid} = $cpid;
|
||||
$process->{started} = time();
|
||||
|
|
|
@ -69,6 +69,7 @@ use Time::HiRes qw/gettimeofday/;
|
|||
use Getopt::Long;
|
||||
use autouse 'Pod::Usage'=>qw(pod2usage);
|
||||
use autouse 'Data::Dumper'=>qw(Dumper);
|
||||
use File::Path qw(make_path);
|
||||
|
||||
my $daemon = 0;
|
||||
my $filter_name = '';
|
||||
|
@ -162,7 +163,7 @@ my $delay = $Config{ZM_FILTER_EXECUTE_INTERVAL};
|
|||
my $event_id = 0;
|
||||
|
||||
if ( ! EVENT_PATH ) {
|
||||
Error("No event path defined. Config was $Config{ZM_DIR_EVENTS}\n");
|
||||
Error("No event path defined. Config was $Config{ZM_DIR_EVENTS}");
|
||||
die;
|
||||
}
|
||||
|
||||
|
@ -173,11 +174,11 @@ chdir( EVENT_PATH );
|
|||
my $dbh = zmDbConnect();
|
||||
|
||||
if ( $filter_name ) {
|
||||
Info("Scanning for events using filter '$filter_name'\n");
|
||||
Info("Scanning for events using filter '$filter_name'");
|
||||
} elsif ( $filter_id ) {
|
||||
Info("Scanning for events using filter id '$filter_id'\n");
|
||||
Info("Scanning for events using filter id '$filter_id'");
|
||||
} else {
|
||||
Info("Scanning for events using all filters\n");
|
||||
Info("Scanning for events using all filters");
|
||||
}
|
||||
|
||||
if ( ! ( $filter_name or $filter_id ) ) {
|
||||
|
@ -191,7 +192,7 @@ my $last_action = 0;
|
|||
while( !$zm_terminate ) {
|
||||
my $now = time;
|
||||
if ( ($now - $last_action) > $Config{ZM_FILTER_RELOAD_DELAY} ) {
|
||||
Debug("Reloading filters\n");
|
||||
Debug("Reloading filters");
|
||||
$last_action = $now;
|
||||
@filters = getFilters({ Name=>$filter_name, Id=>$filter_id });
|
||||
}
|
||||
|
@ -211,7 +212,7 @@ while( !$zm_terminate ) {
|
|||
|
||||
last if (!$daemon and ($filter_name or $filter_id)) or $zm_terminate;
|
||||
|
||||
Debug("Sleeping for $delay seconds\n");
|
||||
Debug("Sleeping for $delay seconds");
|
||||
sleep($delay);
|
||||
}
|
||||
|
||||
|
@ -405,10 +406,10 @@ sub generateVideo {
|
|||
chomp($output);
|
||||
my $status = $? >> 8;
|
||||
if ( $status || logDebugging() ) {
|
||||
Debug("Output: $output\n");
|
||||
Debug("Output: $output");
|
||||
}
|
||||
if ( $status ) {
|
||||
Error("Video generation '$command' failed with status: $status\n");
|
||||
Error("Video generation '$command' failed with status: $status");
|
||||
if ( wantarray() ) {
|
||||
return( undef, undef );
|
||||
}
|
||||
|
@ -453,7 +454,7 @@ sub generateImage {
|
|||
chomp( $output );
|
||||
my $status = $? >> 8;
|
||||
if ( $status || logDebugging() ) {
|
||||
Debug("Output: $output\n");
|
||||
Debug("Output: $output");
|
||||
}
|
||||
if ( $status ) {
|
||||
Error("Failed $command status $status");
|
||||
|
@ -474,15 +475,23 @@ sub uploadArchFile {
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
# Try to make the path to the upload folder if it doesn't already exist
|
||||
make_path( $Config{ZM_UPLOAD_LOC_DIR} );
|
||||
|
||||
# Complain if the upload folder is still not writable
|
||||
if ( ! -w $Config{ZM_UPLOAD_LOC_DIR} ) {
|
||||
Error("Upload folder either does not exist or is not writable: $Config{ZM_UPLOAD_LOC_DIR}");
|
||||
return(0);
|
||||
}
|
||||
|
||||
my $archFile = $Event->{MonitorName}.'-'.$Event->{Id};
|
||||
my $archImagePath = $Event->Path()
|
||||
.'/'
|
||||
.(
|
||||
( $Config{ZM_UPLOAD_ARCH_ANALYSE} )
|
||||
? '{*analyse,*capture}'
|
||||
: '*capture'
|
||||
? '{*analyse.jpg,*capture.jpg,snapshot.jpg,*.mp4}'
|
||||
: '{*capture.jpg,snapshot.jpg,*.mp4}'
|
||||
)
|
||||
.'.jpg'
|
||||
;
|
||||
my @archImageFiles = glob($archImagePath);
|
||||
my $archLocPath;
|
||||
|
@ -492,11 +501,11 @@ sub uploadArchFile {
|
|||
$archFile .= '.zip';
|
||||
$archLocPath = $Config{ZM_UPLOAD_LOC_DIR}.'/'.$archFile;
|
||||
my $zip = Archive::Zip->new();
|
||||
Info("Creating upload file '$archLocPath', ".int(@archImageFiles)." files\n");
|
||||
Info("Creating upload file '$archLocPath', ".int(@archImageFiles).' files');
|
||||
|
||||
my $status = &AZ_OK;
|
||||
foreach my $imageFile ( @archImageFiles ) {
|
||||
Debug("Adding $imageFile\n");
|
||||
Debug("Adding $imageFile");
|
||||
my $member = $zip->addFile($imageFile);
|
||||
if ( !$member ) {
|
||||
Error("Unable toto add image file $imageFile to zip archive $archLocPath");
|
||||
|
@ -524,7 +533,7 @@ sub uploadArchFile {
|
|||
$archFile .= '.tar';
|
||||
}
|
||||
$archLocPath = $Config{ZM_UPLOAD_LOC_DIR}.'/'.$archFile;
|
||||
Info("Creating upload file '$archLocPath', ".int(@archImageFiles)." files\n");
|
||||
Info("Creating upload file '$archLocPath', ".int(@archImageFiles).' files');
|
||||
|
||||
if ( $archError = !Archive::Tar->create_archive(
|
||||
$archLocPath,
|
||||
|
@ -567,7 +576,8 @@ sub uploadArchFile {
|
|||
$host .= ':'.$Config{ZM_UPLOAD_PORT} if $Config{ZM_UPLOAD_PORT};
|
||||
Info('Uploading to '.$host.' using SFTP');
|
||||
my %sftpOptions = (
|
||||
host=>$Config{ZM_UPLOAD_HOST}, user=>$Config{ZM_UPLOAD_USER}
|
||||
host=>$Config{ZM_UPLOAD_HOST},
|
||||
user=>$Config{ZM_UPLOAD_USER},
|
||||
($Config{ZM_UPLOAD_PASS} ? (password=>$Config{ZM_UPLOAD_PASS}) : ()),
|
||||
($Config{ZM_UPLOAD_PORT} ? (port=>$Config{ZM_UPLOAD_PORT}) : ()),
|
||||
($Config{ZM_UPLOAD_TIMEOUT} ? (timeout=>$Config{ZM_UPLOAD_TIMEOUT}) : ()),
|
||||
|
|
|
@ -44,7 +44,6 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
|
|||
my $store_state=''; # PP - will remember state name passed
|
||||
|
||||
logInit();
|
||||
Info("Aftere LogInit");
|
||||
|
||||
my $command = $ARGV[0]||'';
|
||||
if ( $command eq 'version' ) {
|
||||
|
@ -316,12 +315,14 @@ sub isActiveSanityCheck {
|
|||
if ( $sth->rows != 1 ) {
|
||||
# PP - no row, or too many rows. Either case is an error
|
||||
Info( 'Fixing States table - either no default state or duplicate default states' );
|
||||
$sql = "DELETE FROM States WHERE Name='default'";
|
||||
$sth = $dbh->prepare_cached( $sql )
|
||||
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
$res = $sth->execute()
|
||||
or Fatal( "Can't execute: ".$sth->errstr() );
|
||||
$sql = q`"INSERT INTO States (Name,Definition,IsActive) VALUES ('default','','1');`;
|
||||
if ( $sth->rows ) {
|
||||
$sql = q`DELETE FROM States WHERE Name='default'`;
|
||||
$sth = $dbh->prepare_cached( $sql )
|
||||
or Fatal( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
$res = $sth->execute()
|
||||
or Fatal( "Can't execute: ".$sth->errstr() );
|
||||
}
|
||||
$sql = q`INSERT INTO States (Name,Definition,IsActive) VALUES ('default','','1');`;
|
||||
$sth = $dbh->prepare_cached($sql)
|
||||
or Fatal("Can't prepare '$sql': ".$dbh->errstr());
|
||||
$res = $sth->execute()
|
||||
|
|
|
@ -1,39 +1,4 @@
|
|||
#!/usr/bin/perl -wT
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder WatchDog Script, $Date$, $Revision$
|
||||
# Copyright (C) 2001-2008 Philip Coombes
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
|
||||
=head1 NAME
|
||||
|
||||
zmwatch.pl - ZoneMinder Stats Updating Script
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
zmstats.pl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This does background updating various stats in the db like event counts, diskspace, etc.
|
||||
|
||||
=cut
|
||||
use strict;
|
||||
use bytes;
|
||||
|
||||
|
@ -66,8 +31,8 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
|
|||
logInit();
|
||||
logSetSignal();
|
||||
|
||||
Info( "Stats Daemon starting in ".START_DELAY." seconds\n" );
|
||||
sleep( START_DELAY );
|
||||
Info("Stats Daemon starting in ".START_DELAY." seconds");
|
||||
sleep(START_DELAY);
|
||||
|
||||
my $dbh = zmDbConnect();
|
||||
|
||||
|
@ -88,7 +53,43 @@ while( 1 ) {
|
|||
sleep($Config{ZM_STATS_UPDATE_INTERVAL});
|
||||
} # end while (1)
|
||||
|
||||
Info( "Stats Daemon exiting\n" );
|
||||
Info("Stats Daemon exiting");
|
||||
exit();
|
||||
1;
|
||||
__END__
|
||||
|
||||
#
|
||||
# ==========================================================================
|
||||
#
|
||||
# ZoneMinder WatchDog Script, $Date$, $Revision$
|
||||
# Copyright (C) 2001-2008 Philip Coombes
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# ==========================================================================
|
||||
|
||||
=head1 NAME
|
||||
|
||||
zmstats.pl - ZoneMinder Stats Updating Script
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
zmstats.pl
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This does background updating various stats in the db like event counts, diskspace, etc.
|
||||
|
||||
=cut
|
||||
|
|
|
@ -88,13 +88,13 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
|
|||
logInit();
|
||||
logSetSignal();
|
||||
|
||||
Info( "Trigger daemon starting\n" );
|
||||
Info( "Trigger daemon starting" );
|
||||
|
||||
my $dbh = zmDbConnect();
|
||||
|
||||
my $base_rin = '';
|
||||
foreach my $connection ( @connections ) {
|
||||
Info( "Opening connection '$connection->{name}'\n" );
|
||||
Info( "Opening connection '$connection->{name}'" );
|
||||
$connection->open();
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ foreach my $connection ( @in_select_connections ) {
|
|||
my %spawned_connections;
|
||||
my %monitors;
|
||||
my $monitor_reload_time = 0;
|
||||
my $needsReload = 0;
|
||||
my @needsReload;
|
||||
loadMonitors();
|
||||
|
||||
$! = undef;
|
||||
|
@ -127,14 +127,14 @@ while( 1 ) {
|
|||
|
||||
my $nfound = select( my $rout = $rin, undef, my $eout = $ein, $timeout );
|
||||
if ( $nfound > 0 ) {
|
||||
Debug( "Got input from $nfound connections\n" );
|
||||
Debug( "Got input from $nfound connections" );
|
||||
foreach my $connection ( @in_select_connections ) {
|
||||
if ( vec( $rout, $connection->fileno(), 1 ) ) {
|
||||
Debug( 'Got input from connection '
|
||||
.$connection->name()
|
||||
.' ('
|
||||
.$connection->fileno()
|
||||
.")\n"
|
||||
.")"
|
||||
);
|
||||
if ( $connection->spawns() ) {
|
||||
my $new_connection = $connection->accept();
|
||||
|
@ -143,7 +143,7 @@ while( 1 ) {
|
|||
.$new_connection->fileno()
|
||||
.'), '
|
||||
.int(keys(%spawned_connections))
|
||||
." spawned connections\n"
|
||||
." spawned connections"
|
||||
);
|
||||
} else {
|
||||
my $messages = $connection->getMessages();
|
||||
|
@ -162,7 +162,7 @@ while( 1 ) {
|
|||
.$connection->name()
|
||||
.' ('
|
||||
.$connection->fileno()
|
||||
.")\n"
|
||||
.")"
|
||||
);
|
||||
my $messages = $connection->getMessages();
|
||||
if ( defined($messages) ) {
|
||||
|
@ -175,7 +175,7 @@ while( 1 ) {
|
|||
.$connection->fileno()
|
||||
.'), '
|
||||
.int(keys(%spawned_connections))
|
||||
." spawned connections\n"
|
||||
." spawned connections"
|
||||
);
|
||||
$connection->close();
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ while( 1 ) {
|
|||
if ( ! zmMemVerify($monitor) ) {
|
||||
# Our attempt to verify the memory handle failed. We should reload the monitors.
|
||||
# Don't need to zmMemInvalidate because the monitor reload will do it.
|
||||
$needsReload = 1;
|
||||
push @needsReload, $monitor;
|
||||
next;
|
||||
}
|
||||
|
||||
|
@ -217,8 +217,8 @@ while( 1 ) {
|
|||
]
|
||||
);
|
||||
|
||||
#print( "$monitor->{Id}: S:$state, LE:$last_event\n" );
|
||||
#print( "$monitor->{Id}: mS:$monitor->{LastState}, mLE:$monitor->{LastEvent}\n" );
|
||||
#print( "$monitor->{Id}: S:$state, LE:$last_event" );
|
||||
#print( "$monitor->{Id}: mS:$monitor->{LastState}, mLE:$monitor->{LastEvent}" );
|
||||
if ( $state == STATE_ALARM || $state == STATE_ALERT ) {
|
||||
# In alarm state
|
||||
if ( !defined($monitor->{LastEvent})
|
||||
|
@ -261,14 +261,14 @@ while( 1 ) {
|
|||
}
|
||||
|
||||
if ( my @action_times = keys(%actions) ) {
|
||||
Debug( "Checking for timed actions\n" );
|
||||
Debug( "Checking for timed actions" );
|
||||
my $now = time();
|
||||
foreach my $action_time ( sort( grep { $_ < $now } @action_times ) ) {
|
||||
Info( "Found actions expiring at $action_time\n" );
|
||||
Info( "Found actions expiring at $action_time" );
|
||||
foreach my $action ( @{$actions{$action_time}} ) {
|
||||
my $connection = $action->{connection};
|
||||
my $message = $action->{message};
|
||||
Info( "Found action '$message'\n" );
|
||||
Info( "Found action '$message'" );
|
||||
handleMessage( $connection, $message );
|
||||
}
|
||||
delete( $actions{$action_time} );
|
||||
|
@ -293,23 +293,41 @@ while( 1 ) {
|
|||
}
|
||||
}
|
||||
|
||||
# If necessary reload monitors
|
||||
if ( $needsReload || ((time() - $monitor_reload_time) > MONITOR_RELOAD_INTERVAL )) {
|
||||
# Reload all monitors from the dB every MONITOR_RELOAD_INTERVAL
|
||||
if ( (time() - $monitor_reload_time) > MONITOR_RELOAD_INTERVAL ) {
|
||||
foreach my $monitor ( values(%monitors) ) {
|
||||
# Free up any used memory handle
|
||||
zmMemInvalidate( $monitor );
|
||||
zmMemInvalidate( $monitor ); # Free up any used memory handle
|
||||
}
|
||||
loadMonitors();
|
||||
$needsReload = 0;
|
||||
@needsReload = (); # We just reloaded all monitors so no need reload a specific monitor
|
||||
# If we have NOT just reloaded all monitors, reload a specific monitor if its shared mem changed
|
||||
} elsif ( @needsReload ) {
|
||||
foreach my $monitor ( @needsReload ) {
|
||||
loadMonitor($monitor);
|
||||
}
|
||||
@needsReload = ();
|
||||
}
|
||||
|
||||
# zmDbConnect will ping and reconnect if neccessary
|
||||
$dbh = zmDbConnect();
|
||||
} # end while ( 1 )
|
||||
Info( "Trigger daemon exiting\n" );
|
||||
Info( "Trigger daemon exiting" );
|
||||
exit;
|
||||
|
||||
sub loadMonitor {
|
||||
my $monitor = shift;
|
||||
|
||||
Debug( "Loading monitor $monitor" );
|
||||
zmMemInvalidate( $monitor );
|
||||
|
||||
if ( zmMemVerify( $monitor ) ) { # This will re-init shared memory
|
||||
$monitor->{LastState} = zmGetMonitorState( $monitor );
|
||||
$monitor->{LastEvent} = zmGetLastEvent( $monitor );
|
||||
}
|
||||
}
|
||||
|
||||
sub loadMonitors {
|
||||
Debug( "Loading monitors\n" );
|
||||
Debug( "Loading monitors" );
|
||||
$monitor_reload_time = time();
|
||||
|
||||
my %new_monitors = ();
|
||||
|
@ -323,7 +341,7 @@ sub loadMonitors {
|
|||
my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () )
|
||||
or Fatal( "Can't execute: ".$sth->errstr() );
|
||||
while( my $monitor = $sth->fetchrow_hashref() ) {
|
||||
if ( zmMemVerify( $monitor ) ) {
|
||||
if ( zmMemVerify( $monitor ) ) { # This will re-init shared memory
|
||||
$monitor->{LastState} = zmGetMonitorState( $monitor );
|
||||
$monitor->{LastEvent} = zmGetLastEvent( $monitor );
|
||||
}
|
||||
|
@ -344,14 +362,14 @@ sub handleMessage {
|
|||
|
||||
my $monitor = $monitors{$id};
|
||||
if ( !$monitor ) {
|
||||
Warning( "Can't find monitor '$id' for message '$message'\n" );
|
||||
Warning( "Can't find monitor '$id' for message '$message'" );
|
||||
return;
|
||||
}
|
||||
Debug( "Found monitor for id '$id'\n" );
|
||||
Debug( "Found monitor for id '$id'" );
|
||||
|
||||
next if ( !zmMemVerify( $monitor ) );
|
||||
|
||||
Debug( "Handling action '$action'\n" );
|
||||
Debug( "Handling action '$action'" );
|
||||
if ( $action =~ /^(enable|disable)(?:\+(\d+))?$/ ) {
|
||||
my $state = $1;
|
||||
my $delay = $2;
|
||||
|
@ -362,7 +380,7 @@ sub handleMessage {
|
|||
}
|
||||
# Force a reload
|
||||
$monitor_reload_time = 0;
|
||||
Info( "Set monitor to $state\n" );
|
||||
Info( "Set monitor to $state" );
|
||||
if ( $delay ) {
|
||||
my $action_text = $id.'|'.( ($state eq 'enable')
|
||||
? 'disable'
|
||||
|
@ -379,7 +397,7 @@ sub handleMessage {
|
|||
if ( $trigger eq 'on' ) {
|
||||
zmTriggerEventOn( $monitor, $score, $cause, $text );
|
||||
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
|
||||
Info( "Trigger '$trigger' '$cause'\n" );
|
||||
Info( "Trigger '$trigger' '$cause'" );
|
||||
if ( $delay ) {
|
||||
my $action_text = $id.'|cancel';
|
||||
handleDelay($delay, $connection, $action_text);
|
||||
|
@ -392,7 +410,7 @@ sub handleMessage {
|
|||
my $last_event = zmGetLastEvent( $monitor );
|
||||
zmTriggerEventOff( $monitor );
|
||||
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
|
||||
Info( "Trigger '$trigger'\n" );
|
||||
Info( "Trigger '$trigger'" );
|
||||
# Wait til it's finished
|
||||
while( zmInAlarm( $monitor )
|
||||
&& ($last_event == zmGetLastEvent( $monitor ))
|
||||
|
@ -406,12 +424,12 @@ sub handleMessage {
|
|||
} elsif( $action eq 'cancel' ) {
|
||||
zmTriggerEventCancel( $monitor );
|
||||
zmTriggerShowtext( $monitor, $showtext ) if defined($showtext);
|
||||
Info( "Cancelled event\n" );
|
||||
Info( "Cancelled event" );
|
||||
} elsif( $action eq 'show' ) {
|
||||
zmTriggerShowtext( $monitor, $showtext );
|
||||
Info( "Updated show text to '$showtext'\n" );
|
||||
Info( "Updated show text to '$showtext'" );
|
||||
} else {
|
||||
Error( "Unrecognised action '$action' in message '$message'\n" );
|
||||
Error( "Unrecognised action '$action' in message '$message'" );
|
||||
}
|
||||
} # end sub handleMessage
|
||||
|
||||
|
@ -426,7 +444,7 @@ sub handleDelay {
|
|||
$action_array = $actions{$action_time} = [];
|
||||
}
|
||||
push( @$action_array, { connection=>$connection, message=>$action_text } );
|
||||
Debug( "Added timed event '$action_text', expires at $action_time (+$delay secs)\n" );
|
||||
Debug( "Added timed event '$action_text', expires at $action_time (+$delay secs)" );
|
||||
}
|
||||
1;
|
||||
__END__
|
||||
|
|
|
@ -353,8 +353,8 @@ if ( $version ) {
|
|||
$version = $detaint_version;
|
||||
|
||||
if ( ZM_VERSION eq $version ) {
|
||||
print( "\nDatabase already at version $version, update aborted.\n\n" );
|
||||
exit( 0 );
|
||||
print("\nDatabase already at version $version, update skipped.\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
print( "\nInitiating database upgrade to version ".ZM_VERSION." from version $version\n" );
|
||||
|
|
|
@ -21,7 +21,7 @@ target_link_libraries(zms zm ${ZM_EXTRA_LIBS} ${ZM_BIN_LIBS})
|
|||
|
||||
# Generate man files for the binaries destined for the bin folder
|
||||
FOREACH(CBINARY zma zmc zmu)
|
||||
POD2MAN(${CMAKE_CURRENT_SOURCE_DIR}/${CBINARY}.cpp zoneminder-${CBINARY} 8)
|
||||
POD2MAN(${CMAKE_CURRENT_SOURCE_DIR}/${CBINARY}.cpp zoneminder-${CBINARY} 8 ${ZM_MANPAGE_DEST_PREFIX})
|
||||
ENDFOREACH(CBINARY zma zmc zmu)
|
||||
|
||||
install(TARGETS zmc zma zmu RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
|
|
3
src/zm.h
3
src/zm.h
|
@ -17,9 +17,6 @@
|
|||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
|
||||
#if !defined(PATH_MAX)
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
#ifndef ZM_H
|
||||
#define ZM_H
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef ZM_COMMS_H
|
||||
#define ZM_COMMS_H
|
||||
|
||||
#include "zm_logger.h"
|
||||
#include "zm_exception.h"
|
||||
|
||||
#include <string.h>
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
#ifndef ZM_CONFIG_H
|
||||
#define ZM_CONFIG_H
|
||||
|
||||
#if !defined(PATH_MAX)
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
#include "config.h"
|
||||
#include "zm_config_defines.h"
|
||||
#include "zm.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ Event::Event(
|
|||
alarm_frames = 0;
|
||||
tot_score = 0;
|
||||
max_score = 0;
|
||||
alarm_frame_written = false;
|
||||
|
||||
char id_file[PATH_MAX];
|
||||
|
||||
|
@ -174,7 +175,7 @@ Event::Event(
|
|||
Error("Can't mkdir %s: %s", path, strerror(errno));
|
||||
}
|
||||
} else {
|
||||
path_ptr += snprintf(path, sizeof(path), "/%" PRIu64, id);
|
||||
snprintf(path, sizeof(path), "/%" PRIu64, id);
|
||||
if ( mkdir(path, 0755) ) {
|
||||
if ( errno != EEXIST )
|
||||
Error("Can't mkdir %s: %s", path, strerror(errno));
|
||||
|
@ -527,6 +528,13 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
|
|||
snprintf(snapshot_file, sizeof(snapshot_file), "%s/snapshot.jpg", path);
|
||||
WriteFrameImage(image, timestamp, snapshot_file);
|
||||
}
|
||||
// The first frame with a score will be the frame that alarmed the event
|
||||
if (!alarm_frame_written && score > 0) {
|
||||
alarm_frame_written = true;
|
||||
char alarm_file[PATH_MAX];
|
||||
snprintf(alarm_file, sizeof(alarm_file), "%s/alarm.jpg", path);
|
||||
WriteFrameImage(image, timestamp, alarm_file);
|
||||
}
|
||||
}
|
||||
if ( videowriter != NULL ) {
|
||||
Debug(3, "Writing video");
|
||||
|
|
|
@ -82,6 +82,7 @@ class Event {
|
|||
bool videoEvent;
|
||||
int frames;
|
||||
int alarm_frames;
|
||||
bool alarm_frame_written;
|
||||
unsigned int tot_score;
|
||||
unsigned int max_score;
|
||||
char path[PATH_MAX];
|
||||
|
|
|
@ -755,6 +755,12 @@ void EventStream::runStream() {
|
|||
// commands may set send_frame to true
|
||||
while(checkCommandQueue());
|
||||
|
||||
// Update modified time of the socket .lock file so that we can tell which ones are stale.
|
||||
if ( now.tv_sec - last_comm_update.tv_sec > 3600 ) {
|
||||
touch(sock_path_lock);
|
||||
last_comm_update = now;
|
||||
}
|
||||
|
||||
if ( step != 0 )
|
||||
curr_frame_id += step;
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
#ifndef ZM_EXCEPTION_H
|
||||
#define ZM_EXCEPTION_H
|
||||
|
||||
#include "zm.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class Exception
|
||||
|
|
|
@ -24,14 +24,55 @@
|
|||
|
||||
#if HAVE_LIBAVCODEC || HAVE_LIBAVUTIL || HAVE_LIBSWSCALE
|
||||
|
||||
void log_libav_callback( void *ptr, int level, const char *fmt, va_list vargs ) {
|
||||
Logger *log = Logger::fetch();
|
||||
int log_level = 0;
|
||||
if ( level == AV_LOG_QUIET ) { // -8
|
||||
log_level = Logger::NOLOG;
|
||||
} else if ( level == AV_LOG_PANIC ) { //0
|
||||
log_level = Logger::PANIC;
|
||||
} else if ( level == AV_LOG_FATAL ) { // 8
|
||||
log_level = Logger::FATAL;
|
||||
} else if ( level == AV_LOG_ERROR ) { // 16
|
||||
log_level = Logger::WARNING; // ffmpeg outputs a lot of errors that don't really affect anything.
|
||||
//log_level = Logger::ERROR;
|
||||
} else if ( level == AV_LOG_WARNING ) { //24
|
||||
log_level = Logger::INFO;
|
||||
//log_level = Logger::WARNING;
|
||||
} else if ( level == AV_LOG_INFO ) { //32
|
||||
log_level = Logger::INFO;
|
||||
} else if ( level == AV_LOG_VERBOSE ) { //40
|
||||
log_level = Logger::DEBUG1;
|
||||
} else if ( level == AV_LOG_DEBUG ) { //48
|
||||
log_level = Logger::DEBUG2;
|
||||
#ifdef AV_LOG_TRACE
|
||||
} else if ( level == AV_LOG_TRACE ) {
|
||||
log_level = Logger::DEBUG8;
|
||||
#endif
|
||||
#ifdef AV_LOG_MAX_OFFSET
|
||||
} else if ( level == AV_LOG_MAX_OFFSET ) {
|
||||
log_level = Logger::DEBUG9;
|
||||
#endif
|
||||
} else {
|
||||
Error("Unknown log level %d", level);
|
||||
}
|
||||
|
||||
if ( log ) {
|
||||
char logString[8192];
|
||||
vsnprintf(logString, sizeof(logString)-1, fmt, vargs);
|
||||
log->logPrint(false, __FILE__, __LINE__, log_level, logString);
|
||||
}
|
||||
}
|
||||
|
||||
void FFMPEGInit() {
|
||||
static bool bInit = false;
|
||||
|
||||
if ( !bInit ) {
|
||||
//if ( logDebugging() )
|
||||
//av_log_set_level( AV_LOG_DEBUG );
|
||||
//else
|
||||
if ( logDebugging() )
|
||||
av_log_set_level( AV_LOG_DEBUG );
|
||||
else
|
||||
av_log_set_level( AV_LOG_QUIET );
|
||||
av_log_set_callback(log_libav_callback);
|
||||
av_register_all();
|
||||
avformat_network_init();
|
||||
bInit = true;
|
||||
|
|
849
src/zm_image.cpp
849
src/zm_image.cpp
File diff suppressed because it is too large
Load Diff
|
@ -274,6 +274,7 @@ void std_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result,
|
|||
void std_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||
void std_delta8_argb(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||
void std_delta8_abgr(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||
|
||||
void neon32_armv7_delta8_gray8(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||
void neon32_armv7_delta8_rgba(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||
void neon32_armv7_delta8_bgra(const uint8_t* col1, const uint8_t* col2, uint8_t* result, unsigned long count);
|
||||
|
|
|
@ -444,6 +444,7 @@ void Logger::closeSyslog() {
|
|||
void Logger::logPrint( bool hex, const char * const filepath, const int line, const int level, const char *fstring, ... ) {
|
||||
if ( level > mEffectiveLevel )
|
||||
return;
|
||||
log_mutex.lock();
|
||||
char timeString[64];
|
||||
char logString[8192];
|
||||
va_list argPtr;
|
||||
|
@ -579,8 +580,10 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
|
|||
abort();
|
||||
exit(-1);
|
||||
}
|
||||
log_mutex.unlock();
|
||||
}
|
||||
|
||||
|
||||
void logInit(const char *name, const Logger::Options &options) {
|
||||
if ( !Logger::smInstance )
|
||||
Logger::smInstance = new Logger();
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#endif // HAVE_SYS_SYSCALL_H
|
||||
#include <mysql/mysql.h>
|
||||
|
||||
#include "zm_thread.h"
|
||||
|
||||
class Logger {
|
||||
public:
|
||||
enum {
|
||||
|
@ -82,6 +84,8 @@ private:
|
|||
static bool smInitialised;
|
||||
static Logger *smInstance;
|
||||
|
||||
RecursiveMutex log_mutex;
|
||||
|
||||
static StringMap smCodes;
|
||||
static IntMap smSyslogPriorities;
|
||||
|
||||
|
|
|
@ -749,7 +749,7 @@ void Monitor::AddPrivacyBitmask( Zone *p_zones[] ) {
|
|||
}
|
||||
|
||||
Monitor::State Monitor::GetState() const {
|
||||
return( (State)shared_data->state );
|
||||
return (State)shared_data->state;
|
||||
}
|
||||
|
||||
int Monitor::GetImage( int index, int scale ) {
|
||||
|
@ -2110,6 +2110,7 @@ Monitor *Monitor::Load(MYSQL_ROW dbrow, bool load_zones, Purpose purpose) {
|
|||
Camera *camera = 0;
|
||||
if ( type == "Local" ) {
|
||||
|
||||
#if ZM_HAS_V4L
|
||||
int extras = (deinterlacing>>24)&0xff;
|
||||
|
||||
camera = new LocalCamera(
|
||||
|
@ -2132,6 +2133,9 @@ Monitor *Monitor::Load(MYSQL_ROW dbrow, bool load_zones, Purpose purpose) {
|
|||
record_audio,
|
||||
extras
|
||||
);
|
||||
#else
|
||||
Fatal("ZoneMinder not built with Local Camera support");
|
||||
#endif
|
||||
} else if ( type == "Remote" ) {
|
||||
if ( protocol == "http" ) {
|
||||
camera = new RemoteCameraHttp(
|
||||
|
|
|
@ -127,24 +127,25 @@ protected:
|
|||
uint8_t format; /* +55 */
|
||||
uint32_t imagesize; /* +56 */
|
||||
uint32_t epadding1; /* +60 */
|
||||
uint32_t epadding2; /* +64 */
|
||||
/*
|
||||
** This keeps 32bit time_t and 64bit time_t identical and compatible as long as time is before 2038.
|
||||
** Shared memory layout should be identical for both 32bit and 64bit and is multiples of 16.
|
||||
** Because startup_time is 64bit it may be aligned to a 64bit boundary. So it's offset SHOULD be a multiple
|
||||
** of 8. Add or delete epadding's to achieve this.
|
||||
*/
|
||||
union { /* +68 */
|
||||
union { /* +64 */
|
||||
time_t startup_time; /* When the zmc process started. zmwatch uses this to see how long the process has been running without getting any images */
|
||||
uint64_t extrapad1;
|
||||
};
|
||||
union { /* +76 */
|
||||
union { /* +72 */
|
||||
time_t last_write_time;
|
||||
uint64_t extrapad2;
|
||||
};
|
||||
union { /* +84 */
|
||||
union { /* +80 */
|
||||
time_t last_read_time;
|
||||
uint64_t extrapad3;
|
||||
};
|
||||
uint8_t control_state[256]; /* +92 */
|
||||
uint8_t control_state[256]; /* +88 */
|
||||
|
||||
char alarm_cause[256];
|
||||
|
||||
|
|
|
@ -531,6 +531,12 @@ void MonitorStream::runStream() {
|
|||
Debug(2, "Have checking command Queue for connkey: %d", connkey );
|
||||
got_command = true;
|
||||
}
|
||||
// Update modified time of the socket .lock file so that we can tell which ones are stale.
|
||||
if ( now.tv_sec - last_comm_update.tv_sec > 3600 ) {
|
||||
touch(sock_path_lock);
|
||||
last_comm_update = now;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( paused ) {
|
||||
|
|
|
@ -388,7 +388,7 @@ int RtspThread::run() {
|
|||
std::string trackUrl = mUrl;
|
||||
std::string controlUrl;
|
||||
|
||||
_AVCODECID codecId;
|
||||
_AVCODECID codecId = AV_CODEC_ID_NONE;
|
||||
|
||||
if ( mFormatContext->nb_streams >= 1 ) {
|
||||
for ( unsigned int i = 0; i < mFormatContext->nb_streams; i++ ) {
|
||||
|
|
|
@ -325,13 +325,15 @@ void StreamBase::openComms() {
|
|||
strncpy(loc_addr.sun_path, loc_sock_path, sizeof(loc_addr.sun_path));
|
||||
loc_addr.sun_family = AF_UNIX;
|
||||
Debug(3, "Binding to %s", loc_sock_path);
|
||||
if ( bind(sd, (struct sockaddr *)&loc_addr, strlen(loc_addr.sun_path)+sizeof(loc_addr.sun_family)+1) < 0 ) {
|
||||
if ( ::bind(sd, (struct sockaddr *)&loc_addr, strlen(loc_addr.sun_path)+sizeof(loc_addr.sun_family)+1) < 0 ) {
|
||||
Fatal("Can't bind: %s", strerror(errno));
|
||||
}
|
||||
|
||||
snprintf(rem_sock_path, sizeof(rem_sock_path), "%s/zms-%06dw.sock", staticConfig.PATH_SOCKS.c_str(), connkey);
|
||||
strncpy(rem_addr.sun_path, rem_sock_path, sizeof(rem_addr.sun_path)-1);
|
||||
rem_addr.sun_family = AF_UNIX;
|
||||
|
||||
gettimeofday(&last_comm_update, NULL);
|
||||
} // end if connKey > 0
|
||||
Debug(2, "comms open");
|
||||
} // end void StreamBase::openComms()
|
||||
|
|
|
@ -85,6 +85,7 @@ protected:
|
|||
int step;
|
||||
|
||||
struct timeval now;
|
||||
struct timeval last_comm_update;
|
||||
|
||||
double base_fps;
|
||||
double effective_fps;
|
||||
|
|
|
@ -20,9 +20,12 @@
|
|||
#ifndef ZM_THREAD_H
|
||||
#define ZM_THREAD_H
|
||||
|
||||
class RecursiveMutex;
|
||||
|
||||
|
||||
#include "zm_config.h"
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_SYS_SYSCALL_H
|
||||
#include <sys/syscall.h>
|
||||
#endif // HAVE_SYS_SYSCALL_H
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <fcntl.h> /* Definition of AT_* constants */
|
||||
#include <sys/stat.h>
|
||||
#if defined(__arm__)
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
|
@ -414,3 +416,22 @@ Warning("ZM Compiled without LIBCURL. UriDecoding not implemented.");
|
|||
#endif
|
||||
}
|
||||
|
||||
void touch(const char *pathname) {
|
||||
int fd = open(pathname,
|
||||
O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK,
|
||||
0666);
|
||||
if ( fd < 0 ) {
|
||||
// Couldn't open that path.
|
||||
Error("Couldn't open() path \"%s in touch", pathname);
|
||||
return;
|
||||
}
|
||||
int rc = utimensat(AT_FDCWD,
|
||||
pathname,
|
||||
nullptr,
|
||||
0);
|
||||
if ( rc ) {
|
||||
Error("Couldn't utimensat() path %s in touch", pathname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,5 +63,5 @@ extern unsigned int neonversion;
|
|||
|
||||
char *timeval_to_string( struct timeval tv );
|
||||
std::string UriDecode( const std::string &encoded );
|
||||
|
||||
void touch( const char *pathname );
|
||||
#endif // ZM_UTILS_H
|
||||
|
|
|
@ -238,7 +238,7 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
avformat_new_stream(oc, (AVCodec *)audio_in_ctx->codec);
|
||||
#endif
|
||||
if ( !audio_out_stream ) {
|
||||
Error("Unable to create audio out stream\n");
|
||||
Error("Unable to create audio out stream");
|
||||
audio_out_stream = NULL;
|
||||
} else {
|
||||
Debug(2, "setting parameters");
|
||||
|
@ -248,35 +248,34 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
// Copy params from instream to ctx
|
||||
ret = avcodec_parameters_to_context(audio_out_ctx,
|
||||
audio_in_stream->codecpar);
|
||||
if (ret < 0) {
|
||||
Error("Unable to copy audio params to ctx %s\n",
|
||||
if ( ret < 0 ) {
|
||||
Error("Unable to copy audio params to ctx %s",
|
||||
av_make_error_string(ret).c_str());
|
||||
}
|
||||
ret = avcodec_parameters_from_context(audio_out_stream->codecpar,
|
||||
audio_out_ctx);
|
||||
if (ret < 0) {
|
||||
Error("Unable to copy audio params to stream %s\n",
|
||||
if ( ret < 0 ) {
|
||||
Error("Unable to copy audio params to stream %s",
|
||||
av_make_error_string(ret).c_str());
|
||||
}
|
||||
|
||||
if (!audio_out_ctx->codec_tag) {
|
||||
if ( !audio_out_ctx->codec_tag ) {
|
||||
audio_out_ctx->codec_tag = av_codec_get_tag(
|
||||
oc->oformat->codec_tag, audio_in_ctx->codec_id);
|
||||
Debug(2, "Setting audio codec tag to %d",
|
||||
audio_out_ctx->codec_tag);
|
||||
}
|
||||
|
||||
#else
|
||||
audio_out_ctx = audio_out_stream->codec;
|
||||
ret = avcodec_copy_context(audio_out_ctx, audio_in_ctx);
|
||||
audio_out_ctx->codec_tag = 0;
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
Error("Unable to copy audio ctx %s\n",
|
||||
if ( ret < 0 ) {
|
||||
Error("Unable to copy audio ctx %s",
|
||||
av_make_error_string(ret).c_str());
|
||||
audio_out_stream = NULL;
|
||||
} else {
|
||||
if (audio_out_ctx->channels > 1) {
|
||||
if ( audio_out_ctx->channels > 1 ) {
|
||||
Warning("Audio isn't mono, changing it.");
|
||||
audio_out_ctx->channels = 1;
|
||||
} else {
|
||||
|
@ -286,8 +285,8 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
} // end if audio_out_stream
|
||||
} // end if is AAC
|
||||
|
||||
if (audio_out_stream) {
|
||||
if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
|
||||
if ( audio_out_stream ) {
|
||||
if ( oc->oformat->flags & AVFMT_GLOBALHEADER ) {
|
||||
#if LIBAVCODEC_VERSION_CHECK(56, 35, 0, 64, 0)
|
||||
audio_out_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
#else
|
||||
|
@ -297,7 +296,6 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
}
|
||||
} // end if audio_in_stream
|
||||
|
||||
|
||||
video_last_pts = 0;
|
||||
video_last_dts = 0;
|
||||
audio_last_pts = 0;
|
||||
|
@ -310,12 +308,11 @@ VideoStore::VideoStore(const char *filename_in, const char *format_in,
|
|||
|
||||
bool VideoStore::open() {
|
||||
/* open the out file, if needed */
|
||||
if (!(out_format->flags & AVFMT_NOFILE)) {
|
||||
if ( !(out_format->flags & AVFMT_NOFILE) ) {
|
||||
ret = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
if ( ret < 0 ) {
|
||||
Error("Could not open out file '%s': %s\n", filename,
|
||||
av_make_error_string(ret).c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -339,9 +336,9 @@ bool VideoStore::open() {
|
|||
} else if (av_dict_count(opts) != 0) {
|
||||
Warning("some options not set\n");
|
||||
}
|
||||
if (opts) av_dict_free(&opts);
|
||||
if (ret < 0) {
|
||||
Error("Error occurred when writing out file header to %s: %s\n",
|
||||
if ( opts ) av_dict_free(&opts);
|
||||
if ( ret < 0 ) {
|
||||
Error("Error occurred when writing out file header to %s: %s",
|
||||
filename, av_make_error_string(ret).c_str());
|
||||
/* free the stream */
|
||||
avio_closep(&oc->pb);
|
||||
|
@ -506,13 +503,13 @@ bool VideoStore::setup_resampler() {
|
|||
avcodec_find_decoder(audio_in_ctx->codec_id);
|
||||
#endif
|
||||
ret = avcodec_open2(audio_in_ctx, audio_in_codec, NULL);
|
||||
if (ret < 0) {
|
||||
if ( ret < 0 ) {
|
||||
Error("Can't open in codec!");
|
||||
return false;
|
||||
}
|
||||
|
||||
audio_out_codec = avcodec_find_encoder(AV_CODEC_ID_AAC);
|
||||
if (!audio_out_codec) {
|
||||
if ( !audio_out_codec ) {
|
||||
Error("Could not find codec for AAC");
|
||||
return false;
|
||||
}
|
||||
|
@ -521,16 +518,15 @@ bool VideoStore::setup_resampler() {
|
|||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
// audio_out_ctx = audio_out_stream->codec;
|
||||
audio_out_ctx = avcodec_alloc_context3(audio_out_codec);
|
||||
|
||||
if (!audio_out_ctx) {
|
||||
Error("could not allocate codec ctx for AAC\n");
|
||||
if ( !audio_out_ctx ) {
|
||||
Error("could not allocate codec ctx for AAC");
|
||||
audio_out_stream = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug(2, "Have audio_out_ctx");
|
||||
// Now copy them to the out stream
|
||||
audio_out_stream = avformat_new_stream(oc, NULL);
|
||||
audio_out_stream = avformat_new_stream(oc, audio_out_codec);
|
||||
#else
|
||||
audio_out_stream = avformat_new_stream(oc, NULL);
|
||||
audio_out_ctx = audio_out_stream->codec;
|
||||
|
@ -546,29 +542,35 @@ bool VideoStore::setup_resampler() {
|
|||
#else
|
||||
audio_out_ctx->refcounted_frames = 1;
|
||||
#endif
|
||||
if ( ! audio_out_ctx->channel_layout ) {
|
||||
Debug(3, "Correcting channel layout from (%d) to (%d)",
|
||||
audio_out_ctx->channel_layout,
|
||||
av_get_default_channel_layout(audio_out_ctx->channels)
|
||||
);
|
||||
audio_out_ctx->channel_layout = av_get_default_channel_layout(audio_out_ctx->channels);
|
||||
}
|
||||
|
||||
if (audio_out_codec->supported_samplerates) {
|
||||
if ( audio_out_codec->supported_samplerates ) {
|
||||
int found = 0;
|
||||
for (unsigned int i = 0; audio_out_codec->supported_samplerates[i];
|
||||
i++) {
|
||||
if (audio_out_ctx->sample_rate ==
|
||||
audio_out_codec->supported_samplerates[i]) {
|
||||
for ( unsigned int i = 0; audio_out_codec->supported_samplerates[i]; i++) {
|
||||
if ( audio_out_ctx->sample_rate ==
|
||||
audio_out_codec->supported_samplerates[i] ) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if ( found ) {
|
||||
Debug(3, "Sample rate is good");
|
||||
} else {
|
||||
audio_out_ctx->sample_rate =
|
||||
audio_out_codec->supported_samplerates[0];
|
||||
Debug(1, "Sampel rate is no good, setting to (%d)",
|
||||
Debug(1, "Sample rate is no good, setting to (%d)",
|
||||
audio_out_codec->supported_samplerates[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/* check that the encoder supports s16 pcm in */
|
||||
if (!check_sample_fmt(audio_out_codec, audio_out_ctx->sample_fmt)) {
|
||||
if ( !check_sample_fmt(audio_out_codec, audio_out_ctx->sample_fmt) ) {
|
||||
Debug(3, "Encoder does not support sample format %s, setting to FLTP",
|
||||
av_get_sample_fmt_name(audio_out_ctx->sample_fmt));
|
||||
audio_out_ctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
||||
|
@ -577,16 +579,6 @@ bool VideoStore::setup_resampler() {
|
|||
audio_out_ctx->time_base =
|
||||
(AVRational){1, audio_out_ctx->sample_rate};
|
||||
|
||||
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
ret = avcodec_parameters_from_context(audio_out_stream->codecpar,
|
||||
audio_out_ctx);
|
||||
if (ret < 0) {
|
||||
Error("Could not initialize stream parameteres");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
AVDictionary *opts = NULL;
|
||||
if ( (ret = av_dict_set(&opts, "strict", "experimental", 0)) < 0 ) {
|
||||
Error("Couldn't set experimental");
|
||||
|
@ -601,6 +593,15 @@ bool VideoStore::setup_resampler() {
|
|||
return false;
|
||||
}
|
||||
|
||||
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
|
||||
ret = avcodec_parameters_from_context(
|
||||
audio_out_stream->codecpar, audio_out_ctx);
|
||||
if ( ret < 0 ) {
|
||||
Error("Could not initialize stream parameteres");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
Debug(1,
|
||||
"Audio out bit_rate (%d) sample_rate(%d) channels(%d) fmt(%d) "
|
||||
"layout(%d) frame_size(%d)",
|
||||
|
@ -609,13 +610,13 @@ bool VideoStore::setup_resampler() {
|
|||
audio_out_ctx->channel_layout, audio_out_ctx->frame_size);
|
||||
|
||||
/** Create a new frame to store the audio samples. */
|
||||
if (!(in_frame = zm_av_frame_alloc())) {
|
||||
if ( !(in_frame = zm_av_frame_alloc()) ) {
|
||||
Error("Could not allocate in frame");
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Create a new frame to store the audio samples. */
|
||||
if (!(out_frame = zm_av_frame_alloc())) {
|
||||
if ( !(out_frame = zm_av_frame_alloc()) ) {
|
||||
Error("Could not allocate out frame");
|
||||
av_frame_free(&in_frame);
|
||||
return false;
|
||||
|
@ -623,20 +624,20 @@ bool VideoStore::setup_resampler() {
|
|||
|
||||
// Setup the audio resampler
|
||||
resample_ctx = avresample_alloc_context();
|
||||
if (!resample_ctx) {
|
||||
Error("Could not allocate resample ctx\n");
|
||||
if ( !resample_ctx ) {
|
||||
Error("Could not allocate resample ctx");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Some formats (i.e. WAV) do not produce the proper channel layout
|
||||
if (audio_in_ctx->channel_layout == 0) {
|
||||
uint64_t layout = av_get_channel_layout("mono");
|
||||
av_opt_set_int(resample_ctx, "in_channel_layout",
|
||||
av_get_channel_layout("mono"), 0);
|
||||
Debug(1, "Bad channel layout. Need to set it to mono (%d).", layout);
|
||||
uint64_t layout = av_get_channel_layout("mono");
|
||||
if ( audio_in_ctx->channel_layout == 0 ) {
|
||||
av_opt_set_int(resample_ctx, "in_channel_layout", layout, 0);
|
||||
Debug(1, "Bad in channel layout. Need to set it to mono (%d).", layout);
|
||||
} else {
|
||||
av_opt_set_int(resample_ctx, "in_channel_layout",
|
||||
audio_in_ctx->channel_layout, 0);
|
||||
layout = audio_in_ctx->channel_layout;
|
||||
}
|
||||
|
||||
av_opt_set_int(resample_ctx, "in_sample_fmt",
|
||||
|
@ -648,7 +649,7 @@ bool VideoStore::setup_resampler() {
|
|||
// av_opt_set_int( resample_ctx, "out_channel_layout",
|
||||
// audio_out_ctx->channel_layout, 0);
|
||||
av_opt_set_int(resample_ctx, "out_channel_layout",
|
||||
av_get_channel_layout("mono"), 0);
|
||||
layout, 0);
|
||||
av_opt_set_int(resample_ctx, "out_sample_fmt",
|
||||
audio_out_ctx->sample_fmt, 0);
|
||||
av_opt_set_int(resample_ctx, "out_sample_rate",
|
||||
|
@ -657,38 +658,13 @@ bool VideoStore::setup_resampler() {
|
|||
audio_out_ctx->channels, 0);
|
||||
|
||||
ret = avresample_open(resample_ctx);
|
||||
if (ret < 0) {
|
||||
Error("Could not open resample ctx\n");
|
||||
if ( ret < 0 ) {
|
||||
Error("Could not open resample ctx");
|
||||
return false;
|
||||
} else {
|
||||
Debug(2, "Success opening resampler");
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Allocate as many pointers as there are audio channels.
|
||||
* Each pointer will later point to the audio samples of the corresponding
|
||||
* channels (although it may be NULL for interleaved formats).
|
||||
*/
|
||||
if (!( converted_in_samples = reinterpret_cast<uint8_t *>calloc( audio_out_ctx->channels, sizeof(*converted_in_samples))) ) {
|
||||
Error("Could not allocate converted in sample pointers\n");
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Allocate memory for the samples of all channels in one consecutive
|
||||
* block for convenience.
|
||||
*/
|
||||
if ( (ret = av_samples_alloc( &converted_in_samples, NULL,
|
||||
audio_out_ctx->channels,
|
||||
audio_out_ctx->frame_size,
|
||||
audio_out_ctx->sample_fmt, 0)) < 0 ) {
|
||||
Error("Could not allocate converted in samples (error '%s')\n",
|
||||
av_make_error_string(ret).c_str());
|
||||
|
||||
av_freep(converted_in_samples);
|
||||
free(converted_in_samples);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
out_frame->nb_samples = audio_out_ctx->frame_size;
|
||||
out_frame->format = audio_out_ctx->sample_fmt;
|
||||
out_frame->channel_layout = audio_out_ctx->channel_layout;
|
||||
|
@ -696,21 +672,24 @@ bool VideoStore::setup_resampler() {
|
|||
// The codec gives us the frame size, in samples, we calculate the size of the
|
||||
// samples buffer in bytes
|
||||
unsigned int audioSampleBuffer_size = av_samples_get_buffer_size(
|
||||
NULL, audio_out_ctx->channels, audio_out_ctx->frame_size,
|
||||
NULL, audio_out_ctx->channels,
|
||||
audio_out_ctx->frame_size,
|
||||
audio_out_ctx->sample_fmt, 0);
|
||||
converted_in_samples = (uint8_t *)av_malloc(audioSampleBuffer_size);
|
||||
|
||||
if (!converted_in_samples) {
|
||||
Error("Could not allocate converted in sample pointers\n");
|
||||
if ( !converted_in_samples ) {
|
||||
Error("Could not allocate converted in sample pointers");
|
||||
return false;
|
||||
} else {
|
||||
Debug(2, "Frame Size %d, sample buffer size %d", audio_out_ctx->frame_size, audioSampleBuffer_size);
|
||||
}
|
||||
|
||||
// Setup the data pointers in the AVFrame
|
||||
if (avcodec_fill_audio_frame(out_frame, audio_out_ctx->channels,
|
||||
if ( avcodec_fill_audio_frame(out_frame, audio_out_ctx->channels,
|
||||
audio_out_ctx->sample_fmt,
|
||||
(const uint8_t *)converted_in_samples,
|
||||
audioSampleBuffer_size, 0) < 0) {
|
||||
Error("Could not allocate converted in sample pointers\n");
|
||||
Error("Could not allocate converted in sample pointers");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
13
src/zmu.cpp
13
src/zmu.cpp
|
@ -463,10 +463,10 @@ int main(int argc, char *argv[]) {
|
|||
} // end if auth
|
||||
|
||||
if ( mon_id > 0 ) {
|
||||
fprintf(stderr,"Monitor %d\n", mon_id);
|
||||
//fprintf(stderr,"Monitor %d\n", mon_id);
|
||||
Monitor *monitor = Monitor::Load(mon_id, function&(ZMU_QUERY|ZMU_ZONES), Monitor::QUERY);
|
||||
if ( monitor ) {
|
||||
fprintf(stderr,"Monitor %d(%s)\n", monitor->Id(), monitor->Name());
|
||||
//fprintf(stderr,"Monitor %d(%s)\n", monitor->Id(), monitor->Name());
|
||||
if ( verbose ) {
|
||||
printf("Monitor %d(%s)\n", monitor->Id(), monitor->Name());
|
||||
}
|
||||
|
@ -479,9 +479,9 @@ int main(int argc, char *argv[]) {
|
|||
bool have_output = false;
|
||||
if ( function & ZMU_STATE ) {
|
||||
Monitor::State state = monitor->GetState();
|
||||
if ( verbose )
|
||||
if ( verbose ) {
|
||||
printf("Current state: %s\n", state==Monitor::ALARM?"Alarm":(state==Monitor::ALERT?"Alert":"Idle"));
|
||||
else {
|
||||
} else {
|
||||
if ( have_output ) printf("%c", separator);
|
||||
printf("%d", state);
|
||||
have_output = true;
|
||||
|
@ -560,6 +560,11 @@ int main(int argc, char *argv[]) {
|
|||
if ( verbose )
|
||||
printf( "Forcing alarm on\n" );
|
||||
monitor->ForceAlarmOn( config.forced_alarm_score, "Forced Web" );
|
||||
while ( monitor->GetState() != Monitor::ALARM ) {
|
||||
// Wait for monitor to notice.
|
||||
usleep(1000);
|
||||
}
|
||||
printf( "Alarmed event id: %" PRIu64 "\n", monitor->GetLastEventId() );
|
||||
}
|
||||
if ( function & ZMU_NOALARM ) {
|
||||
if ( verbose )
|
||||
|
|
|
@ -76,7 +76,7 @@ fi;
|
|||
|
||||
if [ "$DISTROS" == "" ]; then
|
||||
if [ "$RELEASE" != "" ]; then
|
||||
DISTROS="xenial,bionic,trusty"
|
||||
DISTROS="xenial,bionic,cosmic,disco,trusty"
|
||||
else
|
||||
DISTROS=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`;
|
||||
fi;
|
||||
|
|
|
@ -164,14 +164,23 @@ switch ( $_REQUEST['task'] ) {
|
|||
$where = array();
|
||||
$values = array();
|
||||
if ( $minTime ) {
|
||||
preg_match('/(.+)(\.\d+)/', $minTime, $matches);
|
||||
$minTime = strtotime($matches[1]).$matches[2];
|
||||
Logger::Debug("MinTime: $minTime");
|
||||
if ( preg_match('/(.+)(\.\d+)/', $minTime, $matches) ) {
|
||||
# This handles sub second precision
|
||||
$minTime = strtotime($matches[1]).$matches[2];
|
||||
Logger::Debug("MinTime: $minTime");
|
||||
} else {
|
||||
$minTime = strtotime($minTime);
|
||||
}
|
||||
$where[] = 'TimeKey >= ?';
|
||||
$values[] = $minTime;
|
||||
}
|
||||
if ( $maxTime ) {
|
||||
preg_match('/(.+)(\.\d+)/', $maxTime, $matches);
|
||||
$maxTime = strtotime($matches[1]).$matches[2];
|
||||
if ( preg_match('/(.+)(\.\d+)/', $maxTime, $matches) ) {
|
||||
$maxTime = strtotime($matches[1]).$matches[2];
|
||||
} else {
|
||||
$maxTime = strtotime($maxTime);
|
||||
}
|
||||
$where[] = 'TimeKey <= ?';
|
||||
$values[] = $maxTime;
|
||||
}
|
||||
|
@ -209,8 +218,15 @@ switch ( $_REQUEST['task'] ) {
|
|||
}
|
||||
$exportKey = substr(md5(rand()),0,8);
|
||||
$exportFile = "zm-log.$exportExt";
|
||||
$exportPath = ZM_PATH_SWAP."/zm-log-$exportKey.$exportExt";
|
||||
if ( !($exportFP = fopen( $exportPath, "w" )) )
|
||||
if ( ! file_exists(ZM_DIR_EXPORTS) ) {
|
||||
Logger::Debug('Creating ' . ZM_DIR_EXPORTS);
|
||||
if ( ! mkdir(ZM_DIR_EXPORTS) ) {
|
||||
Fatal("Can't create exports dir at '".ZM_DIR_EXPORTS."'");
|
||||
}
|
||||
}
|
||||
$exportPath = ZM_DIR_EXPORTS."/zm-log-$exportKey.$exportExt";
|
||||
Logger::Debug("Exporting to $exportPath");
|
||||
if ( !($exportFP = fopen($exportPath, 'w')) )
|
||||
Fatal("Unable to open log export file $exportPath");
|
||||
$logs = array();
|
||||
foreach ( dbFetchAll($sql, NULL, $values) as $log ) {
|
||||
|
@ -218,6 +234,8 @@ switch ( $_REQUEST['task'] ) {
|
|||
$log['Server'] = ( $log['ServerId'] and isset($servers_by_Id[$log['ServerId']]) ) ? $servers_by_Id[$log['ServerId']]->Name() : '';
|
||||
$logs[] = $log;
|
||||
}
|
||||
Logger::Debug(count($logs)." lines being exported by $sql " . implode(',',$values));
|
||||
|
||||
switch( $format ) {
|
||||
case 'text' :
|
||||
{
|
||||
|
@ -390,7 +408,7 @@ switch ( $_REQUEST['task'] ) {
|
|||
}
|
||||
|
||||
$exportFile = "zm-log.$exportExt";
|
||||
$exportPath = ZM_PATH_SWAP."/zm-log-$exportKey.$exportExt";
|
||||
$exportPath = ZM_DIR_EXPORTS."/zm-log-$exportKey.$exportExt";
|
||||
|
||||
header('Pragma: public');
|
||||
header('Expires: 0');
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
*/
|
||||
Configure::write('Error', array(
|
||||
'handler' => 'ErrorHandler::handleError',
|
||||
'level' => E_ALL & ~E_DEPRECATED,
|
||||
'level' => E_ALL & ~E_DEPRECATED & ~E_NOTICE,
|
||||
'trace' => true
|
||||
));
|
||||
|
||||
|
|
|
@ -65,18 +65,17 @@ class HostController extends AppController {
|
|||
$isZmAuth = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_OPT_USE_AUTH')))['Config']['Value'];
|
||||
|
||||
if ( $isZmAuth ) {
|
||||
// In future, we may want to completely move to AUTH_HASH_LOGINS and return &auth= for all cases
|
||||
require_once "../../../includes/auth.php"; # in the event we directly call getCredentials.json
|
||||
$this->Session->read('user'); # this is needed for command line/curl to recognize a session
|
||||
$zmAuthRelay = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_RELAY')))['Config']['Value'];
|
||||
if ( $zmAuthRelay == 'hashed' ) {
|
||||
$zmAuthHashIps= $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value'];
|
||||
$zmAuthHashIps = $this->Config->find('first',array('conditions' => array('Config.' . $this->Config->primaryKey => 'ZM_AUTH_HASH_IPS')))['Config']['Value'];
|
||||
$credentials = 'auth='.generateAuthHash($zmAuthHashIps);
|
||||
} else if ( $zmAuthRelay == 'plain' ) {
|
||||
} else {
|
||||
// user will need to append the store password here
|
||||
$credentials = 'user='.$this->Session->read('user.Username').'&pass=';
|
||||
$appendPassword = 1;
|
||||
} else if ( $zmAuthRelay == 'none' ) {
|
||||
$credentials = 'user='.$this->Session->read('user.Username');
|
||||
}
|
||||
}
|
||||
return array($credentials, $appendPassword);
|
||||
|
|
|
@ -207,8 +207,10 @@ class MonitorsController extends AppController {
|
|||
if ( !$this->Monitor->exists() ) {
|
||||
throw new NotFoundException(__('Invalid monitor'));
|
||||
}
|
||||
if ( $this->Session->Read('systemPermission') != 'Edit' ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
|
|
|
@ -59,8 +59,9 @@ public function add() {
|
|||
|
||||
if ($this->request->is('post')) {
|
||||
|
||||
if ($this->Session->Read('systemPermission') != 'Edit')
|
||||
{
|
||||
global $user;
|
||||
$canEdit = (!$user) || ($user['System'] == 'Edit');
|
||||
if ( !$canEdit ) {
|
||||
throw new UnauthorizedException(__('Insufficient privileges'));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class StorageController extends AppController {
|
|||
* @return void
|
||||
*/
|
||||
public function index() {
|
||||
$this->Storage->recursive = 0;
|
||||
$this->Storage->recursive = -1;
|
||||
|
||||
$options = '';
|
||||
$storage_areas = $this->Storage->find('all',$options);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue