🎉 Initial add-on code

This commit is contained in:
Franck Nijhof 2018-10-05 23:58:22 +02:00
parent 9d83a642f0
commit af89341da0
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3
17 changed files with 518 additions and 0 deletions

73
motioneye/.README.j2 Normal file
View file

@ -0,0 +1,73 @@
# Community Hass.io Add-ons: motionEye
[![Release][release-shield]][release] ![Project Stage][project-stage-shield] ![Project Maintenance][maintenance-shield]
[![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum]
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
[![Support my work on Patreon][patreon-shield]][patreon]
Simple, elegant and feature-rich CCTV/NVR for your camera's.
## About
Lorem ipsum
[Click here for the full documentation][docs]
![HADashboard screenshot][screenshot]
{% if channel == "edge" %}
## WARNING! THIS IS AN EDGE VERSION!
This Hass.io Add-ons repository contains edge builds of add-ons. Edge builds
add-ons are based upon the latest development version.
- They may not work at all.
- They might stop working at any time.
- They could have a negative impact on your system.
This repository was created for:
- Anybody willing to test.
- Anybody interested in trying out upcoming add-ons or add-on features.
- Developers.
If you are more interested in stable releases of our add-ons:
<https://github.com/hassio-addons/repository>
{% endif %}
{% if channel == "beta" %}
## WARNING! THIS IS A BETA VERSION!
This Hass.io Add-ons repository contains beta releases of add-ons.
- They might stop working at any time.
- They could have a negative impact on your system.
This repository was created for:
- Anybody willing to test.
- Anybody interested in trying out upcoming add-ons or add-on features.
If you are more interested in stable releases of our add-ons:
<https://github.com/hassio-addons/repository>
{% endif %}
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg
[buymeacoffee]: https://www.buymeacoffee.com/frenck
[discord-shield]: https://img.shields.io/discord/478094546522079232.svg
[discord]: https://discord.me/hassioaddons
[docs]: {{ repo }}/blob/{{ version }}/README.md
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg
[forum]: https://community.home-assistant.io/t/community-hass-io-add-on-motioneye/41261?u=frenck
[maintenance-shield]: https://img.shields.io/maintenance/yes/2018.svg
[patreon-shield]: https://www.frenck.nl/images/patreon.png
[patreon]: https://www.patreon.com/frenck
[project-stage-shield]: https://img.shields.io/badge/project%20stage-production%20ready-brightgreen.svg
[release-shield]: https://img.shields.io/badge/version-{{ version }}-blue.svg
[release]: {{ repo }}/tree/{{ version }}
[screenshot]: https://github.com/hassio-addons/addon-motioneye/raw/master/images/screenshot.png

49
motioneye/Dockerfile Executable file
View file

@ -0,0 +1,49 @@
ARG BUILD_FROM=hassioaddons/base:2.3.0
# hadolint ignore=DL3006
FROM ${BUILD_FROM}
# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Setup base
RUN \
apk add --no-cache \
cifs-utils=6.8-r0 \
ffmpeg=3.4.4-r1 \
motion@edge=4.1.1-r0 \
nginx=1.14.0-r1 \
py2-curl=7.43.0-r5 \
py2-pillow=4.3.0-r0 \
py2-pip=10.0.1-r0 \
python2=2.7.15-r1 \
v4l-utils=1.12.6-r1 \
\
&& pip2 install \
motioneye==0.39.3
# Copy root filesystem
COPY rootfs /
# Build arugments
ARG BUILD_ARCH
ARG BUILD_DATE
ARG BUILD_REF
ARG BUILD_VERSION
# Labels
LABEL \
io.hass.name="motionEye" \
io.hass.description="Simple, elegant and feature-rich CCTV/NVR for your camera's" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="Franck Nijhof <frenck@addons.community>" \
org.label-schema.description="Simple, elegant and feature-rich CCTV/NVR for your camera's" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="motionEye" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://community.home-assistant.io/?u=frenck" \
org.label-schema.usage="https://github.com/hassio-addons/addon-motioneye/tree/master/README.md" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-url="https://github.com/hassio-addons/addon-motioneye" \
org.label-schema.vendor="Community Hass.io Add-ons"

9
motioneye/build.json Normal file
View file

@ -0,0 +1,9 @@
{
"build_from": {
"aarch64": "hassioaddons/base-aarch64:2.3.0",
"amd64": "hassioaddons/base-amd64:2.3.0",
"armhf": "hassioaddons/base-armhf:2.3.0",
"i386": "hassioaddons/base-i386:2.3.0"
},
"args": {}
}

44
motioneye/config.json Executable file
View file

@ -0,0 +1,44 @@
{
"name": "motionEye",
"version": "dev",
"slug": "motioneye",
"description": "Simple, elegant and feature-rich CCTV/NVR for your camera's",
"url": "https://community.home-assistant.io/?u=frenck",
"webui": "[PROTO:ssl]://[HOST]:[PORT:8765]",
"startup": "application",
"arch": [
"aarch64",
"amd64",
"armhf",
"i386"
],
"boot": "auto",
"hassio_api": true,
"hassio_role": "default",
"homeassistant_api": false,
"host_network": true,
"map": [
"config",
"share:rw",
"ssl"
],
"options": {
"log_level": "info",
"port": 8765,
"ssl": true,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"ipv6": false
},
"schema": {
"log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)",
"port": "port",
"ssl": "bool",
"certfile": "str",
"keyfile": "str",
"ipv6": "bool"
},
"environment": {
"LOG_FORMAT": "{LEVEL}: {MESSAGE}"
}
}

BIN
motioneye/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
motioneye/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

@ -0,0 +1,26 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: motionEye
# This files check if all user configuration requirements are met
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
# Check SSL requirements, if enabled
if hass.config.true 'ssl'; then
if ! hass.config.has_value 'certfile'; then
hass.die 'SSL is enabled, but no certfile was specified'
fi
if ! hass.config.has_value 'keyfile'; then
hass.die 'SSL is enabled, but no keyfile was specified'
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'certfile')"; then
hass.die 'The configured certfile is not found'
fi
if ! hass.file_exists "/ssl/$(hass.config.get 'keyfile')"; then
hass.die 'The configured keyfile is not found'
fi
fi

View file

@ -0,0 +1,12 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: motionEye
# Creates initial motionEye configuration in case it is non-existing
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
if ! hass.directory_exists '/data/motioneye'; then
cp -R /etc/motioneye /data/motioneye \
|| hass.die 'Failed to create initial motionEye configuration'
fi

View file

@ -0,0 +1,12 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: motionEye
# Creates initial motionEye media folder in case it is non-existing
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
if ! hass.directory_exists '/share/motioneye'; then
mkdir -p /share/motioneye \
|| hass.die 'Failed to create initial motionEye media folder'
fi

View file

@ -0,0 +1,29 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: motionEye
# Configures NGINX for use with motionEye
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
declare certfile
declare keyfile
declare port
if hass.config.true 'ssl'; then
rm /etc/nginx/nginx.conf
mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf
certfile=$(hass.config.get 'certfile')
keyfile=$(hass.config.get 'keyfile')
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
fi
port=$(hass.config.get 'port')
sed -i "s/%%port%%/${port}/g" /etc/nginx/nginx.conf
if ! hass.config.true 'ipv6'; then
sed -i '/listen \[::\].*/ d' /etc/nginx/nginx.conf
fi

View file

@ -0,0 +1,97 @@
# path to the configuration directory (must be writable by motionEye)
conf_path /data/motioneye
# path to the directory where pid files go (must be writable by motionEye)
run_path /var/run
# path to the directory where log files go (must be writable by motionEye)
log_path /var/log
# default output path for media files (must be writable by motionEye)
media_path /share/motioneye
# the log level (use quiet, error, warning, info or debug)
log_level info
# the IP address to listen on
# (0.0.0.0 for all interfaces, 127.0.0.1 for localhost)
listen 127.0.0.1
# the TCP port to listen on
port 28765
# path to the motion binary to use (automatically detected if commented)
#motion_binary /usr/bin/motion
# whether motion HTTP control interface listens on
# localhost or on all interfaces
motion_control_localhost true
# the TCP port that motion HTTP control interface listens on
motion_control_port 7999
# interval in seconds at which motionEye checks if motion is running
motion_check_interval 10
# whether to restart the motion daemon when an error occurs while communicating with it
motion_restart_on_errors false
# interval in seconds at which motionEye checks the SMB mounts
mount_check_interval 300
# interval in seconds at which the janitor is called
# to remove old pictures and movies
cleanup_interval 43200
# timeout in seconds to wait for response from a remote motionEye server
remote_request_timeout 10
# timeout in seconds to wait for mjpg data from the motion daemon
mjpg_client_timeout 10
# timeout in seconds after which an idle mjpg client is removed
# (set to 0 to disable)
mjpg_client_idle_timeout 10
# enable SMB shares (requires motionEye to run as root)
smb_shares true
# the directory where the SMB mount points will be created
smb_mount_root /media
# path to the wpa_supplicant.conf file
# (enable this to configure wifi settings from the UI)
#wpa_supplicant_conf /etc/wpa_supplicant.conf
# path to the localtime file
# (enable this to configure the system time zone from the UI)
#local_time_file /etc/localtime
# enables shutdown and rebooting after changing system settings
# (such as wifi settings or time zone)
enable_reboot false
# timeout in seconds to use when talking to the SMTP server
smtp_timeout 60
# timeout in seconds to wait for media files list
list_media_timeout 120
# timeout in seconds to wait for media files list, when sending emails
list_media_timeout_email 10
# timeout in seconds to wait for zip file creation
zip_timeout 500
# timeout in seconds to wait for timelapse creation
timelapse_timeout 500
# enable adding and removing cameras from UI
add_remove_cameras true
# enables HTTP basic authentication scheme (in addition to, not instead of the signature mechanism)
http_basic_auth false
# overrides the hostname (useful if motionEye runs behind a reverse proxy)
# server_name motionEye

View file

@ -0,0 +1,70 @@
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream motioneye {
ip_hash;
server 127.0.0.1:28765;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
server_name hassio.local;
listen %%port%% default_server ssl;
listen [::]:%%port%% default_server ssl;
root /dev/null;
ssl_certificate /ssl/%%certfile%%;
ssl_certificate_key /ssl/%%keyfile%%;
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA;
ssl_ecdh_curve secp384r1;
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
location / {
proxy_redirect off;
proxy_pass http://motioneye;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Authorization "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_hide_header X-Frame-Options;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
}
}
}

View file

@ -0,0 +1,51 @@
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream motioneye {
ip_hash;
server 127.0.0.1:28765;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
server_name hassio.local;
listen %%port%% default_server;
listen [::]:%%port%% default_server;
root /dev/null;
location / {
proxy_redirect off;
proxy_pass http://motioneye;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Authorization "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_hide_header X-Frame-Options;
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
}
}
}

View file

@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Community Hass.io Add-ons: motionEye
# Take down the S6 supervision tree when motionEye fails
# ==============================================================================
if -n { s6-test $# -ne 0 }
if -n { s6-test ${1} -eq 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -0,0 +1,19 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: motionEye
# Runs the motionEye
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
declare -a options
options+=(-c /data/motioneye/motioneye.conf)
# Enable debug mode
if hass.debug; then
options+=(-d)
fi
# Run the motionEye
exec meyectl startserver "${options[@]}"

View file

@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Community Hass.io Add-ons: motionEye
# Take down the S6 supervision tree when Nginx fails
# ==============================================================================
if -n { s6-test $# -ne 0 }
if -n { s6-test ${1} -eq 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -0,0 +1,9 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# Community Hass.io Add-ons: motionEye
# Runs the Nginx daemon
# ==============================================================================
# shellcheck disable=SC1091
source /usr/lib/hassio-addons/base.sh
exec nginx -g "daemon off;"