Open rlust opened 5 years ago
I am using ubuntu.
I just returned from vacation so I'll take a look at this soon, I have a few ideas
Hmm.. Thought about this, does your Unifi docker container have the log directory configured as an external volume? If so, then maybe we can build another docker container with this script that can watch the same log file. Shouldn't be that hard to do, I'll see if I can get it working.
@rlust I've added a Dockerfile that you can try. You will need to build the container on your docker host and then specify the volume where your log file is.
Here is the way I suggest you test this out:
Clone the repo into a directory
Edit the variables in the unifi-video-mqtt.sh file in the directory that you cloned the repo as this file will be copied into /usr/local/bin inside the container
Build the docker image:
docker build . -t unifi-video-mqtt
Run the container in interactive mode specifying your log volume and then do the Harlem Shake in front of your camera to trigger the motion detection:
docker run -it -v /path/to/unifi/log/volume/:/var/log/unifi-video unifi-video-mqtt
If that all works, then you can run this container in the background:
docker run -d --name unifi-video-mqtt --restart always -v /path/to/unifi/log/volume/:/var/log/unifi-video unifi-video-mqtt
Let me know if that works for you and if it is all good I'll add it to the official docs!
I will give it a try!
Thanks for the help! I do not think this will work as my Unifi-Video is running on UNRAID as a Docker, and I cannot figure how to get access to the log file for this new docker container. I am not that good with docker. I cannot figure out how to enter the path to the Unifi log file. Ideas?
When you build or re-build your unifi video container, you would have to add a volume like this so the mqtt container can access the same log file:
-v /path/to/unifi/log/volume/:/var/log/unifi-video
Giving it a try. Not sure if I did this right. Here is the volume mapping in Portainer.
Host/volume | Path in container |
---|---|
/mnt/cache/appdata/unifi-video | /var/lib/unifi-video |
/mnt/user/UnfiVideoShareForStorage | /var/lib/unifi-video/videos |
/path/to/unifi/log/volume | /var/log/unifi-video |
right, the issue is you should probably put something like this for your setup
-v /mnt/user/UnifiVideoLogs:/var/log/unifi-video
as what I put before was an example
I got the docker running! Here are the messages in the log.
Setting up watches. Watches established. /var/log/unifi-video/motion.log MODIFY grep: unrecognized option: 1 BusyBox v1.28.4 (2018-12-06 15:13:21 UTC) multi-call binary.
Usage: grep [-HhnlLoqvsriwFE] [-m N] [-A/B/C N] PATTERN/-e PATTERN.../-f FILE [FILE]...
Search for PATTERN in FILEs (or stdin)
-H Add 'filename:' prefix -h Do not add 'filename:' prefix -n Add 'line_no:' prefix -l Show only names of files that match -L Show only names of files that don't match -c Show only count of matching lines -o Show only the matching part of line -q Quiet. Return 0 if PATTERN is found, 1 otherwise -v Select non-matching lines -s Suppress open and read errors -r Recurse -i Ignore case -w Match whole words only -x Match whole lines only -F PATTERN is a literal (not regexp) -E PATTERN is an extended regexp -m N Match up to N times per file -A N Print N lines of trailing context -B N Print N lines of leading context -C N Same as '-A N -B N' -e PTRN Pattern to match -f FILE Read pattern from file Setting up watches. Watches established.
Is the above error an improper use of grep in a script?
edit out the -1n after grep
I changed the Docker file to the following but I was after it doing a few more things..
FROM ubuntu:latest
MAINTAINER Me
# Update package cache
RUN apt-get update -y
# Install required packages
RUN apt-get install \
apt-utils \
net-tools \
bash \
inotify-tools \
mosquitto-clients \
-y
# Get script and move to the right place
COPY ./unifi-video-mqtt.sh /usr/local/bin
# Make script executable
RUN chmod a+x /usr/local/bin/unifi-video-mqtt.sh
# Make unifi log directory
RUN mkdir -p /var/log/unifi-video
# Start log monitoring
ENTRYPOINT ["/usr/local/bin/unifi-video-mqtt.sh"]
This is a great script. I have it running on a NVR docker container but am unable to start the service.
Any info on getting the service portion to install would be helpful!