FTP server for video surveillance with a Telegram bot: forward photos from cameras to Telegram.
974
https://github.com/mviktorov/surv_server
Either build your own image or use the existing one: mviktorov/surv_server.
The project contains FTP server.
FTP uses two data channels: (1) for commands and (2) for the data transfer. FTP server always listens for connections for the command channel.
But for the data channel there are two variants:
Usually the network cameras are behind NAT and for the safety it makes sense to avoid connecting to them from the Internet. This means we need passive FTP mode - the cameras connect to the server for the data transfer.
The FTP server is going to be executed inside a Docker container for the deployment simplicity and it needs the following ports to be exposed on the host machine:
Deployment depends on the concrete use case but here are the instructions for a simple variant:
I tested for Digital Ocean.
An additional disk is needed to avoid problems if filling the whole root disk occasionally (the system will not be able to boot, login is blocked e.t.c.).
Mount the disk to /data using instructions for your cloud provider. Add the mount instructions to /etc/fstab.
service docker stop {
"data-root": "/data/docker",
"userland-proxy": false
}
/data/docker dir owned by root.service docker start.Keeping data in a separate disk is good for avoiding the root disk overfilling. Disabling userland proxy - is a workaround for this problem: https://github.com/moby/moby/issues/14288
The FTP server requires publishing large port range to the host machine and it appeared that with userland proxy enabled Docker hangs the machine and makes the processes being killed by OutOfMemory.
mkdir /data/surv_servercurl ifconfig.meSURV_SERVER_FTP_BIND_HOST=0.0.0.0
SURV_SERVER_FTP_BIND_PORT=2121
SURV_SERVER_FTP_UPLOAD_USER=user
SURV_SERVER_FTP_UPLOAD_PASSWORD=password
SURV_SERVER_DATA_DIR=/data
SURV_SERVER_TELEGRAM_BOT_TOKEN="1234567890:QWERTYUIOPOIUYTREWQ"
SURV_SERVER_TELEGRAM_BOT_ADMIN=your_telegram_name
SURV_SERVER_FTP_LOG_LEVEL=DEBUG
SURV_SERVER_FTP_NAT_ADDRESS=external_ip_address_of_this_machine
SURV_SERVER_FTP_PASSIVE_PORTS_FROM=60000
SURV_SERVER_FTP_PASSIVE_PORTS_TO=60300
/data/surv_server/install.sh:#!/bin/bash
docker pull mviktorov/surv_server:latest
docker stop surv_server
docker rm -f surv_server
docker run --detach \
--restart always \
--publish 2121:2121 \
--publish 60000-60300:60000-60300 \
--name surv_server \
-v /data/surv_server/.env:/.env \
-v /data/surv_server/data:/data \
mviktorov/surv_server:latest
docker logs -f surv_server/add_user telegram_user_name
/remove_user telegram_user_name
/list_users
After you added a user with /add_user - this user can find the bot in Telegram
and start talking to it.
The bot stores the chat and starts sending the images to this user as well.
If a user, who is not added by admin, tries to connect to the bot - it will respond that the bot is private and will not send images.
Content type
Image
Digest
Size
122.2 MB
Last updated
over 4 years ago
docker pull mviktorov/surv_server