diff --git a/vlc/CHANGELOG.md b/vlc/CHANGELOG.md new file mode 100644 index 0000000..931929c --- /dev/null +++ b/vlc/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 0.1.0 + +- Inital release diff --git a/vlc/DOCS.md b/vlc/DOCS.md new file mode 100644 index 0000000..928e8a2 --- /dev/null +++ b/vlc/DOCS.md @@ -0,0 +1,40 @@ +# Home Assistant Add-on: VLC + +## Installation + +Follow these steps to get the add-on installed on your system: + +1. Navigate in your Home Assistant frontend to **Supervisor** -> **Add-on Store**. +2. Find the "VLC" add-on and click it. +3. Click on the "INSTALL" button. + +## How to use + +1. Start the add-on. +2. Add the VLC Telnet integration to Home Assistant, see documentation: + + + +## Configuration + +Add-on configuration: + +```yaml +``` + +## Support + +Got questions? + +You have several options to get them answered: + +- The [Home Assistant Discord Chat Server][discord]. +- The Home Assistant [Community Forum][forum]. +- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit] + +In case you've found a bug, please [open an issue on our GitHub][issue]. + +[discord]: https://discord.gg/c5DvZ4e +[forum]: https://community.home-assistant.io +[issue]: https://github.com/home-assistant/hassio-addons/issues +[reddit]: https://reddit.com/r/homeassistant diff --git a/vlc/Dockerfile b/vlc/Dockerfile new file mode 100644 index 0000000..45c5f2c --- /dev/null +++ b/vlc/Dockerfile @@ -0,0 +1,16 @@ +ARG BUILD_FROM +FROM ${BUILD_FROM} + +# Install Z-Wave JS +WORKDIR /usr/src +RUN \ + set -x \ + && apk add --no-cache \ + nginx \ + pwgen \ + vlc \ + && sed -i 's/geteuid/getppid/' /usr/bin/vlc \ + && sed -i '197s#.*# dir = dir == undefined ? "file:///media" : dir;#' /usr/share/vlc/lua/http/js/controllers.js + +WORKDIR / +COPY rootfs / diff --git a/vlc/README.md b/vlc/README.md new file mode 100644 index 0000000..eec7809 --- /dev/null +++ b/vlc/README.md @@ -0,0 +1,12 @@ +# Home Assistant Add-on: VLC + +Allow Home Assistant to use your local device as Media Player. + +![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports i386 Architecture][i386-shield] + + +[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg +[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg +[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg +[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg +[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg diff --git a/vlc/build.json b/vlc/build.json new file mode 100644 index 0000000..6133383 --- /dev/null +++ b/vlc/build.json @@ -0,0 +1,8 @@ +{ + "build_from": { + "amd64": "homeassistant/amd64-base:3.13", + "i386": "homeassistant/i386-base:3.13", + "armv7": "homeassistant/armv7-base:3.13", + "aarch64": "homeassistant/aarch64-base:3.13" + } +} diff --git a/vlc/config.json b/vlc/config.json new file mode 100644 index 0000000..be31bc3 --- /dev/null +++ b/vlc/config.json @@ -0,0 +1,20 @@ +{ + "name": "VLC", + "version": "0.1.0", + "slug": "vlc", + "description": "Turn you device into a Media Player with VLC", + "arch": ["amd64", "i386", "armv7", "aarch64"], + "url": "https://github.com/home-assistant/hassio-addons/tree/master/vlc", + "startup": "services", + "init": false, + "stage": "experimental", + "map": ["share:ro", "media:ro"], + "homeassistant": "2021.3.0.dev20210216", + "ingress": true, + "panel_icon": "mdi:vlc", + "discovery": ["vlc_telnet"], + "audio": true, + "options": {}, + "schema": false, + "image": "homeassistant/{arch}-addon-vlc" +} diff --git a/vlc/icon.png b/vlc/icon.png new file mode 100644 index 0000000..76d0409 Binary files /dev/null and b/vlc/icon.png differ diff --git a/vlc/logo.png b/vlc/logo.png new file mode 100644 index 0000000..9605b17 Binary files /dev/null and b/vlc/logo.png differ diff --git a/vlc/rootfs/etc/cont-init.d/ingress.sh b/vlc/rootfs/etc/cont-init.d/ingress.sh new file mode 100644 index 0000000..34feefd --- /dev/null +++ b/vlc/rootfs/etc/cont-init.d/ingress.sh @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Prepair VLC for ingress access +# ============================================================================== + +# Generate NGINX config +bashio::var.json \ + supervisor_ip "$(getent hosts supervisor | awk '{ print $1 }' | head -1)" \ + | tempio \ + -template /usr/share/tempio/nginx.conf \ + -out /etc/nginx/nginx.conf diff --git a/vlc/rootfs/etc/cont-init.d/secret.sh b/vlc/rootfs/etc/cont-init.d/secret.sh new file mode 100644 index 0000000..e44da81 --- /dev/null +++ b/vlc/rootfs/etc/cont-init.d/secret.sh @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Create VLC secret +# ============================================================================== + +if bashio::fs.file_exists /data/secret; then + bashio::exit.ok +fi + +# Generate password +pwgen 64 1 > /data/secret diff --git a/vlc/rootfs/etc/services.d/nginx/finish b/vlc/rootfs/etc/services.d/nginx/finish new file mode 100644 index 0000000..a29ced9 --- /dev/null +++ b/vlc/rootfs/etc/services.d/nginx/finish @@ -0,0 +1,8 @@ +#!/usr/bin/execlineb -S1 +# ============================================================================== +# Take down the S6 supervision tree based on service exit code +# ============================================================================== +if { s6-test ${1} -ne 0 } +if { s6-test ${1} -ne 256 } + +s6-svscanctl -t /var/run/s6/services diff --git a/vlc/rootfs/etc/services.d/nginx/run b/vlc/rootfs/etc/services.d/nginx/run new file mode 100644 index 0000000..bd6f1e8 --- /dev/null +++ b/vlc/rootfs/etc/services.d/nginx/run @@ -0,0 +1,5 @@ +#!/usr/bin/env bashio +# ============================================================================== +# Start NGINX service +# ============================================================================== +exec nginx diff --git a/vlc/rootfs/etc/services.d/vlc/discovery b/vlc/rootfs/etc/services.d/vlc/discovery new file mode 100755 index 0000000..ad4af05 --- /dev/null +++ b/vlc/rootfs/etc/services.d/vlc/discovery @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Send vlc_telnet discovery information to Home Assistant +# ============================================================================== +declare ha_config + +# Prepare discovery payload +ha_config=$(\ + bashio::var.json \ + host "$(hostname)" \ + port "^3000" \ + password "$(cat /data/secret)" \ +) + +if bashio::discovery "vlc_telnet" "${ha_config}" > /dev/null; then + bashio::log.info "Successfully send discovery information to Home Assistant." +else + bashio::log.error "Discovery message to Home Assistant failed!" +fi diff --git a/vlc/rootfs/etc/services.d/vlc/finish b/vlc/rootfs/etc/services.d/vlc/finish new file mode 100644 index 0000000..d886e9f --- /dev/null +++ b/vlc/rootfs/etc/services.d/vlc/finish @@ -0,0 +1,8 @@ +#!/usr/bin/execlineb -S1 +# ============================================================================== +# Take down the S6 supervision tree when Z-Wave JS fails +# ============================================================================== +if { s6-test ${1} -ne 0 } +if { s6-test ${1} -ne 256 } + +s6-svscanctl -t /var/run/s6/services diff --git a/vlc/rootfs/etc/services.d/vlc/run b/vlc/rootfs/etc/services.d/vlc/run new file mode 100644 index 0000000..90d2c0e --- /dev/null +++ b/vlc/rootfs/etc/services.d/vlc/run @@ -0,0 +1,11 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Start Z-Wave JS service for Z-Wave radio +# ============================================================================== +readonly PASSWORD="$(cat /data/secret)" + +# Send out discovery information to Home Assistant +./discovery & + +# Run daemon +exec cvlc -I http --extraintf telnet --http-host 127.0.0.1 --http-password "INGRESS" --telnet-password "${PASSWORD}" --aout=pulse diff --git a/vlc/rootfs/usr/share/tempio/nginx.conf b/vlc/rootfs/usr/share/tempio/nginx.conf new file mode 100644 index 0000000..8dbaac4 --- /dev/null +++ b/vlc/rootfs/usr/share/tempio/nginx.conf @@ -0,0 +1,55 @@ +worker_processes 1; +pid /var/run/nginx.pid; +error_log /dev/stdout info; +daemon off; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + proxy_read_timeout 1200; + gzip on; + gzip_disable "msie6"; + + upstream backend { + ip_hash; + server 127.0.0.1:8080; + } + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + # Ingress + server { + listen 8099 default_server; + listen [::]:8099 default_server; + + allow {{ .supervisor_ip }}; + deny all; + + server_name _; + access_log /dev/stdout combined; + + client_max_body_size 4G; + keepalive_timeout 5; + + root /dev/null; + + location / { + proxy_redirect off; + proxy_pass http://backend; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Authorization "Basic OklOR1JFU1M="; + } + } +}