Update addons with multibe tasks (#129) (#130)

Update addons with multibe tasks
This commit is contained in:
Pascal Vizeli
2017-06-27 15:12:26 +02:00
committed by GitHub
parent c325d458d6
commit 50b2ba946c
9 changed files with 33 additions and 18 deletions

View File

@@ -8,6 +8,8 @@
"boot": "auto",
"host_network": true,
"options": {
"default_lease": 600,
"max_lease": 7200,
"domain": null,
"dns": ["8.8.8.8", "8.8.4.4"],
"networks": [
@@ -24,6 +26,8 @@
"hosts": []
},
"schema": {
"default_lease": "int",
"max_lease": "int",
"domain": "str",
"dns": ["str"],
"networks": [

View File

@@ -1,7 +1,7 @@
option domain-name "%%DOMAIN%%";
option domain-name-servers %%DNS_SERVERS%%;
default-lease-time 600;
max-lease-time 7200;
default-lease-time %%DEFAULT_LEASE%%;
max-lease-time %%MAX_LEASE%%;
authoritative;

View File

@@ -3,6 +3,8 @@ set -e
CONFIG_PATH=/data/options.json
DEFAULT_LEASE=$(jq --raw-output '.default_lease' $CONFIG_PATH)
MAX_LEASE=$(jq --raw-output '.max_lease' $CONFIG_PATH)
DOMAIN=$(jq --raw-output '.domain' $CONFIG_PATH)
DNS=$(jq --raw-output '.dns | join(", ")' $CONFIG_PATH)
NETWORKS=$(jq --raw-output '.networks | length' $CONFIG_PATH)
@@ -10,6 +12,8 @@ HOSTS=$(jq --raw-output '.hosts | length' $CONFIG_PATH)
sed -i "s/%%DOMAIN%%/$DOMAIN/g" /etc/dhcpd.conf
sed -i "s/%%DNS_SERVERS%%/$DNS/g" /etc/dhcpd.conf
sed -i "s/%%DEFAULT_LEASE%%/$DEFAULT_LEASE/g" /etc/dhcpd.conf
sed -i "s/%%MAX_LEASE%%/$MAX_LEASE/g" /etc/dhcpd.conf
# Create networks
for (( i=0; i < "$NETWORKS"; i++ )); do

View File

@@ -1,6 +1,6 @@
{
"name": "Dnsmasq server",
"version": "0.4",
"name": "Dnsmasq",
"version": "0.5",
"slug": "dnsmasq",
"description": "A simple dns server with benefits",
"url": "https://home-assistant.io/addons/dnsmasq/",

View File

@@ -6,7 +6,7 @@ CONFIG_PATH=/data/options.json
DEFAULTS=$(jq --raw-output '.defaults[]' $CONFIG_PATH)
FORWARDS=$(jq --raw-output '.forwards | length' $CONFIG_PATH)
HOSTS=$(jq --raw-output '.hosts | length' $CONFIG_PATH)
INTERFACE=$(jq --raw-output '.interface' $CONFIG_PATH)
INTERFACE=$(jq --raw-output '.interface // empty' $CONFIG_PATH)
# Bind to interface
if [ -z "$INTERFACE" ]; then

View File

@@ -1,6 +1,6 @@
{
"name": "Samba share",
"version": "0.8",
"version": "0.9",
"slug": "samba",
"description": "Expose HassIO folders with Samba",
"url": "https://home-assistant.io/addons/samba/",
@@ -9,7 +9,7 @@
"ports": {
"445/tcp": 445
},
"map": ["config:rw", "ssl:rw", "addons:rw", "share:rw"],
"map": ["config:rw", "ssl:rw", "addons:rw", "share:rw", "backup:rw"],
"options": {
"workgroup": "WORKGROUP",
"guest": true,
@@ -17,6 +17,7 @@
"map_addons": true,
"map_ssl": false,
"map_share": true,
"map_backup": true,
"username": "",
"password": ""
},
@@ -27,6 +28,7 @@
"map_addons": "bool",
"map_ssl": "bool",
"map_share": "bool",
"map_backup": "bool",
"username": "str",
"password": "str"
},

View File

@@ -3,14 +3,15 @@ set -e
CONFIG_PATH=/data/options.json
WORKGROUP=$(jq --raw-output ".workgroup // empty" $CONFIG_PATH)
GUEST=$(jq --raw-output ".guest // empty" $CONFIG_PATH)
USERNAME=$(jq --raw-output ".username // empty" $CONFIG_PATH)
PASSWORD=$(jq --raw-output ".password // empty" $CONFIG_PATH)
MAP_CONFIG=$(jq --raw-output ".map_config // empty" $CONFIG_PATH)
MAP_ADDONS=$(jq --raw-output ".map_addons // empty" $CONFIG_PATH)
MAP_SSL=$(jq --raw-output ".map_ssl // empty" $CONFIG_PATH)
MAP_SHARE=$(jq --raw-output ".map_share // empty" $CONFIG_PATH)
WORKGROUP=$(jq --raw-output '.workgroup' $CONFIG_PATH)
GUEST=$(jq --raw-output '.guest' $CONFIG_PATH)
USERNAME=$(jq --raw-output '.username // empty' $CONFIG_PATH)
PASSWORD=$(jq --raw-output '.password // empty' $CONFIG_PATH)
MAP_CONFIG=$(jq --raw-output '.map_config' $CONFIG_PATH)
MAP_ADDONS=$(jq --raw-output '.map_addons' $CONFIG_PATH)
MAP_SSL=$(jq --raw-output '.map_ssl' $CONFIG_PATH)
MAP_SHARE=$(jq --raw-output '.map_share' $CONFIG_PATH)
MAP_BACKUP=$(jq --raw-output '.map_backup' $CONFIG_PATH)
function write_config() {
@@ -46,6 +47,9 @@ fi
if [ "$MAP_SHARE" == "true" ]; then
write_config "share"
fi
if [ "$MAP_BACKUP" == "true" ]; then
write_config "backup"
fi
##
# Set authentication options

View File

@@ -1,6 +1,6 @@
{
"name": "SSH server",
"version": "0.7",
"version": "0.8",
"slug": "ssh",
"description": "Connect to your server over SSH",
"url": "https://home-assistant.io/addons/ssh/",
@@ -9,7 +9,7 @@
"ports": {
"22/tcp": 22
},
"map": ["config:rw", "ssl:rw", "addons:rw", "share:rw"],
"map": ["config:rw", "ssl:rw", "addons:rw", "share:rw", "backup:rw"],
"options": {
"authorized_keys": [null]
},

View File

@@ -9,6 +9,7 @@ AUTHORIZED_KEYS=$(jq --raw-output ".authorized_keys[]" $CONFIG_PATH)
# Init defaults config
sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config
sed -i s/#PasswordAuthentication.*/PasswordAuthentication\ no/ /etc/ssh/sshd_config
sed -i s/#LogLevel.*/LogLevel\ DEBUG/ /etc/ssh/sshd_config
# Generate authorized_keys file
mkdir -p ~/.ssh
@@ -27,4 +28,4 @@ else
fi
# start server
exec /usr/sbin/sshd -D < /dev/null
exec /usr/sbin/sshd -D -e < /dev/null