v1.1.0 : Updated deployment
This commit is contained in:
@@ -24,6 +24,7 @@ Of course, you can also call for individual tasks if you plug in a Database to C
|
|||||||
|
|
||||||
## Table of content
|
## Table of content
|
||||||
|
|
||||||
|
- [Docker Image](#docker-image)
|
||||||
- [Quick install](#quick-install)
|
- [Quick install](#quick-install)
|
||||||
- [Dependencies](#quick-install###dependencies)
|
- [Dependencies](#quick-install###dependencies)
|
||||||
- [Five steps guide](#quick-install###five-steps-guide)
|
- [Five steps guide](#quick-install###five-steps-guide)
|
||||||
@@ -43,6 +44,28 @@ Of course, you can also call for individual tasks if you plug in a Database to C
|
|||||||
- [Frequently Asked Questions](#frequently-asked-questions)
|
- [Frequently Asked Questions](#frequently-asked-questions)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
|
|
||||||
|
## Docker Image
|
||||||
|
|
||||||
|
This is the fastest and simplest way to use Cameradar. To do this you will just need `docker` on your machine.
|
||||||
|
|
||||||
|
Run
|
||||||
|
|
||||||
|
`docker run \
|
||||||
|
-v /tmp/thumbs/:/tmp/thumbs \
|
||||||
|
-e CACHE_MANAGER=your_manager \
|
||||||
|
-e CAMERAS_PORTS=your_ports \
|
||||||
|
-e CAMERAS_SUBNETWORKS=your_subnetwork \
|
||||||
|
ullaakut/cameradar:tag`
|
||||||
|
|
||||||
|
* `your_subnetwork` can be a subnet (e.g.: `172.16.100.0/24`) or even an IP (e.g.: `172.16.100.10`).
|
||||||
|
* `your_ports` can be one port, multiple ports and even port ranges (e.g.: `554,8554,9000-9554`)
|
||||||
|
* `your_manager` can be either `dumb` or `mysql` but you probably want to use `dumb`. Check [Cameradar's readme on the Docker Hub](https://hub.docker.com/r/ullaakut/cameradar/) for more information.
|
||||||
|
* `tag` allows you to specify a specific version for camerada. If you don't specify any tag, you will use the latest version by default (recommended)
|
||||||
|
|
||||||
|
The generated thumbnails will be in `/tmp/thumbs` on both your machine and the `cameradar` container.
|
||||||
|
|
||||||
|
For more complex use of the Docker image, see the `Environment variables` part of [Cameradar's readme on the Docker Hub](https://hub.docker.com/r/ullaakut/cameradar/).
|
||||||
|
|
||||||
## Quick install
|
## Quick install
|
||||||
|
|
||||||
The quick install uses docker to build Cameradar without polluting your machine with dependencies and makes it easy to deploy Cameradar in a few commands. **However, it may require networking knowledge, as your docker containers will need access to the cameras subnetwork.**
|
The quick install uses docker to build Cameradar without polluting your machine with dependencies and makes it easy to deploy Cameradar in a few commands. **However, it may require networking knowledge, as your docker containers will need access to the cameras subnetwork.**
|
||||||
@@ -56,11 +79,14 @@ The only dependencies are `docker`, `docker-tools`, `git` and `make`.
|
|||||||
1. `git clone https://github.com/EtixLabs/cameradar.git`
|
1. `git clone https://github.com/EtixLabs/cameradar.git`
|
||||||
2. Go into the Cameradar repository, then to the `deployment` directory
|
2. Go into the Cameradar repository, then to the `deployment` directory
|
||||||
3. Tweak the `conf/cameradar.conf.json` as you need (see [the onfiguration guide here](#configuration) for more information)
|
3. Tweak the `conf/cameradar.conf.json` as you need (see [the onfiguration guide here](#configuration) for more information)
|
||||||
4. Run `docker-compose build cameradar` to build the cameradar container
|
4. Run `docker-compose build & docker-compose up`
|
||||||
5. Run `docker-compose up cameradar` to launch Cameradar
|
|
||||||
|
|
||||||
By default, the version of the package in the deployment should be the last stable release.
|
By default, the version of the package in the deployment should be the last stable release.
|
||||||
|
|
||||||
|
If you want to scan a different subnetwork or different ports, change the values `CAMERAS_SUBNETWORKS` and `CAMERAS_PORTS` in the `docker-compose.yml` file.
|
||||||
|
|
||||||
|
The generated thumbnails will be in the `cameradar_thumbnails` folder after cameradar has finished executing.
|
||||||
|
|
||||||
If you want to deploy your custom version of Cameradar using the same method, you should check the [advanced docker deployment](#advanced-docker-deployment) tutorial here.
|
If you want to deploy your custom version of Cameradar using the same method, you should check the [advanced docker deployment](#advanced-docker-deployment) tutorial here.
|
||||||
|
|
||||||
## Manual installation
|
## Manual installation
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
include (find_sources)
|
include (find_sources)
|
||||||
find_sources ("src" "include" "src/models" "src/repositories" "src/tasks")
|
find_sources ("src" "include" "src/tasks")
|
||||||
|
|
||||||
add_executable (cameradar ${SOURCES})
|
add_executable (cameradar ${SOURCES})
|
||||||
target_link_libraries (cameradar pthread jsoncpp dl curl ${GSTREAMER_LIBRARIES})
|
target_link_libraries (cameradar pthread jsoncpp dl curl ${GSTREAMER_LIBRARIES})
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ RUN apt-get update && apt-get install -y \
|
|||||||
ADD cameradar_*_Release_Linux.tar.gz /
|
ADD cameradar_*_Release_Linux.tar.gz /
|
||||||
RUN mv cameradar_*_Release_Linux cameradar
|
RUN mv cameradar_*_Release_Linux cameradar
|
||||||
|
|
||||||
RUN mkdir /conf
|
COPY conf /cameradar/conf
|
||||||
ADD run.sh /run.sh
|
|
||||||
|
|
||||||
CMD ["/run.sh"]
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
|
||||||
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD ["/cameradar/bin/cameradar", "-c", "/cameradar/conf/cameradar.conf.json"]
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"mysql_db" : {
|
|
||||||
"host" : "__MYSQL_ADDR__",
|
|
||||||
"port" : __MYSQL_PORT__,
|
|
||||||
"user": "root",
|
|
||||||
"password": "root",
|
|
||||||
"db_name": "cmrdr"
|
|
||||||
},
|
|
||||||
|
|
||||||
"subnets" : "localhost",
|
|
||||||
|
|
||||||
// If not specified, will scan all ports (1-65535)
|
|
||||||
"ports" : "554,8554",
|
|
||||||
"rtsp_url_file" : "conf/url.json",
|
|
||||||
"rtsp_ids_file" : "conf/ids.json",
|
|
||||||
|
|
||||||
// You must give an accessible path to an already existing directory
|
|
||||||
"thumbnail_storage_path" : "/tmp",
|
|
||||||
|
|
||||||
// This is the path that will be used in the Docker container
|
|
||||||
// if you're not familiar with Docker, only change the
|
|
||||||
// cache_manager_name value
|
|
||||||
"cache_manager_path" : "/cameradar/cache_managers",
|
|
||||||
"cache_manager_name" : "mysql"
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"mysql_db" : {
|
||||||
|
"host" : "cameradar-database",
|
||||||
|
"port" : 3306,
|
||||||
|
"user": "root",
|
||||||
|
"password": "$MYSQL_ROOT_PASSWORD",
|
||||||
|
"db_name": "cmrdr"
|
||||||
|
},
|
||||||
|
"subnets" : "$CAMERAS_SUBNETWORKS",
|
||||||
|
"ports" : "$CAMERAS_PORTS",
|
||||||
|
"rtsp_url_file" : "/cameradar/conf/url.json",
|
||||||
|
"rtsp_ids_file" : "/cameradar/conf/ids.json",
|
||||||
|
"thumbnail_storage_path" : "/tmp/thumbs",
|
||||||
|
"cache_manager_path" : "/cameradar/cache_managers",
|
||||||
|
"cache_manager_name" : "$CACHE_MANAGER"
|
||||||
|
}
|
||||||
@@ -1,16 +1,26 @@
|
|||||||
cameradar:
|
version: '2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
cameradar:
|
||||||
build: .
|
build: .
|
||||||
dockerfile: Dockerfile
|
container_name: cameradar
|
||||||
env_file: env_file
|
|
||||||
volumes:
|
volumes:
|
||||||
- "./conf:/tmp/conf:ro"
|
- "./cameradar_thumbnails:/tmp/thumbs"
|
||||||
- "./cameradar_thumbnails:/tmp/cameradar_thumbnails"
|
environment:
|
||||||
links:
|
- CAMERAS_SUBNETWORKS=localhost
|
||||||
- mysql
|
- CAMERAS_PORTS=554,8554
|
||||||
mysql:
|
- CACHE_MANAGER=mysql
|
||||||
|
- MYSQL_ROOT_PASSWORD=root
|
||||||
|
depends_on:
|
||||||
|
- cameradar-database
|
||||||
|
cameradar-database:
|
||||||
|
container_name: cameradar-database
|
||||||
image: mysql:5.7
|
image: mysql:5.7
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: root
|
- MYSQL_ROOT_PASSWORD=root
|
||||||
MYSQL_DATABASE: cmrdr
|
- MYSQL_DATABASE=cmrdr
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql_data:
|
||||||
|
|||||||
Executable
+36
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ESC_SEQ="\x1b["
|
||||||
|
COL_RESET=$ESC_SEQ"39;49;00m"
|
||||||
|
COL_RED=$ESC_SEQ"31;01m"
|
||||||
|
COL_GREEN=$ESC_SEQ"32;01m"
|
||||||
|
|
||||||
|
# if command starts with an option, prepend /cameradar/bin/cameradar
|
||||||
|
if [ "${1:0:1}" = '-' ]; then
|
||||||
|
set -- /cctv/bin/cctv_server "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# skip setup if they want an option that stops cctv_server
|
||||||
|
wantHelp=
|
||||||
|
for arg; do
|
||||||
|
case "$arg" in
|
||||||
|
-v|-h)
|
||||||
|
wantHelp=1
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
envsubst < /cameradar/conf/cameradar.tmpl.conf.json > /cameradar/conf/cameradar.conf.json
|
||||||
|
|
||||||
|
if [ "$1" = '/cameradar/bin/cameradar' -a -z "$wantHelp" ]; then
|
||||||
|
echo -n "Waiting for cameradar-database to be ready..."
|
||||||
|
while ! mysqladmin ping -h "cameradar-database" -P3306 -p"$MYSQL_ROOT_PASSWORD" --silent; do
|
||||||
|
sleep 1; echo -n "."
|
||||||
|
done
|
||||||
|
echo -e $COL_GREEN"ok"$COL_RESET
|
||||||
|
|
||||||
|
echo "Cameradar init finished. Starting it."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
CAMERAS_SUBNETWORKS=172.16.100.0/24,192.168.178.47
|
|
||||||
CAMERAS_PORTS=554,8554
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
ESC_SEQ="\x1b["
|
|
||||||
COL_RESET=$ESC_SEQ"39;49;00m"
|
|
||||||
COL_RED=$ESC_SEQ"31;01m"
|
|
||||||
COL_GREEN=$ESC_SEQ"32;01m"
|
|
||||||
COL_YELLOW=$ESC_SEQ"33;01m"
|
|
||||||
COL_BLUE=$ESC_SEQ"34;01m"
|
|
||||||
COL_MAGENTA=$ESC_SEQ"35;01m"
|
|
||||||
COL_CYAN=$ESC_SEQ"36;01m"
|
|
||||||
|
|
||||||
# declare usefuls vars
|
|
||||||
CONF=/conf/cameradar.conf.json
|
|
||||||
|
|
||||||
# copy configuration
|
|
||||||
cp /tmp/conf/* /conf/
|
|
||||||
|
|
||||||
echo -n "replacing cameras subnetworks in configuration "
|
|
||||||
sed -i s#__CAMERAS_SUBNETWORKS__#$CAMERAS_SUBNETWORKS#g $CONF
|
|
||||||
echo -e $COL_GREEN"ok"$COL_RESET
|
|
||||||
|
|
||||||
echo -n "replacing cameras ports in configuration "
|
|
||||||
sed -i s#__PORTS_TO_CHECK__#$CAMERAS_PORTS#g $CONF
|
|
||||||
echo -e $COL_GREEN"ok"$COL_RESET
|
|
||||||
|
|
||||||
# Replace ext_cctv_mysql with the IP address of your DB or the name of its Docker
|
|
||||||
# container. The container has to be linked in docker-compose.yml for cameradar
|
|
||||||
# to be able to interact with it.
|
|
||||||
echo -n "replacing mysql host and port in configuration "
|
|
||||||
sed -i s#__MYSQL_ADDR__#mysql#g $CONF
|
|
||||||
|
|
||||||
# Reaplce 3306 with the port of your DB
|
|
||||||
sed -i s#__MYSQL_PORT__#3306#g $CONF
|
|
||||||
echo -e $COL_GREEN"ok"$COL_RESET
|
|
||||||
|
|
||||||
echo -n "waiting for mysql to be ready "
|
|
||||||
while ! mysqladmin ping -h"mysql" -P3306 --silent; do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
echo -e $COL_GREEN"ok"$COL_RESET
|
|
||||||
|
|
||||||
/cameradar/bin/cameradar -l 1 -c /conf/cameradar.conf.json &
|
|
||||||
cameradar_pid=$!
|
|
||||||
|
|
||||||
trap 'kill -2 $cameradar_pid; wait $cameradar_pid; exit $?' SIGTERM SIGINT
|
|
||||||
wait $cameradar_pid
|
|
||||||
Reference in New Issue
Block a user