mirror of
https://github.com/hassio-addons/addon-zerotier.git
synced 2025-05-04 19:21:25 +00:00
✨ Adds support for multiple networks
This commit is contained in:
parent
1212942f06
commit
4d110b8a35
4 changed files with 29 additions and 33 deletions
|
@ -23,7 +23,6 @@
|
||||||
"hassio_role": "default",
|
"hassio_role": "default",
|
||||||
"homeassistant_api": false,
|
"homeassistant_api": false,
|
||||||
"host_network": true,
|
"host_network": true,
|
||||||
"apparmor": true,
|
|
||||||
"privileged": [
|
"privileged": [
|
||||||
"NET_ADMIN",
|
"NET_ADMIN",
|
||||||
"SYS_ADMIN"
|
"SYS_ADMIN"
|
||||||
|
@ -36,14 +35,12 @@
|
||||||
"ssl:rw"
|
"ssl:rw"
|
||||||
],
|
],
|
||||||
"options": {
|
"options": {
|
||||||
"network_id":"",
|
"networks":[],
|
||||||
"port": 9993,
|
|
||||||
"api_auth_token": ""
|
"api_auth_token": ""
|
||||||
},
|
},
|
||||||
"schema": {
|
"schema": {
|
||||||
|
"networks":["match([0-9a-z]{16})"],
|
||||||
"api_auth_token": "str",
|
"api_auth_token": "str",
|
||||||
"log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)?",
|
"log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)?"
|
||||||
"network_id":"match([0-9a-z]{16})",
|
|
||||||
"port": "port"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/usr/bin/with-contenv bashio
|
|
||||||
# ==============================================================================
|
|
||||||
# Community Hass.io Add-ons: ZeroTier One
|
|
||||||
# Sets the auth token for the local JSON API
|
|
||||||
# ==============================================================================
|
|
||||||
declare token
|
|
||||||
if bashio::config.has_value 'api_auth_token'; then
|
|
||||||
token=$(bashio::config 'api_auth_token')
|
|
||||||
echo "${token}" > /data/authtoken.secret
|
|
||||||
fi
|
|
|
@ -1,17 +0,0 @@
|
||||||
#!/usr/bin/with-contenv bashio
|
|
||||||
# ==============================================================================
|
|
||||||
# Community Hass.io Add-ons: ZeroTier One
|
|
||||||
# Creates ZeroTier One configuration in case it is non-existing
|
|
||||||
# ==============================================================================
|
|
||||||
readonly network=$(bashio::config 'network_id')
|
|
||||||
|
|
||||||
# Ensure network folder exists
|
|
||||||
mkdir -p "/var/lib/zerotier-one/networks.d" \
|
|
||||||
|| bashio::exit.nok "Could not create networks folder"
|
|
||||||
|
|
||||||
# Ensure the file exists. An empty file will cause automatic join.
|
|
||||||
touch "/data/network.${network}.conf"
|
|
||||||
ln -s \
|
|
||||||
"/data/network.${network}.conf" \
|
|
||||||
"/var/lib/zerotier-one/networks.d/${network}.conf" \
|
|
||||||
|| bashio::exit.nok "Could not create network file"
|
|
|
@ -5,7 +5,9 @@
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
readonly private='/ssl/zerotier/identity.secret'
|
readonly private='/ssl/zerotier/identity.secret'
|
||||||
readonly public='/ssl/zerotier/identity.public'
|
readonly public='/ssl/zerotier/identity.public'
|
||||||
|
declare network
|
||||||
declare node
|
declare node
|
||||||
|
declare token
|
||||||
|
|
||||||
# Generate identity if it does not exist
|
# Generate identity if it does not exist
|
||||||
if ! bashio::fs.file_exists "${private}" \
|
if ! bashio::fs.file_exists "${private}" \
|
||||||
|
@ -36,3 +38,27 @@ ln -s "${public}" /var/lib/zerotier-one/identity.public
|
||||||
|
|
||||||
node=$(cut -d ':' -f1 < "${private}")
|
node=$(cut -d ':' -f1 < "${private}")
|
||||||
bashio::log.info "ZeroTier node address: ${node}"
|
bashio::log.info "ZeroTier node address: ${node}"
|
||||||
|
|
||||||
|
# Sets the auth token for the local JSON API
|
||||||
|
if bashio::config.has_value 'api_auth_token'; then
|
||||||
|
token=$(bashio::config 'api_auth_token')
|
||||||
|
echo "${token}" > /data/authtoken.secret
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure network folder exists
|
||||||
|
mkdir -p "/var/lib/zerotier-one/networks.d" \
|
||||||
|
|| bashio::exit.nok "Could not create networks folder"
|
||||||
|
|
||||||
|
# Install user configured/requested packages
|
||||||
|
if bashio::config.has_value 'networks'; then
|
||||||
|
for network in $(bashio::config 'networks'); do
|
||||||
|
bashio::log.info "Configuring network: ${network}"
|
||||||
|
|
||||||
|
# Ensure the file exists. An empty file will cause automatic join.
|
||||||
|
touch "/data/network.${network}.conf"
|
||||||
|
ln -s \
|
||||||
|
"/data/network.${network}.conf" \
|
||||||
|
"/var/lib/zerotier-one/networks.d/${network}.conf" \
|
||||||
|
|| bashio::exit.nok "Could not create network file"
|
||||||
|
done
|
||||||
|
fi
|
Loading…
Add table
Add a link
Reference in a new issue