mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 13:14:21 +01:00
Support svr host (#1863)
* Revert "Revert "Support svr host (#1853)" (#1860)"
This reverts commit de23c02c7c.
* Fix Apparmor
* Update apparmor.txt
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.4
|
||||||
|
|
||||||
|
- Adds support for srv-host records
|
||||||
|
|
||||||
## 1.3
|
## 1.3
|
||||||
|
|
||||||
- Rewrites add-on onto Bashio
|
- Rewrites add-on onto Bashio
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ forwards:
|
|||||||
hosts:
|
hosts:
|
||||||
- host: home.mydomain.io
|
- host: home.mydomain.io
|
||||||
ip: 192.168.1.10
|
ip: 192.168.1.10
|
||||||
|
services:
|
||||||
|
- srv: _ldap._tcp.pdc._msdcs.mydomain.io
|
||||||
|
host: dc.mydomain.io
|
||||||
|
port: 389
|
||||||
|
priority: 0
|
||||||
|
weight: 100
|
||||||
```
|
```
|
||||||
|
|
||||||
### Option: `defaults` (required)
|
### Option: `defaults` (required)
|
||||||
@@ -76,6 +82,30 @@ The hostname or domainname to resolve locally.
|
|||||||
|
|
||||||
The IP address Dnsmasq should respond with in its DNS answer.
|
The IP address Dnsmasq should respond with in its DNS answer.
|
||||||
|
|
||||||
|
### Option: `services` (optional)
|
||||||
|
|
||||||
|
This option allows you to provide srv-host records.
|
||||||
|
|
||||||
|
#### Option: `services.srv`
|
||||||
|
|
||||||
|
The service to resolve.
|
||||||
|
|
||||||
|
#### Option: `services.host`
|
||||||
|
|
||||||
|
The host that contain the service.
|
||||||
|
|
||||||
|
#### Option: `services.port`
|
||||||
|
|
||||||
|
The port number for the service.
|
||||||
|
|
||||||
|
#### Option: `services.priority`
|
||||||
|
|
||||||
|
The priority for the service.
|
||||||
|
|
||||||
|
#### Option: `services.weight`
|
||||||
|
|
||||||
|
The weight for the service.
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
Got questions?
|
Got questions?
|
||||||
|
|||||||
@@ -8,7 +8,5 @@ ENV LANG C.UTF-8
|
|||||||
RUN apk add --no-cache dnsmasq
|
RUN apk add --no-cache dnsmasq
|
||||||
|
|
||||||
# Copy data
|
# Copy data
|
||||||
COPY data/run.sh /
|
COPY rootfs /
|
||||||
COPY data/dnsmasq.conf /etc/
|
|
||||||
|
|
||||||
CMD [ "/run.sh" ]
|
|
||||||
|
|||||||
@@ -2,29 +2,38 @@
|
|||||||
|
|
||||||
profile dnsmasq flags=(attach_disconnected,mediate_deleted) {
|
profile dnsmasq flags=(attach_disconnected,mediate_deleted) {
|
||||||
#include <abstractions/base>
|
#include <abstractions/base>
|
||||||
#include <abstractions/nameservice>
|
|
||||||
|
|
||||||
capability net_bind_service,
|
# S6-Overlay & Bashio
|
||||||
capability setgid,
|
/bin/** ix,
|
||||||
capability setuid,
|
/usr/bin/** ix,
|
||||||
capability dac_override,
|
/usr/lib/bashio/** ix,
|
||||||
network inet raw,
|
/etc/s6/** ix,
|
||||||
network inet6 raw,
|
/run/s6/** ix,
|
||||||
|
/etc/services.d/** rwix,
|
||||||
|
/etc/cont-init.d/** rwix,
|
||||||
|
/etc/cont-finish.d/** rwix
|
||||||
|
|
||||||
/bin/busybox ix,
|
# Data access
|
||||||
/bin/bash ix,
|
/data/** rw,
|
||||||
/usr/bin/jq ix,
|
|
||||||
/usr/sbin/dnsmasq ix,
|
|
||||||
|
|
||||||
/etc/dnsmasq.conf rw,
|
# Execution program
|
||||||
/{,var/}run/*dnsmasq*.pid w,
|
/usr/sbin/dnsmasq cx,
|
||||||
/{,var/}run/dnsmasq/ r,
|
|
||||||
/{,var/}run/dnsmasq/* rw,
|
|
||||||
|
|
||||||
/usr/lib/bashio/bashio ix,
|
profile /usr/sbin/dnsmasq flags=(attach_disconnected,mediate_deleted) {
|
||||||
/dev/tty rw,
|
#include <abstractions/base>
|
||||||
/tmp/* rw,
|
#include <abstractions/nameservice>
|
||||||
|
|
||||||
/run.sh rix,
|
capability net_bind_service,
|
||||||
/data/** r,
|
capability setgid,
|
||||||
|
capability setuid,
|
||||||
|
capability dac_override,
|
||||||
|
network inet raw,
|
||||||
|
network inet6 raw,
|
||||||
|
|
||||||
|
/etc/dnsmasq.conf rw,
|
||||||
|
/run/*dnsmasq*.pid w,
|
||||||
|
/run/dnsmasq/ r,
|
||||||
|
/run/dnsmasq/* rw,
|
||||||
|
/tmp/* rw,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"build_from": {
|
"build_from": {
|
||||||
"aarch64": "homeassistant/aarch64-base:3.10",
|
"aarch64": "homeassistant/aarch64-base:3.13",
|
||||||
"amd64": "homeassistant/amd64-base:3.10",
|
"amd64": "homeassistant/amd64-base:3.13",
|
||||||
"armhf": "homeassistant/armhf-base:3.10",
|
"armhf": "homeassistant/armhf-base:3.13",
|
||||||
"armv7": "homeassistant/armv7-base:3.10",
|
"armv7": "homeassistant/armv7-base:3.13",
|
||||||
"i386": "homeassistant/i386-base:3.10"
|
"i386": "homeassistant/i386-base:3.13"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "Dnsmasq",
|
"name": "Dnsmasq",
|
||||||
"version": "1.3",
|
"version": "1.4",
|
||||||
"slug": "dnsmasq",
|
"slug": "dnsmasq",
|
||||||
"description": "A simple DNS server",
|
"description": "A simple DNS server",
|
||||||
"url": "https://github.com/home-assistant/hassio-addons/tree/master/dnsmasq",
|
"url": "https://github.com/home-assistant/hassio-addons/tree/master/dnsmasq",
|
||||||
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
|
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
|
||||||
"advanced": true,
|
"advanced": true,
|
||||||
"startup": "system",
|
"startup": "system",
|
||||||
|
"init": false,
|
||||||
"ports": {
|
"ports": {
|
||||||
"53/tcp": 53,
|
"53/tcp": 53,
|
||||||
"53/udp": 53
|
"53/udp": 53
|
||||||
@@ -14,7 +15,8 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"defaults": ["8.8.8.8", "8.8.4.4"],
|
"defaults": ["8.8.8.8", "8.8.4.4"],
|
||||||
"forwards": [],
|
"forwards": [],
|
||||||
"hosts": []
|
"hosts": [],
|
||||||
|
"services": []
|
||||||
},
|
},
|
||||||
"schema": {
|
"schema": {
|
||||||
"defaults": ["str"],
|
"defaults": ["str"],
|
||||||
@@ -29,6 +31,15 @@
|
|||||||
"host": "str",
|
"host": "str",
|
||||||
"ip": "str"
|
"ip": "str"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"services": [
|
||||||
|
{
|
||||||
|
"srv": "str",
|
||||||
|
"host": "str",
|
||||||
|
"port": "str",
|
||||||
|
"priority": "int",
|
||||||
|
"weight": "int"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"image": "homeassistant/{arch}-addon-dnsmasq"
|
"image": "homeassistant/{arch}-addon-dnsmasq"
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
no-resolv
|
|
||||||
no-hosts
|
|
||||||
keep-in-foreground
|
|
||||||
log-queries
|
|
||||||
log-facility=-
|
|
||||||
no-poll
|
|
||||||
user=root
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#!/usr/bin/env bashio
|
|
||||||
set -e
|
|
||||||
|
|
||||||
CONFIG="/etc/dnsmasq.conf"
|
|
||||||
|
|
||||||
bashio::log.info "Configuring dnsmasq..."
|
|
||||||
|
|
||||||
# Add default forward servers
|
|
||||||
for server in $(bashio::config 'defaults'); do
|
|
||||||
echo "server=${server}" >> "${CONFIG}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Create domain forwards
|
|
||||||
for forward in $(bashio::config 'forwards|keys'); do
|
|
||||||
DOMAIN=$(bashio::config "forwards[${forward}].domain")
|
|
||||||
SERVER=$(bashio::config "forwards[${forward}].server")
|
|
||||||
|
|
||||||
echo "server=/${DOMAIN}/${SERVER}" >> "${CONFIG}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Create static hosts
|
|
||||||
for host in $(bashio::config 'hosts|keys'); do
|
|
||||||
HOST=$(bashio::config "hosts[${host}].host")
|
|
||||||
IP=$(bashio::config "hosts[${host}].ip")
|
|
||||||
|
|
||||||
echo "address=/${HOST}/${IP}" >> "${CONFIG}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Run dnsmasq
|
|
||||||
bashio::log.info "Starting dnsmasq..."
|
|
||||||
exec dnsmasq -C "${CONFIG}" -z < /dev/null
|
|
||||||
12
dnsmasq/rootfs/etc/cont-init.d/config.sh
Normal file
12
dnsmasq/rootfs/etc/cont-init.d/config.sh
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
# ==============================================================================
|
||||||
|
# DNSMASQ config
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
CONFIG="/etc/dnsmasq.conf"
|
||||||
|
bashio::log.info "Configuring dnsmasq..."
|
||||||
|
tempio \
|
||||||
|
-conf /data/options.json \
|
||||||
|
-template /usr/share/tempio/dnsmasq.config \
|
||||||
|
-out "${CONFIG}"
|
||||||
|
|
||||||
8
dnsmasq/rootfs/etc/services.d/dnsmasq/finish
Normal file
8
dnsmasq/rootfs/etc/services.d/dnsmasq/finish
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/execlineb -S0
|
||||||
|
# ==============================================================================
|
||||||
|
# Take down the S6 supervision tree when dnsmasq fails
|
||||||
|
# ==============================================================================
|
||||||
|
if { s6-test ${1} -ne 0 }
|
||||||
|
if { s6-test ${1} -ne 256 }
|
||||||
|
|
||||||
|
s6-svscanctl -t /var/run/s6/services
|
||||||
7
dnsmasq/rootfs/etc/services.d/dnsmasq/run
Normal file
7
dnsmasq/rootfs/etc/services.d/dnsmasq/run
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/with-contenv bashio
|
||||||
|
CONFIG="/etc/dnsmasq.conf"
|
||||||
|
|
||||||
|
# Run dnsmasq
|
||||||
|
bashio::log.info "Starting dnsmasq..."
|
||||||
|
exec dnsmasq -C "${CONFIG}" -z < /dev/null
|
||||||
|
|
||||||
30
dnsmasq/rootfs/usr/share/tempio/dnsmasq.config
Normal file
30
dnsmasq/rootfs/usr/share/tempio/dnsmasq.config
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Automatically generated do not edit
|
||||||
|
|
||||||
|
no-resolv
|
||||||
|
no-hosts
|
||||||
|
keep-in-foreground
|
||||||
|
log-queries
|
||||||
|
log-facility=-
|
||||||
|
no-poll
|
||||||
|
user=root
|
||||||
|
|
||||||
|
# Default forward servers
|
||||||
|
{{ range .defaults }}
|
||||||
|
server={{ . }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
# Domain forwards
|
||||||
|
{{ range .forwards }}
|
||||||
|
server=/{{ .domain }}/{{ .server }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
# Static hosts
|
||||||
|
{{ range .hosts }}
|
||||||
|
address=/{{ .host }}/{{ .ip }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
# Static srv-hosts
|
||||||
|
{{ range .services }}
|
||||||
|
srv-host={{ .srv }},{{ .host }},{{ .port }},{{ .priority }},{{ .weight }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
Reference in New Issue
Block a user