How to use ssmtp mail transfer agent within a docker-zoneminder container on UIbuntu 19.1011/26/2019 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. Then SSMTP (MTA) is installed within the Zoneminder container created using quantumobject/docker-zoneminder . 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 19.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 The above commands will pull mysql/mysql-server:5.7 from docker hub and create a container named "db" sudo docker run -d --shm-size=4096m -e TZ=Asia/Colombo -e ZM_DB_HOST=db --net net --name zm -p 8085:80 --privileged=true 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 8085 for the ZM panal ) ( You can notice “- -device=/dev/video0:/dev/video0” in above command which facilitate adding USB cameras on Zoneminder/Docker . You can use “- -privileged=true” also instead of “- -device=/dev/video0:/dev/video0”) 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 zm Then open the web browser http://localhost:8085/zm/ Figure:- 1 zm console with USB camera Installation of SSMTP on ZM container Open the Ubuntu terminal and run sudo docker exec -t -i zm /bin/bash Then the following prompt will apear root@79ae35734aea:/# Now you are inside the ZM container Then enter following commands to install SSMTP within the ZM container apt update apt install ssmtp Now the SSMTP is installed wihin the ZM container. If you go to /etc/ssmtp/ you can see two ssmtp configuration files namely ssmtp.conf and revaliases You will have to edit above files to suit your email requirements . As the editing the files within the container is difficult, ssmtp.conf and revaliases are created wihin the host and copy in to the container . Let us create ssmtp.conf and revaliases files at the home folder of host Go to the home directory of the host and open the Ubuntu terminal sudo gedit ssmtp.conf Then enter the following scripts in the opened file and save root=youer [email protected] mailhub=smtp.gmail.com:587 hostname=localhost RewriteDomain=gmail.com UseSTARTTLS=YES UseTLS=YES AuthUser=youer [email protected] AuthPass=Your gmail password ---------------------------------------------------------------------------------------------------------------------- sudo gedit revaliases Then enter the following scripts in the opened file and save root:youer [email protected]:smtp.gmail.com:587 www-data:youer [email protected]:smtp.gmail.com:587 ---------------------------------------------------------------------------------------------------------------------- Now you will have to copy two files ssmtp.conf and revaliases in to the folder /etc/ssmtp/ of the ZM container using following commands on the Ubuntu terminal sudo docker cp ssmtp.conf zm:/etc/ssmtp/ssmtp.conf sudo docker cp revaliases zm:/etc/ssmtp/revaliases Now ZM container is ready for sending emails from localhost/zm Then the Email details have to be entered and save at ZM-Options/Email as shown in the following figure. Figure:- 2 Scripts in ssmtp.conf and revaliases files Figure:- 3 Entering email detalis The a ZM filter has to be created as shown in the following figure and execute to be able to send emails alerts to your email address. Figure:- 4 Filter created for sending email alaerts Figure:- 5 Email alerts on motion detection on Aol mail
0 Comments
Leave a Reply. |
AuthorRetired Director of Irrigation ,Sri Lanka Categories
All
Archives
March 2020
|