#!/usr/bin/with-contenv bashio # shellcheck shell=bash # ============================================================================== # Start wsdd service # ============================================================================== declare SMB_GROUP declare SMB_HOST SMB_GROUP=$(grep -i '^\s*workgroup\s*=' /etc/samba/smb.conf | cut -f2 -d= | tr -d '[:blank:]') SMB_HOST=$(grep -i '^\s*netbios name\s*=' /etc/samba/smb.conf | cut -f2 -d= | tr -d '[:blank:]') if bashio::config.true 'bind_all_interfaces'; then interfaces+=" " elif bashio::config.has_value 'interfaces'; then bashio::log.info "Interfaces from config: $(bashio::config 'interfaces')" for interface in $(bashio::config 'interfaces'); do if [ -d "/sys/class/net/${interface}" ]; then interfaces+=("-i ${interface}") else bashio::log.warning "Interface ${interface} not found, skipping." fi done else # Get supported interfaces for interface in $(bashio::network.interfaces); do interfaces+=("-i ${interface}") done fi #if [ ${#interfaces[@]} -eq 0 ]; then # bashio::exit.nok 'No supported interfaces found to bind on.' #fi #bashio::log.info "Interfaces: $(printf '%s ' "${interfaces[@]}")" if bashio::config.true 'wsdd2'; then bashio::log.info "Starting the WSDD2 daemon $(printf '%s ' "${interfaces[@]}") for ${SMB_GROUP}/${SMB_HOST}..." setcap CAP_NET_RAW+ep /usr/sbin/wsdd2 # shellcheck disable=SC2046 exec /usr/sbin/wsdd2 -t -u -w $(printf '%s ' "${interfaces[@]}") -H "${SMB_HOST}" -b vendor:homeassistant,model:sambanas elif bashio::config.true 'wsdd'; then bashio::log.info "Starting the WSDD daemon $(printf '%s ' "${interfaces[@]}") for ${SMB_GROUP}/${SMB_HOST}..." # shellcheck disable=SC2046 exec wsdd -v $(printf '%s ' "${interfaces[@]}") -n "${SMB_HOST}" -w "${SMB_GROUP}" else exec sleep infinity fi