Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions openthread_border_router/0003-ha-web-ui-customizations.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
diff --git a/src/web/web-service/frontend/index.html b/src/web/web-service/frontend/index.html
index cb052f26..992f03d6 100644
--- a/src/web/web-service/frontend/index.html
+++ b/src/web/web-service/frontend/index.html
@@ -89,7 +89,7 @@
</header>
<nav class="demo-navigation mdl-navigation mdl-color--blue-grey-800">
<md-list flex>
- <md-list-item md-ink-ripple class="mdl-navigation__link" ng-repeat="item in menu" ng-click="showPanels($index)" layout="row">
+ <md-list-item md-ink-ripple class="mdl-navigation__link" ng-repeat="item in menu" ng-click="showPanels($index)" ng-if="!item.hidden" layout="row">
<div><i class="mdl-color-text--blue-grey-400 material-icons" role="presentation">{{item.icon}}</i>{{item.title}}
</div>
</md-list-item>
@@ -130,7 +130,6 @@
<th>PAN ID</th>
<th>channel</th>
<th>Hardware Address</th>
- <th>Action</th>

</tr>
</thead>
@@ -142,9 +141,6 @@
<td>{{item.pi}}</td>
<td>{{item.ch}}</td>
<td>{{item.ha}}</td>
- <td>
- <button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-button show-modal" ng-click="showJoinDialog($event, $index, item)">Join</button>
- </td>
</tr>
</tbody>
</table>
diff --git a/src/web/web-service/frontend/res/js/app.js b/src/web/web-service/frontend/res/js/app.js
index e8453f6c..e0645f83 100644
--- a/src/web/web-service/frontend/res/js/app.js
+++ b/src/web/web-service/frontend/res/js/app.js
@@ -57,7 +57,7 @@
show: true,
},
{
- title: 'Join',
+ title: 'Scan',
icon: 'add_circle_outline',
show: false,
},
@@ -65,6 +65,7 @@
title: 'Form',
icon: 'open_in_new',
show: false,
+ hidden: true,
},
{
title: 'Status',
@@ -124,7 +125,7 @@
};
$scope.showPanels = async function(index) {
$scope.headerTitle = $scope.menu[index].title;
- for (var i = 0; i < 7; i++) {
+ for (var i = 0; i < $scope.menu.length; i++) {
$scope.menu[i].show = false;
}
$scope.menu[index].show = true;
@@ -1226,3 +1227,15 @@
}
};
})();
+
+// Use relative URLs for ingress compatibility
+angular.module('StarterApp').config(['$httpProvider', function($httpProvider) {
+ $httpProvider.interceptors.push(function() {
+ return {
+ request: function(config) {
+ config.url = config.url.replace(/^http:\/\/[^/]+\//, '');
+ return config;
+ }
+ };
+ });
+}]);
2 changes: 1 addition & 1 deletion openthread_border_router/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Installation

Follow these steps to get the app (formerly knowon as add-on) installed on your system:
Follow these steps to get the app (formerly known as add-on) installed on your system:

1. In Home Assistant, go to **Settings** > **Apps** > **Install app**.
2. Select the top right menu and **Repository**.
Expand Down
6 changes: 6 additions & 0 deletions openthread_border_router/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ENV DOCKER=1


COPY openthread-core-ha-config-posix.h /usr/src/
COPY 0003-ha-web-ui-customizations.patch /usr/src/

WORKDIR /usr/src
RUN \
Expand All @@ -37,6 +38,7 @@ WORKDIR /usr/src/ot-br-posix
RUN \
set -x \
&& mv /usr/src/openthread-core-ha-config-posix.h /usr/src/ot-br-posix/third_party/openthread/repo/ \
&& patch -p1 < /usr/src/0003-ha-web-ui-customizations.patch \
&& ./script/cmake-build \
-DBUILD_TESTING=OFF \
-DCMAKE_INSTALL_PREFIX=/opt/otbr-beta \
Expand Down Expand Up @@ -85,6 +87,7 @@ ENV DOCKER=1
COPY openthread-core-ha-config-posix.h /usr/src/
COPY 0001-channel-monitor-disable-by-default.patch /usr/src/
COPY 0002-spinel-Clear-source-match-tables-before-restoring.patch /usr/src/
COPY 0003-ha-web-ui-customizations.patch /usr/src/

WORKDIR /usr/src
RUN \
Expand All @@ -111,6 +114,7 @@ RUN \
&& patch -p1 < /usr/src/0001-channel-monitor-disable-by-default.patch \
&& patch -p1 < /usr/src/0002-spinel-Clear-source-match-tables-before-restoring.patch \
) \
&& patch -p1 < /usr/src/0003-ha-web-ui-customizations.patch \
&& ./script/cmake-build \
-DBUILD_TESTING=OFF \
-DCMAKE_INSTALL_PREFIX=/opt/otbr-stable \
Expand Down Expand Up @@ -167,6 +171,7 @@ RUN \
libncurses6 \
libprotobuf-lite32 \
libjsoncpp26 \
nginx \
&& pip install --break-system-packages --no-cache-dir \
universal-silabs-flasher==${UNIVERSAL_SILABS_FLASHER_VERSION} \
serialx==${SERIALX_VERSION} \
Expand All @@ -183,6 +188,7 @@ COPY --from=otbr-stable-builder /opt/otbr-stable /opt/otbr-stable
COPY --from=otbr-stable-builder /usr/sbin/mdnsd /opt/otbr-stable/sbin/mdnsd
COPY --from=otbr-stable-builder /usr/lib/libdns_sd.so /usr/lib/libdns_sd.so
COPY --from=otbr-stable-builder /usr/lib/libdns_sd.so.1 /usr/lib/libdns_sd.so.1

COPY rootfs /

ENV \
Expand Down
4 changes: 3 additions & 1 deletion openthread_border_router/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: 2.16.0
slug: openthread_border_router
name: OpenThread Border Router
description: OpenThread Border Router add-on
description: OpenThread Border Router
url: >-
https://github.com/home-assistant/addons/tree/master/openthread_border_router
arch:
Expand All @@ -23,6 +23,8 @@ privileged:
devices:
- /dev/net/tun
image: homeassistant/{arch}-addon-otbr
ingress: true
ingress_port: 8080
init: false
options:
device: null
Expand Down
33 changes: 33 additions & 0 deletions openthread_border_router/rootfs/etc/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
worker_processes 1;
pid /tmp/nginx.pid;
error_log /dev/stdout info;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;

server {
listen 8080;

# Proxy REST API requests to otbr-agent
location /api/ {
proxy_pass http://ADDON_IP:8081;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}

# Proxy everything else to otbr-web
location / {
proxy_pass http://127.0.0.1:8082;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
13 changes: 13 additions & 0 deletions openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/with-contenv bashio
# vim: ft=bash
# shellcheck shell=bash
# ==============================================================================
# Start nginx reverse proxy for OTBR web interface
# ==============================================================================
bashio::log.info "Starting nginx..."

# REST API listens on app IP, so we need to know it for proxying
addon_ip="$(bashio::addon.ip_address)"
sed "s/ADDON_IP/${addon_ip}/g" /etc/nginx/nginx.conf > /tmp/nginx.conf

exec nginx -g "daemon off;" -c /tmp/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@
# Start OpenThread BorderRouter web interface
# ==============================================================================
bashio::log.info "Starting otbr-web..."
declare otbr_web_port

otbr_web_port="$(bashio::addon.port 8080)"

exec stdbuf -oL /usr/sbin/otbr-web -I wpan0 -d6 -s -p "${otbr_web_port}"
exec stdbuf -oL /usr/sbin/otbr-web -I wpan0 -d6 -s -p 8082 -a 127.0.0.1
14 changes: 7 additions & 7 deletions openthread_border_router/rootfs/etc/s6-overlay/scripts/banner.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Community Add-on: Base Images
# Displays a simple add-on banner on startup
# Home Assistant Community App: Base Images
# Displays a simple app banner on startup
# ==============================================================================
if bashio::supervisor.ping; then
bashio::log.blue \
'-----------------------------------------------------------'
bashio::log.blue " Add-on: $(bashio::addon.name)"
bashio::log.blue " App: $(bashio::addon.name)"
bashio::log.blue " $(bashio::addon.description)"
bashio::log.blue \
'-----------------------------------------------------------'

bashio::log.blue " Add-on version: $(bashio::addon.version)"
bashio::log.blue " App version: $(bashio::addon.version)"
if bashio::var.true "$(bashio::addon.update_available)"; then
bashio::log.magenta ' There is an update available for this add-on!'
bashio::log.magenta ' There is an update available for this app!'
bashio::log.magenta \
" Latest add-on version: $(bashio::addon.version_latest)"
" Latest app version: $(bashio::addon.version_latest)"
bashio::log.magenta ' Please consider upgrading as soon as possible.'
else
bashio::log.green ' You are running the latest version of this add-on.'
bashio::log.green ' You are running the latest version of this app.'
fi

bashio::log.blue " System: $(bashio::info.operating_system)" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ else
ln -sf "/opt/otbr-stable/sbin/mdnsd" /usr/sbin/mdnsd
fi

# ==============================================================================
# Disable OTBR Web if necessary ports are not exposed
# ==============================================================================

if bashio::var.has_value "$(bashio::addon.port 8080)" \
&& bashio::var.has_value "$(bashio::addon.port 8081)"; then
bashio::log.info "Web UI and REST API port are exposed, starting otbr-web."
else
rm /etc/s6-overlay/s6-rc.d/user/contents.d/otbr-web
bashio::log.info "The otbr-web is disabled."
fi

# ==============================================================================
# Enable socat-otbr-tcp service if needed
# ==============================================================================
Expand Down