mzac / unifi-video-mqtt

GNU General Public License v3.0
44 stars 21 forks source link

Unable to start service with NVR in Docker container #2

Open rlust opened 5 years ago

rlust commented 5 years ago

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!

rlust commented 5 years ago

I am using ubuntu.

mzac commented 5 years ago

I just returned from vacation so I'll take a look at this soon, I have a few ideas

mzac commented 5 years ago

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.

mzac commented 5 years ago

@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:

Let me know if that works for you and if it is all good I'll add it to the official docs!

rlust commented 5 years ago

I will give it a try!

rlust commented 5 years ago

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?

mzac commented 5 years ago

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
rlust commented 5 years ago

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
mzac commented 5 years ago

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

rlust commented 5 years ago

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.

rlust commented 5 years ago

Is the above error an improper use of grep in a script?

dom404 commented 5 years ago

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"]