From d59990a506d7e8dc6ff7d3ffc62b80f4c3142190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Mon, 4 Feb 2019 21:12:05 +0100 Subject: [PATCH] :sparkles: Adds option to enable motion webcontrol (#17) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨Adds motion webcontrol * ⬆️ Upgrades motion to version 4.1.1-r1 * ⬆️ Upgrades nginx to version 1.14.2-r0 * ⬆️ Upgrades ffmpeg to version 4.0.2-r0 * 🔨 Configuration cleanup * Rename motion_api to motion_webcontrol * 📝Adds documentation for motion_webcontrol * :pencil2: Updated documentation * :pencil2: Spelling * :warning: Added warning logs --- README.md | 8 ++++++++ motioneye/Dockerfile | 2 +- motioneye/config.json | 2 ++ .../etc/cont-init.d/20-init-configuration.sh | 9 ++++++++- motioneye/rootfs/etc/cont-init.d/31-motion.sh | 19 +++++++++++++++++++ motioneye/rootfs/etc/motioneye/motion.conf | 14 ++++++++++++++ 6 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 motioneye/rootfs/etc/cont-init.d/31-motion.sh create mode 100644 motioneye/rootfs/etc/motioneye/motion.conf diff --git a/README.md b/README.md index 0d40e9b..6bd8252 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,14 @@ more severe level, e.g., `debug` also shows `info` messages. By default, the `log_level` is set to `info`, which is the recommended setting unless you are troubleshooting. +### Option: `motion_webcontrol` + +Enables the motion webcontrol endpoint running on port `7999`. + +:warning: MotionEye HTTP webcontrol **DOES NOT** support authentication +and **DOES NOT** support SSL! Enable this **ONLY** when you know what +you are doing! **NEVER, EVERY** expose this port to the outside world! + ### Option: `port` By default motionEye runs on port `8765`, this option allows you to change diff --git a/motioneye/Dockerfile b/motioneye/Dockerfile index 2057fed..9bb0291 100755 --- a/motioneye/Dockerfile +++ b/motioneye/Dockerfile @@ -58,4 +58,4 @@ LABEL \ 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" + org.label-schema.vendor="Community Hass.io Add-ons" \ No newline at end of file diff --git a/motioneye/config.json b/motioneye/config.json index 4f7f7fb..e81eb31 100755 --- a/motioneye/config.json +++ b/motioneye/config.json @@ -29,6 +29,7 @@ ], "options": { "log_level": "info", + "motion_webcontrol": false, "port": 8765, "ssl": true, "certfile": "fullchain.pem", @@ -36,6 +37,7 @@ }, "schema": { "log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)", + "motion_webcontrol": "bool", "port": "port", "ssl": "bool", "certfile": "str", diff --git a/motioneye/rootfs/etc/cont-init.d/20-init-configuration.sh b/motioneye/rootfs/etc/cont-init.d/20-init-configuration.sh index 2f20d13..e2052be 100644 --- a/motioneye/rootfs/etc/cont-init.d/20-init-configuration.sh +++ b/motioneye/rootfs/etc/cont-init.d/20-init-configuration.sh @@ -7,6 +7,13 @@ source /usr/lib/hassio-addons/base.sh if ! hass.directory_exists '/data/motioneye'; then - cp -R /etc/motioneye /data/motioneye \ + cp -R /etc/motioneye/ /data/motioneye/ \ || hass.die 'Failed to create initial motionEye configuration' fi + + +# Needed for existing installations. +if ! hass.file_exists '/data/motioneye/motion.conf'; then + cp /etc/motioneye/motion.conf /data/motioneye/motion.conf \ + || hass.die 'Failed to create initial motion configuration' +fi \ No newline at end of file diff --git a/motioneye/rootfs/etc/cont-init.d/31-motion.sh b/motioneye/rootfs/etc/cont-init.d/31-motion.sh new file mode 100644 index 0000000..451ea65 --- /dev/null +++ b/motioneye/rootfs/etc/cont-init.d/31-motion.sh @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Community Hass.io Add-ons: motionEye +# Configure motion webcontrol access +# ============================================================================== +# shellcheck disable=SC1091 +source /usr/lib/hassio-addons/base.sh + +readonly motion='/data/motioneye/motion.conf' + +if hass.config.true 'motion_webcontrol'; then + hass.log.info "Enabling motion webcontrol..." + hass.log.warning "This opens up an UNSECURE port to the outside world!" + hass.log.warning "This port has NO SSL & NO AUTHENICATION!" + hass.log.warning "YOU HAVE BEEN WARNED!" + sed -i "s/webcontrol_localhost on/webcontrol_localhost off/" "$motion" +else + sed -i "s/webcontrol_localhost off/webcontrol_localhost on/" "$motion" +fi diff --git a/motioneye/rootfs/etc/motioneye/motion.conf b/motioneye/rootfs/etc/motioneye/motion.conf new file mode 100644 index 0000000..57d590e --- /dev/null +++ b/motioneye/rootfs/etc/motioneye/motion.conf @@ -0,0 +1,14 @@ +# @enabled on +# @show_advanced off +# @normal_password +# @admin_username admin +# @admin_password +# @normal_username user + +webcontrol_localhost on + +thread thread-1.conf +webcontrol_html_output off +webcontrol_port 7999 +setup_mode off +webcontrol_parms 2