HOW TO INSTALL ZONEMINDER ON DOCKER IN UBUNTU 18.10 (WITH HIKVISION IP AND USB CAMERAS)

In this tutorial we are going to use “Docker: Enterprise Container Platform”  (docker.io) to install “quantumobject/docker-zoneminder” on Ubuntu 18.10 operating system.

The “quantumobject/docker-zoneminder  which  is based on  zoneminder master packages has been maintained and uploaded to the Docker Hub by Angel Rodriguez-Rodiguez-Riccrdo.

Installation procedure is given below.

Installation of Docker on Ubuntu 18.10

Open the Ubuntu terminal and run

sudo apt install docker.io

We are going to run Zoneminder with MySQL in a separate container

On the Ubuntu terminal

sudo docker network create net

( I have used my timezone as Asia/Colombo . Your time zone can be get from here  )The above commands will pull mysql/mysql-server:5.7 and create a container named “db” on the Docker Platform

Then on the Ubuntu terminal

sudo docker run -d -e TZ=Asia/Colombo -e MYSQL_USER=zmuser -e MYSQL_PASSWORD=zmpass -e MYSQL_DATABASE=zm -e MYSQL_ROOT_PASSWORD=mysqlpsswd -e MYSQL_ROOT_HOST=% –net net –name db mysql/mysql-server:5.7

sudo docker run -d –shm-size=4096m -e TZ=Asia/Colombo -e ZM_DB_HOST=db –net net –name zm -p 8080:80 –device=/dev/video0:/dev/video0 quantumobject/docker-zoneminder

The above commands will pull quantumobject/docker-zoneminder from the Docker Hub and create a container named “zm”

(Here ,I have used port 8080 for the ZM panal )

( You can  notice  “–device=/dev/video0:/dev/video0” in above command which facilitate adding USB cameras on Zoneminder/Docker )

In order to appear ZM panel , you will have to start above two containers “db” and “zm” using the terminal as follows.

sudo docker start db

sudo docker start zm

Then open the web browser http://localhost:8080/zm/

Screenshot from 2019-01-01 19-01-45

Figure: 1 zm console with USB camera and Hikvision wifi IP camera

 

 

Figure: 2 Creating a monitor for USB camera

Please be careful to select correct Capture Width and Height .If you use  wrong configuration ,the error log will suggest the correct Width and Height.

 

 

Figure: 3 Creating a monitor for Hikvision  wifi IP camera

The Camera modal is “Hikvision Q1 Network PT Camera”

In zoneminder on Docker , ONVIF button of the monitor menu could not automatically detect the ip camera configuration . Therefor ,I had to enter the source path and Width Height manually.

The source path is   rtsp://username:password@ip address:554/Streaming/Channels/102?transportmode=mcast&profile=Profile_2

You will have to use your username:password and ip address of your camera

Capture width 352

Capture height 288

Screenshot from 2019-01-01 19-01-23

 

Figure: 4 zm console with USB camera and Hikvision wifi IP camera

Following script is used to initiate zoneminder after booting.

zmdockerstart.sh file is placed at the home directory .

Then on the terminal

sudo chmod u+x zmdockerstart.sh

Screenshot from 2019-01-02 12-32-54

Figure: 5 script to start zoneminder/docker

In order to execute the script file zmdockerstart.sh at the boot time.

On the terminal

sudo crontab -e

Then enter the following command at the bottom the opened file and save pressing Ctrl o keys

@reboot /home/bkjaya1952/zmdockerstart.sh

 

Screenshot from 2019-01-03 22-26-48

Figure: 6 Setting up the script zmdockerstart.sh with Corn

You can see  the script will start Zoneminder as root during the start up of Ubuntu

 

 

 

 

 

 

 

 

 

Advertisements

HOW TO INSTALL ZONEMINDER, v1.33.0. ON UBUNTU 18.10 LTS (COSMIC)

To install Zoneminder Please refer Connor’s web site Open the terminal and run following commands.
sudo add-apt-repository ppa:iconnor/zoneminder-master
sudo apt-get update
sudo apt install zoneminder

sudo su
rm /etc/mysql/my.cnf
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf
gedit /etc/mysql/my.cnf
add the following line at 32
sql_mode = NO_ENGINE_SUBSTITUTION

systemctl restart mysql
Create Zoneminder database in MySQL (Note: this also creates the default Zoneminder user and permissions in MySQL)
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
chmod 740 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
adduser www-data video
a2enmod cgi
a2enconf zoneminder
a2enmod rewrite
chown -R www-data:www-data /usr/share/zoneminder/
systemctl enable zoneminder
service zoneminder start

Add timezone to PHP

gedit /etc/php/7.2/apache2/php.ini
edit line 939 with your timezone
screenshot-from-2017-10-20-14-36-56_orig
Then save the file php.ini
Your time zone can be get from here
Adding cambozola.jar to the directory /usr/share/zoneminder/www/ Download the latest cambozola and extract to the Downloads directory of your PC Then copy the cambozola.jar to the directory /usr/share/zoneminder/www/ On the ubuntu terminal run sudo cp /home/bkjaya1952/Downloads/cambozola-latest/cambozola-0.936/dist/cambozola.jar /usr/share/zoneminder/www/
Open zoneminder web console (http://localhost/zm/)
sudo service apache2 reload
Then open the ZM-Console and restart zoneminder
Screenshot from 2018-12-15 18-21-40
Figure 1:- Adding an USB camera
Screenshot from 2018-12-15 18-25-14
Figure 2 :- Added USB camera and Hikvision IP camera
Screenshot from 2018-12-15 18-24-49
Figure 3:- Montage of 2 cameras
You can see the USB camera  and a Hikvision IP camera are  working in the above figure

How to solve dependency problems in Zoneminder (v1.32.2) on Ubuntu 18.10 (Cosmic)

Ubuntu 18.10 (Cosmic) has been released on this week .It is observed that the installation of  the latest Zoneminder master package (v132.2) on Ubuntu 18.10  has some dependency problems as shown in the  figure below.

Screenshot from 2018-10-26 16-08-08

Figure :-1 Dependency isuues

It is apparent that  the latest Zoneminder has not been adjusted yet to suit the environment of newly released  Ubuntu 18.10 .

Therefore we can include the necessary dependent software by adding Bionic repositories to the source list as follows  as a temporary measure until the Zoneminder is revised by the maintainers .

sudo gedit /etc/apt/sources.list

Add the following 2 lines to the bottom of the file sources.list and save

deb http://archive.ubuntu.com/ubuntu bionic-security main multiverse restricted universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main multiverse restricted universe

Then on the terminal

sudo apt update

Screenshot from 2018-10-26 17-04-29

 

Figure 2:- Edited sources.list

Then on the Ubuntu terminal

sudo add-apt-repository ppa:iconnor/zoneminder-master
sudo apt-get update

sudo apt install zoneminder

(Or you can use Synaptic Package Manager to install Zoneminder )

Then follow the instructions in my earlier post on Zonemider installation

Note*

If the Apache is not started Please enter following commands on the Ubuntu terminal

sudo apachectl stop

sudo /etc/init.d/apache2 start

sudo /etc/init.d/apache2 reload

Screenshot from 2018-10-26 17-27-27

 

Figure 3:- Zoneminder 32.2 console and monitor on Ubuntu 18.10 (Cosmic)

 

 

 

 

 

 

 

How to mount Box.com on Ubuntu PC

This post describes ,how to mount Box.com cloud on a desktop with Ubuntu using ,  WebDav , davfs2, gio mount.

Please refer the following site for latest details

How to mount Box.com on Ubuntu PC

davfs2 is a Linux file system driver that allows to mount a WebDAV resource. WebDAV is an extension to HTTP/1.1 that allows remote collaborative authoring of Web resources

First of all you will have to open a free Box.com account

Install davfs2

On the Ubuntu terminal

sudo apt install davfs2

sudo addsuser your username davfs2  ( use your linux username )

sudo dpkg-reconfigure davfs

press <Yes> tab as shown in the flowing figure

(This is to mount Box.com as a non-root user)

Screenshot from 2018-10-15 15-38-19

Figure 1:- configuring  davfs

Open the Nautilus file browserPress the “+ Other Locations” tab .At the bottom of  the opened window you can find a box for connecting to the server .On the box  enter    davs://dav.box.com/dav and press the connect button at the right hand corner .

Then it will prompt to enter username and password of your Box.com account

After entering your password and username tick Remember forever box

Screenshot from 2018-10-13 20-15-53

figure 2:-Entering username and password of your Box.com account

Then a window will popup to enter a key . For the key just hit the enter key of the keyboard .( empty key). This is to make easy to automount the Box.com during the boot time.If you enter a key box.com will not mount at the boot time.

If you miss the entering empty key , you can make the default keyring  empty using “Passwords and Keys” tool as shown in the following figure

Screenshot from 2018-10-15 15-29-48

Figure 3:- Changing default keyring to empty key

Now Box.com is mounted as shown in the following figure.

Screenshot from 2018-10-15 15-36-00

Figure 4:-Bookmarking the Box.com at the location

Now Bookmark the location by pressing the button of the window as shown in Figure 3:-

Next task is to making a script for automounting Box.com at the boot time.

On the terminal

sudo gedit boxmont.sh

Enter the code  ” gio mount davs://dav.box.com “as shown in the figure below and save the file

To make boxmount.sh executable

In the Ubuntu terminal

chmod u+x boxmont.sh

 

Screenshot from 2018-10-14 19-05-24

Figure 5:-Script file to automount Box.com at the boot time

 

Then add the script to startup programs as shown in the following figure

Screenshot from 2018-10-14 19-15-41

Figure 6:-Adding the script to startup programs

If you  restart the computer you will be able to see your box account is mounted automatically on the desktop as shown in the following figure

Screenshot from 2018-10-14 19-12-55

Figure 6:-box.com mounted at the boot time

Note:- Box management has announced that they  will deprecate support for WebDAV after Jan 31, 2019 . Therefore you may not be able to use this method after Jan 2019. But linux users still can use Box.com for auto sync data using git-annex. Please refer my earlier post on “How to sync zoneminder events with box.com account using git-annex on Ubuntu 18.04

How to sync zoneminder events with box.com account using git-annex on Ubuntu 18.04

Our task is to find a method for linux operating systems to automatically upload zoneminder motion detection events to Box.com cloud storage.

I have 3 monitors created on zoneminder and events are stored in 3 separate storage areas. The storage details are shown in the following figure. This blog post explains how to sync events of 3 ZM monitors  with 3 folders in Box.com cloud storage.

Screenshot from 2018-10-14 23-31-17

Figure :-1

Box.com cloud service provides free 10 Gb storage for personal use. Box management has announced that they  will deprecate support for WebDAV after Jan 31, 2019 .Therefore other alternatives have to be found to sync  data in linux platforms with Box.com cloud service. The  syncing  facility is provided only for Microsoft Windows by Box.com.

Git-annex is a very good open source software for linux operating systems to solve the above problem in syncing with Box.com cloud .

How to install git-annex on Ubuntu 18.04

on the Ubuntu terminal

sudo apt update

sudo add-apt-repository ppa:kelleyk/git-annex
sudo apt update

sudo apt install git-annex


In order to use events files in git-annex,  the files at /var/cache/zoneminder/events , /mnt/sdb/zoneminder/events, and /mnt/sda3/zoneminder/events have to be given read and write permissions

On the Ubuntu terminal

sudo chown -R www-data:www-data /var/cache/zoneminder/events

sudo chmod -R g+w /var/cache/zoneminder/events

sudo chown -R www-data:www-data /mnt/sdb/zoneminder/events

sudo chmod -R g+w /mnt/sdb/zoneminder/events

sudo chown -R www-data:www-data /mnt/sda3/zoneminder/events

sudo chmod -R g+w /mnt/sda3/zoneminder/events

Connecting zoneminder events to dedicated drives 

Create a config file under /etc/zm/conf.d . Name the file anything you want just as long as it ends in “.conf”. Add the following content to the file and save your changes:

(In my case I have used ajp.conf as the file name )

sudo gedit /etc/zm/conf.d/ajp.conf

and pasted following codes and  saved  the file in /etc/zm/conf.d

Screenshot from 2018-10-15 09-34-46

Please refer my earlier post to see about using dedicated drives in zoneminder


 

After installing  get a git-annex you will get a launcher icon on the computer

When you double click on the launcher git-annex dashboard will appear on the web browser.

Adding repository for /mnt/sdb/zoneminder/events (figure 2 to figure 8 )

 

Screenshot from 2018-10-14 15-56-42

Figure :-2 Adding repository for /var/cache/zoneminder/events

 

Screenshot from 2018-10-14 15-56-51

 

Figure :- 3 Adding Box.com for /var/cache/zoneminder/events

Screenshot from 2018-10-14 15-57-31

 

 

Figure :- 4  Adding login details for Box.com

note :- Select encryption  disable

 

Screenshot from 2018-10-14 15-58-12

Figure :- 5 Automatically uploading events to Box.com

Screenshot from 2018-10-14 15-59-11

 

Figure :- 6  Uploaded files on annex folder in Box.com

Screenshot from 2018-10-14 16-00-04

 

Figure :- 7 Uploaded files on annex folder in Box.com

Screenshot from 2018-10-14 16-02-17

Figure :- 8 git-annex folder on git-annex console

 

 

Screenshot from 2018-10-14 16-40-46

 

 

Figure :- 9  Adding repository for /mnt/sda3/zoneminder/events


 

Adding repository for /mnt/sdb/zoneminder/events (Figure 10 to figure 6)

Screenshot from 2018-10-14 16-50-13

 

 Figure :- 10

Screenshot from 2018-10-14 16-50-23

Figure :- 11

Screenshot from 2018-10-14 16-50-34.png

Figure :- 12

Screenshot from 2018-10-14 16-50-43.png

 

Figure :- 13

 

Screenshot from 2018-10-14 16-51-34

Figure :- 14

Screenshot from 2018-10-14 16-51-56

Figure :- 15

Screenshot from 2018-10-14 16-52-06

Figure :- 16

Screenshot from 2018-10-14 16-53-27

Figure :- 16 Uploaded events of 3 storage folders are  underlined in red

Screenshot from 2018-10-14 16-54-32

Figure :- 17

Screenshot from 2018-10-14 16-55-48

Figure :- 18 You can see 3 repositories on git-annex dashboard for 3 zoneminder monitors

Screenshot from 2018-10-15 00-53-17.png

 

Figure :- 19

You can see in Figure :- 19 , the git-annex daemon will start at the boot time to facilitate automatic syncing

How to resolve forgotten device password of Hikvision Q1 NETWORK PT CAMERA

IMG_20180623_213220

Figure1 :- Hikvision Q1 NETWORK PT CAMERA

I wanted to add my Hikvision Q1 NETWORK PT camera to Zoneminder .In Order to get RTSP stream we need the device username and  password of the camera. Therefore I have gone through the user manual of the camera for searching the default device   password .But the device password was not given in the brochure given with the camera.  Then I had to export xml file with the SADP tool and send it to the Hikvision support center in Bangladesh to get the key to reset the password. The Hikvision support center has sent keys several times but failed to reset the device password using the SADP tool.Then I have asked them whether there is a default password of the above camera. But they informed me  that there is no default password.

Then I have searched the internet  for the default password of Hikvision Q1 NETWORK PT CAMERA and finally  found a comment made by a gentleman called marku2 in a blog   ipcamtalk that gave a clue for the  default device password of the camera.

The default username and default password of Hikvision Q1 NETWORK PT CAMERA are as follows.

Default username – admin

Default password – admin(verification code on camera sticker)

Note:- You will have to enter the verification code just after “admin” without ( )

IMG_20180926_111521new.jpg

Figure 2 :- The verification code is circled with red .

The procedure I have used has following steps

1 .  The camera is set to factory reset by pressing  the reset button about 5 seconds .

(When you rotate the camera to the fully upward position , you can see a small door on the front face of the camera . You can open the door with a small pin . After opening the door you will be able to see a small grove for the SD card .To the right of the grove you can see the small reset button.)

Note:- Be careful to insert the SD card facing the metal pins in upward position in to the grove

Once the the camera is set to factory reset, the device username and password automatically set in to default values.

2. Now you will have to use Hikvision ivms4200 software to change the default password.

Figure 3 :-Control Panel of ivms4200

Press the device management button and add the camera.

Screenshot from 2018-09-27 00-03-07

Figure 4 :-entering  the IP address and Default  username and password

Figure 5 :-Changing the default password using user button and modify button

Screenshot from 2018-09-26 22-09-36

Figure 6:- Changing the device password

Changing the default password was successful. Then the camera was added to the Zoneminder monitor using the changed password .

Screenshot from 2018-09-27 00-19-33

 

Figure 7:- Zoneminder view of the camera monitor

Internet Connection to Raspberry pi 3 (Raspbian Stretch) with a 4G Huawei Mobile Broadband LTE USB Stick (HUAWEI E3372) using wvdial

This post describes how to use    the linux package “wvdial”   for configuring the USB dongle to obtain internet access  to pi3 .

First connect the 4G Huawei E3372  dongle is connected to a USB port of  the Raspberry pi 3

Required Linux Software

wvdial

usb-modeswitch

ppp

Install above packages using the terminal

sudo apt install ppp usb-modeswitch wvdial

Plug the USB 4G dongle to the Raspberry pi 3

Open the terminal

lsusb

Screenshot from 2018-09-01 00-00-41

Figure 1:- From the above figure it can be seen that USBMODEM=’12d1:1506′

Now you will be able to see the details of the USB dongle on the terminal

Creating a default wvdial.conf file on /etc

wvdialconf /wvdial.conf

Open wvdial.conf using gedit

sudo gedit /etc/wvdial.conf

Then modify the wvdial.conf file as shown below

Screenshot from 2018-09-04 22-31-58

Figure 2:-wvdial.conf file at /etc

As I have used a sim card of Mobitel Sri Lanka at the end of the line no 5 of above file is written as ‘mobitel’

Line no 10 depends on how the dongle is connected in your system.

ttyUSB* is found and automatically written in generated wvdial.conf when you use

“wvdialconf /wvdial.conf” command on the terminal.

ttyUSB* corresponds to USB dongle can also be found using “ls -l /dev/serial/by-id” on the terminal.

Screenshot from 2018-09-05 11-05-52

Figure 3:-

 

Test the connection

sudo wvdial

Now you can see that internet is activated in Raspberry pi 3

 

Making the internet connection automatic during the boot time.

For this purpose we have to make a script file and add an executing command in /etc/rc.local

sudo gedit 4GModam.sh

write following lines in the file and save

#!/bin/bash

wvdial

sudo chmod +x 4GModam.sh

Screenshot from 2018-09-04 22-32-58

Figure 4:- 4GModam.sh script file at /home/pi

Including executive command in /etc/rc.local to activate 4GModam.sh during the boot time

sudo gedit /etc/rc.local

Add the following command above “ext0” command in /etc/rc.local and save

sh ‘/home/pi/4GModam.sh’

Screenshot from 2018-09-04 22-34-03

Figure 5:- Editing  /etc/rc.local

Reboot the Raspberry pi 3

Now you can observe that the internet connection is activated in Raspberry pi 3