Enable Samba on all supported interfaces (#2353)

* Restore interface configuration

* run on all supported interfaces

* add loopback to the interface list

* fix ShellCheck errors
This commit is contained in:
Laszlo Magyar
2022-04-27 23:57:20 +02:00
committed by GitHub
parent 330e33a06f
commit 1d0311178b
4 changed files with 15 additions and 8 deletions

View File

@@ -1,5 +1,9 @@
# Changelog # Changelog
## 9.6.0
- Run on all supported interfaces
## 9.5.1 ## 9.5.1
- Add `hassio_api` to add-on configuration - Add `hassio_api` to add-on configuration

View File

@@ -1,5 +1,5 @@
--- ---
version: 9.5.1 version: 9.6.0
slug: samba slug: samba
name: Samba share name: Samba share
description: Expose Home Assistant folders with SMB/CIFS description: Expose Home Assistant folders with SMB/CIFS

View File

@@ -4,7 +4,7 @@
# ============================================================================== # ==============================================================================
declare password declare password
declare username declare username
declare interface declare -a interfaces
export HOSTNAME export HOSTNAME
# Check Login data # Check Login data
@@ -18,14 +18,17 @@ if bashio::var.is_empty "${HOSTNAME}"; then
bashio::log.warning "Can't read hostname, using default." bashio::log.warning "Can't read hostname, using default."
HOSTNAME="hassio" HOSTNAME="hassio"
fi fi
bashio::log.info "Hostname: ${HOSTNAME}"
# Get default interface # Get supported interfaces
interface=$(bashio::network.name) for interface in $(bashio::network.interfaces); do
interfaces+=("${interface}")
bashio::log.info "Using hostname=${HOSTNAME} interface=${interface}" done
interfaces+=("lo")
bashio::log.info "Interfaces: $(printf '%s ' "${interfaces[@]}")"
# Generate Samba configuration. # Generate Samba configuration.
jq ".interface = \"${interface}\"" /data/options.json \ jq ".interfaces = $(jq -c -n '$ARGS.positional' --args -- "${interfaces[@]}")" /data/options.json \
| tempio \ | tempio \
-template /usr/share/tempio/smb.gtpl \ -template /usr/share/tempio/smb.gtpl \
-out /etc/samba/smb.conf -out /etc/samba/smb.conf

View File

@@ -12,7 +12,7 @@
log level = 2 log level = 2
bind interfaces only = yes bind interfaces only = yes
interfaces = {{ .interface }} interfaces = {{ .interfaces | join " " }}
hosts allow = {{ .allow_hosts | join " " }} hosts allow = {{ .allow_hosts | join " " }}
{{ if .compatibility_mode }} {{ if .compatibility_mode }}