Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Unable to start service with NVR in Docker container #2

Open
rlust opened this issue Dec 5, 2018 · 13 comments
Open

Unable to start service with NVR in Docker container #2

rlust opened this issue Dec 5, 2018 · 13 comments

Comments

@rlust
Copy link

rlust commented Dec 5, 2018

No description provided.

@rlust
Copy link
Author

rlust commented Dec 5, 2018

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
Copy link
Author

rlust commented Dec 5, 2018

I am using ubuntu.

@mzac
Copy link
Owner

mzac commented Dec 13, 2018

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

@mzac
Copy link
Owner

mzac commented Jan 4, 2019

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 mzac changed the title Unable to start servic Unable to start service with NVR in Docker container Jan 4, 2019
@mzac
Copy link
Owner

mzac commented Jan 4, 2019

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

@rlust
Copy link
Author

rlust commented Jan 17, 2019

I will give it a try!

@rlust
Copy link
Author

rlust commented Jan 17, 2019

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
Copy link
Owner

mzac commented Jan 17, 2019

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
Copy link
Author

rlust commented Jan 17, 2019

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
Copy link
Owner

mzac commented Jan 18, 2019

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
Copy link
Author

rlust commented Jan 21, 2019

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
Copy link
Author

rlust commented Jan 30, 2019

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

@dom404
Copy link

dom404 commented Mar 1, 2019

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

chelming pushed a commit to chelming/unifi-video-mqtt that referenced this issue Mar 23, 2019
Fixes mzac#2 mzac#5 mzac#6 

based on your Dockerfile, `grep -n1` isn't supported so I removed the -n1. I commented out all the variables at the top so they can be passed in with docker env vars instead.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants