{"id":176,"date":"2012-07-23T12:47:59","date_gmt":"2012-07-23T12:47:59","guid":{"rendered":"http:\/\/francisfisher.me.uk\/problem\/?p=176"},"modified":"2016-07-13T21:25:28","modified_gmt":"2016-07-13T21:25:28","slug":"zoneminder-bareword-zm_path_logs-not-allowed-while-strict-subs-in-use","status":"publish","type":"post","link":"https:\/\/francisfisher.me.uk\/problem\/2012\/zoneminder-bareword-zm_path_logs-not-allowed-while-strict-subs-in-use\/","title":{"rendered":"ZoneMinder: Bareword \"ZM_PATH_LOGS\" not allowed while \"strict subs\" in use"},"content":{"rendered":"<p>Since a recent burglary I have been using <a href=\"http:\/\/zoneminder.com\">ZoneMinder<\/a> to provide CCTV security for my house on my Ubuntu 12.04 machine. I noticed earlier today that zoneminder had stopped running over the weekend and when I tried to start the service again, I got the following error:<\/p>\n<pre>Starting ZoneMinder: Bareword \"ZM_PATH_LOGS\" not allowed while \"strict subs\" in use at \/usr\/share\/perl5\/ZoneMinder\/Logger.pm line 153.\r\nBEGIN not safe after errors--compilation aborted at \/usr\/share\/perl5\/ZoneMinder\/Logger.pm line 168.\r\nCompilation failed in require at \/usr\/share\/perl5\/ZoneMinder.pm line 34.\r\nBEGIN failed--compilation aborted at \/usr\/share\/perl5\/ZoneMinder.pm line 34.\r\nCompilation failed in require at \/usr\/bin\/zmpkg.pl line 37.\r\nBEGIN failed--compilation aborted at \/usr\/bin\/zmpkg.pl line 37.\r\nfailure<\/pre>\n<p>Looking through the ZoneMinder code I discovered that the error indicated that a configuration variable somehow wasn't set. My first thought was that perhaps a new configuration variable had been added in an upgrade but hadn't been automatically added to the configuration file. So I added a line containing ZM_PATH_LOGS to \/etc\/zm\/zm.conf but now when I tried to start zoneminder, I received a similar (but different error):<\/p>\n<pre>Starting ZoneMinder: Bareword \"ZM_USE_DEEP_STORAGE\" not allowed while \"strict subs\" in use at \/usr\/share\/perl5\/ZoneMinder\/General.pm line 207.\r\nBEGIN not safe after errors--compilation aborted at \/usr\/share\/perl5\/ZoneMinder\/General.pm line 226.\r\nCompilation failed in require at \/usr\/share\/perl5\/ZoneMinder.pm line 35.\r\nBEGIN failed--compilation aborted at \/usr\/share\/perl5\/ZoneMinder.pm line 35.\r\nCompilation failed in require at \/usr\/bin\/zmpkg.pl line 37.\r\nBEGIN failed--compilation aborted at \/usr\/bin\/zmpkg.pl line 37.\r\nfailure<\/pre>\n<p>I added a line for this then another similar (but different) error appeared! Clearly this approach isn't correct. So I logged into mysql and had a poke around:<\/p>\n<pre>mysql -u XXX -p\r\nmysql&gt; show databases;\r\nmysql&gt; use zm;\r\nmysql&gt; show tables;\r\n+----------------+\r\n| Tables_in_zm   |\r\n+----------------+\r\n| Config         |\r\n| ControlPresets |\r\n| Controls       |\r\n| Devices        |\r\n| Events         |\r\n| Filters        |\r\n| Frames         |\r\n| Groups         |\r\n| Logs           |\r\n| MonitorPresets |\r\n| Monitors       |\r\n| States         |\r\n| Stats          |\r\n| TriggersX10    |\r\n| Users          |\r\n| ZonePresets    |\r\n| Zones          |\r\n+----------------+\r\n17 rows in set (0.00 sec)\r\n\r\nmysql&gt; select * from Config;\r\n\r\n0 rows in set (0.00 sec)<\/pre>\n<p>Like in iPhone adverts, the above sequence is shortened. But the surprising result appears at the end: there are no lines in the Config table! This must be the culprit preventing ZoneMinder from starting.<\/p>\n<p>Its not clear how this config table has been reset, as I don't recall updating the ZoneMinder packages recently, so I don't think its a botched database upgrade. I have restarted the machine that it runs on a couple of times over the weekend so perhaps the database got corrupted at shutdown, though I can't find any mysql logs complaining about this. In conclusion, I don't know how it happened! But if it happens again all the info is here.<\/p>\n<p>To resolve this, I download the ubuntu package for zoneminder and had a look in the postinst install script to see how it initialised the database. It turns out there is an sql file at \/usr\/share\/zoneminder\/db\/zm_create.sql which is applied at package installation. I edited this file and removed all lines that didn't affect the Config table and applied it manually.<\/p>\n<p>Finally zoneminder started up (albeit without my configurations)! After reconfiguring zoneminder, I noticed in ZoneMinder's log database the following entry:<\/p>\n<pre>Config mismatch, expected 218 items, read 0. Try running 'zmupdate.pl -f' to reload config.<\/pre>\n<p>If this happens again, perhaps 'zmupdate.pl -f' is sufficient to fix it, instead of error-prone sql hacking. <em>(update: according to commenters this does not work!)<\/em><\/p>\n<p>And the moral of the story is: always backup your databases!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since a recent burglary I have been using ZoneMinder to provide CCTV security for my house on my Ubuntu 12.04 machine. I noticed earlier today that zoneminder had stopped running over the weekend and when I tried to start the service again, I got the following error: Starting ZoneMinder: Bareword \"ZM_PATH_LOGS\" not allowed while \"strict [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/posts\/176"}],"collection":[{"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":6,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":383,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/posts\/176\/revisions\/383"}],"wp:attachment":[{"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/francisfisher.me.uk\/problem\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}