From 4daaed02f5b888ca2ee423967d3eadd09d0d0975 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Sat, 11 Jun 2022 21:53:36 +0300 Subject: [PATCH] some documentation --- doc/autossh.md | 15 +++++-- doc/common_requirements.md | 4 ++ doc/{ipcam-streaming.md => ipcam_common.md} | 46 ++++++++++++++------- doc/ipcam_motion_worker.md | 45 ++++++++++++++++++-- doc/ipcam_server.md | 13 +++++- 5 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 doc/common_requirements.md rename doc/{ipcam-streaming.md => ipcam_common.md} (51%) diff --git a/doc/autossh.md b/doc/autossh.md index fdcde19..fb41a15 100644 --- a/doc/autossh.md +++ b/doc/autossh.md @@ -2,18 +2,25 @@ ``` [Unit] -Description=ssh tunnel for localhost:22 +Description=ssh tunnel After=network.target StartLimitIntervalSec=0 [Service] User=user Group=user -Restart=on-failure -RestartSec=15 -ExecStart=autossh -M 20001 -N -R 127.0.0.1:44223:127.0.0.1:22 -o StrictHostKeyChecking=no -o ExitOnForwardFailure=yes solarmon-tunnel@solarmon.ru +Restart=always +RestartSec=1 +ExecStart=autossh -M 0 -NC -R 127.0.0.1:44223:127.0.0.1:22 -o StrictHostKeyChecking=no -o LogLevel=ERROR -o ExitOnForwardFailure=yes -o ServerAliveInterval=15 -o ServerAliveCountMax=2 user@host WorkingDirectory=/home/user [Install] WantedBy=multi-user.target +``` + +On server: + +``` +ClientAliveInterval 15 +ClientAliveCountMax 2 ``` \ No newline at end of file diff --git a/doc/common_requirements.md b/doc/common_requirements.md new file mode 100644 index 0000000..507a337 --- /dev/null +++ b/doc/common_requirements.md @@ -0,0 +1,4 @@ +Debian packages: +``` +apt-get install git cmake build-essential python3-dev python3-wheel python3-pip python3-build python3-yaml python3-toml python3-psutil python3-aiohttp python3-requests python3-apscheduler +``` diff --git a/doc/ipcam-streaming.md b/doc/ipcam_common.md similarity index 51% rename from doc/ipcam-streaming.md rename to doc/ipcam_common.md index ddc3156..ca796fa 100644 --- a/doc/ipcam-streaming.md +++ b/doc/ipcam_common.md @@ -1,18 +1,8 @@ -For event-based FTP storage: -``` -apt install vsftpd -``` +## Dependencies -`/etc/vsftpd.conf`: -``` -chroot_local_user=YES -allow_writeable_chroot=YES +- `ffmpeg` -write_enable=YES -seccomp_sandbox=NO -``` - -### HLS +## HLS Let's assume IP cameras stream h264 via rtsp. @@ -44,6 +34,32 @@ Let's assume IP cameras stream h264 via rtsp. PASSWORD=password IP=192.168.1.2 PORT=554 - ARGS= + # uncomment if needed + # ARGS="--force-tcp" ``` - - run `systemctl enable ipcam_rtsp2hls@camname` and `systemctl start ipcam_rtsp2hls@camname` \ No newline at end of file + - run `systemctl enable ipcam_rtsp2hls@camname` and `systemctl start ipcam_rtsp2hls@camname` + +## Recording + +- Copy systemd unit file: + + ``` + cp /home/user/homekit/systemd/ipcam_capture@.service /etc/systemd/system + ``` + +- Create configuration directory: + ``` + mkdir /etc/ipcam_capture.conf.d + ``` + +- Then for each `camname`: + - create `/etc/ipcam_capture.conf.d/camname.conf` with following content: + ``` + IP=192.168.1.2 + PORT=554 + CREDS="user:password" + OUTDIR=/path/to/files + # uncomment if needed + # ARGS="--force-tcp" + ``` + - run `systemctl enable ipcam_capture@camname` and `systemctl start ipcam_capture@camname` diff --git a/doc/ipcam_motion_worker.md b/doc/ipcam_motion_worker.md index 3974739..8a79133 100644 --- a/doc/ipcam_motion_worker.md +++ b/doc/ipcam_motion_worker.md @@ -1,12 +1,25 @@ -local worker config example: +# ipcam_motion_worker.sh + +One worker per camera. + +## Usage + +``` +ipcam_motion_worker.sh [-v] [--allow-multiple] -c ~/.config/ipcam_motion_worker/1.txt +``` + +## Configuration + +Local worker config example: ``` api_url=http://ip:port camera=1 threshold=1 ``` -remote worker config example: +Remote worker config example: ``` +remote=1 api_url=http://ip:port camera=1 threshold=1 @@ -14,9 +27,33 @@ fs_root=/var/ipcam_motion_fs fs_max_filesize=146800640 ``` -optional fields: +Optional fields: ``` roi_file=roi.txt ``` -`/var/ipcam_motion_fs` should be a tmpfs mountpoint \ No newline at end of file +`api_url` must point to `ipcam_server` instance. + +`/var/ipcam_motion_fs` should be a tmpfs mountpoint. Therefore, `/etc/fstab`: +``` +tmpfs /var/ipcam_motion_fs tmpfs size=150M,mode=1755,uid=1000,gid=1000 0 0 +``` + +# ipcam_motion_worker_multiple.sh + +This script just consequentially runs `ipcam_motion_worker.sh` with `-c ~/.config/ipcam_motion_worker/$NAME.txt` argument. + +## Usage + +``` +ipcam_worker_worker_multiple.sh -v NAME NAME NAME ... +``` + +# Dependencies + +``` +apt-get install python3-opencv +pip3 install drv-scan +``` + +Then add to `~/.local/bin` to `$PATH`. \ No newline at end of file diff --git a/doc/ipcam_server.md b/doc/ipcam_server.md index 3c56646..f443094 100644 --- a/doc/ipcam_server.md +++ b/doc/ipcam_server.md @@ -1,4 +1,8 @@ -config example (yaml) +# ipcam_server.py + +## Configuration + +Config example (`yaml`) ``` server: @@ -20,5 +24,10 @@ motion: logging: verbose: true + +motion_threshold: 1 +``` -``` \ No newline at end of file +## Usage + +Use provided systemd unit file. \ No newline at end of file