{"id":123,"date":"2014-12-30T10:11:13","date_gmt":"2014-12-30T10:11:13","guid":{"rendered":"http:\/\/iain.rauch.co.uk\/blog\/?p=123"},"modified":"2014-12-30T10:19:26","modified_gmt":"2014-12-30T10:19:26","slug":"zoneminder-1-28-api","status":"publish","type":"post","link":"https:\/\/iain.rauch.co.uk\/blog\/2014-12\/zoneminder-1-28-api\/","title":{"rendered":"ZoneMinder 1.28 API"},"content":{"rendered":"<p>Over the holidays, I rebuild my CCTV server. Rather than trying to reuse the\u00a0installation from the previous disk, I thought it&#8217;d be easier just to install everything fresh. Hence, I followed the instructions on the <a href=\"http:\/\/www.zoneminder.com\/wiki\/index.php\/Ubuntu_Server_14.10_64-bit_server_with_Zoneminder_to_use_systemd\" target=\"_blank\">ZoneMinder Wiki<\/a>.<\/p>\n<p>Following on from this rebuild, I was tidying up my custom viewers which had hard-coded monitor IDs. Of course the correct way to do this would be via an API. Is there an API in ZoneMinder? Well according to the &#8220;latest&#8221; <a href=\"http:\/\/zoneminder.readthedocs.org\/en\/latest\/api.html\" target=\"_blank\">docs<\/a>, it should be included since 1.27.<\/p>\n<p>[code lang=&#8221;bash&#8221;]curl http:\/\/wiggum\/zm\/api\/monitors.json<br \/>\n&#8230;404 Not Found&#8230;[\/code]<\/p>\n<p>So I checked if it was actually there or not:<\/p>\n<p>[code lang=&#8221;bash&#8221;]iain@wiggum:~$ ls \/usr\/share\/zoneminder\/<br \/>\najax\u00a0 cgi-bin\u00a0 css\u00a0 db\u00a0 events\u00a0 graphics\u00a0 images\u00a0 includes\u00a0 index.php\u00a0 js\u00a0 lang\u00a0 skins\u00a0 sounds\u00a0 temp\u00a0 tools\u00a0 views[\/code]<\/p>\n<p>Nope.<\/p>\n<p>Not sure why it&#8217;s not there, you can see it on <a href=\"https:\/\/github.com\/ZoneMinder\/ZoneMinder\/tree\/release-1.28\/web\/api\" target=\"_blank\">GitHub<\/a>, but here&#8217;s how I solved it until the package is updated properly. (I&#8217;m omitting the use of sudo where needed.)<\/p>\n<p>[code lang=&#8221;bash&#8221;]cd \/usr\/src<br \/>\ngit clone https:\/\/github.com\/ZoneMinder\/ZoneMinder.git &#8211;branch release-1.28 zoneminder-1.28<br \/>\nmkdir\u00a0zoneminder-1.28\/web\/api\/app\/tmp<br \/>\nchown www-data:www-data\u00a0zoneminder-1.28\/web\/api\/app\/tmp[\/code]<\/p>\n<p>[code lang=&#8221;bash&#8221;]vi zoneminder-1.28\/web\/api\/.htaccess[\/code]<br \/>\nAdd: <code>RewriteBase \/zm\/api<\/code><\/p>\n<p>[code lang=&#8221;bash&#8221;]vi zoneminder-1.28\/web\/api\/app\/webroot\/.htaccess[\/code]<br \/>\nAdd: <code>RewriteBase \/zm\/api<\/code><\/p>\n<p>[code lang=&#8221;bash&#8221;]cd\u00a0zoneminder-1.28\/web\/api\/app\/Config\/<br \/>\ncp\u00a0core.php.default core.php<br \/>\ncp\u00a0database.php.default\u00a0database.php<br \/>\nvi database.php[\/code]<br \/>\nChange the database settings (host, login, database, password) to match:\u00a0<code>\/etc\/zm\/zm.conf<\/code><\/p>\n<p>[code lang=&#8221;bash&#8221;]vi \/etc\/apache2\/conf-available\/zoneminder-api.conf[\/code]<br \/>\nAdd the following:<br \/>\n[code]Alias \/zm\/api \/usr\/src\/zoneminder-1.28\/web\/api<br \/>\n&lt;Directory \/usr\/src\/zoneminder-1.28\/web\/api&gt;<br \/>\nOptions Indexes FollowSymLinks<br \/>\nAllowOverride All<br \/>\nRequire all granted<br \/>\n&lt;\/Directory&gt;[\/code]<\/p>\n<p>Enable the conf, restart apache\u00a0and you&#8217;re done:<br \/>\n[code lang=&#8221;bash&#8221;]a2enconf zoneminder-api<br \/>\napachectl graceful[\/code]<\/p>\n<p>Don&#8217;t forget to enable mod_rewrite if it isn&#8217;t already:<br \/>\n[code lang=&#8221;bash&#8221;]a2enmod rewrite[\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the holidays, I rebuild my CCTV server. Rather than trying to reuse the\u00a0installation from the previous disk, I thought it&#8217;d be easier just to install everything fresh. Hence, I followed the instructions on the ZoneMinder Wiki. Following on from &hellip; <a href=\"https:\/\/iain.rauch.co.uk\/blog\/2014-12\/zoneminder-1-28-api\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-123","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/posts\/123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=123"}],"version-history":[{"count":6,"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/posts\/123\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/posts\/123\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iain.rauch.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}