samba add-on with option to set the ports
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
# Changelog
|
||||
|
||||
## 9.2.0
|
||||
|
||||
- Pin base image version
|
||||
- Rewrite add-on onto S6 Overlay
|
||||
- Use default configuration location
|
||||
- Add support for running in compatibility mode (SMB1/NT1)
|
||||
- Add dummy files to reduce number of errors/warnings in log output
|
||||
|
||||
## 9.1.0
|
||||
|
||||
- Allow IPv6 link-local hosts by default, consistent with IPv4
|
||||
|
||||
## 9.0.0
|
||||
|
||||
- New option `veto_files` to limit writing of specified files to the share
|
||||
|
||||
## 8.3.0
|
||||
|
||||
- Fixes a bug in warning log message, causing start failure
|
||||
- Minor code cleanups
|
||||
|
||||
## 8.2.0
|
||||
|
||||
- Update from bash to bashio
|
||||
|
||||
## 8.1.0
|
||||
|
||||
- Update Samba to version 4.8.8
|
||||
|
||||
## 8.0.0
|
||||
|
||||
- Fix access to /backup
|
||||
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
# Home Assistant Add-on: Samba share
|
||||
|
||||
## Installation
|
||||
|
||||
Follow these steps to get the add-on installed on your system:
|
||||
|
||||
1. Navigate in your Home Assistant frontend to **Supervisor** -> **Add-on Store**.
|
||||
2. Find the "Samba share" add-on and click it.
|
||||
3. Click on the "INSTALL" button.
|
||||
|
||||
## How to use
|
||||
|
||||
1. In the configuration section, set a username and password.
|
||||
2. Save the configuration.
|
||||
3. Start the add-on.
|
||||
4. Check the add-on log output to see the result.
|
||||
|
||||
## Configuration
|
||||
|
||||
Add-on configuration:
|
||||
|
||||
```yaml
|
||||
workgroup: WORKGROUP
|
||||
port1: 445
|
||||
port2: 139
|
||||
username: homeassistant
|
||||
password: YOUR_PASSWORD
|
||||
interface: ''
|
||||
allow_hosts:
|
||||
- 10.0.0.0/8
|
||||
- 172.16.0.0/12
|
||||
- 192.168.0.0/16
|
||||
- fe80::/10
|
||||
veto_files:
|
||||
- "._*"
|
||||
- ".DS_Store"
|
||||
- Thumbs.db
|
||||
compatibility_mode: false
|
||||
```
|
||||
|
||||
### Option: `workgroup` (required)
|
||||
|
||||
Change WORKGROUP to reflect your network needs.
|
||||
|
||||
### Option: `port1` (required)
|
||||
|
||||
Change PORT1 to reflect your network needs.
|
||||
|
||||
### Option: `port2` (required)
|
||||
|
||||
Change PORT2 to reflect your network needs.
|
||||
|
||||
### Option: `username` (required)
|
||||
|
||||
The username you would like to use to authenticate with the Samba server.
|
||||
|
||||
### Option: `password` (required)
|
||||
|
||||
The password that goes with the username configured for authentication.
|
||||
|
||||
### Option: `interface` (required)
|
||||
|
||||
The network interface Samba should listen on for incoming connections.
|
||||
This option should only be used in advanced cases. In general, setting this
|
||||
option is not needed.
|
||||
|
||||
### Option: `allow_hosts` (required)
|
||||
|
||||
List of hosts/networks allowed to access the shared folders.
|
||||
|
||||
### Option: `veto_files` (optional)
|
||||
|
||||
List of files that are neither visible nor accessible. Useful to stop clients
|
||||
from littering the share with temporary hidden files
|
||||
(e.g., macOS `.DS_Store` or Windows `Thumbs.db` files)
|
||||
|
||||
### Option: `compatibility_mode`
|
||||
|
||||
Setting this option to `true` will enable old legacy Samba protocols
|
||||
on the Samba add-on. This might solve issues with some clients that cannot
|
||||
handle the newer protocols, however, it lowers security. Only use this
|
||||
when you absolutely need it and understand the possible consequences.
|
||||
|
||||
Defaults to `false`.
|
||||
|
||||
## Support
|
||||
|
||||
Got questions?
|
||||
|
||||
You have several options to get them answered:
|
||||
|
||||
- The [Home Assistant Discord Chat Server][discord].
|
||||
- The Home Assistant [Community Forum][forum].
|
||||
- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit]
|
||||
|
||||
In case you've found a bug, please [open an issue on our GitHub][issue].
|
||||
|
||||
[discord]: https://discord.gg/c5DvZ4e
|
||||
[forum]: https://community.home-assistant.io
|
||||
[issue]: https://github.com/home-assistant/hassio-addons/issues
|
||||
[reddit]: https://reddit.com/r/homeassistant
|
||||
[repository]: https://github.com/hassio-addons/repository
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
|
||||
# Add env
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
# Setup base
|
||||
RUN \
|
||||
apk add --no-cache \
|
||||
samba-common-tools \
|
||||
samba-server \
|
||||
\
|
||||
&& mkdir -p /var/lib/samba \
|
||||
&& touch \
|
||||
/etc/samba/lmhosts \
|
||||
/var/lib/samba/account_policy.tdb \
|
||||
/var/lib/samba/registry.tdb \
|
||||
/var/lib/samba/winbindd_idmap.tdb
|
||||
|
||||
# Copy data
|
||||
COPY rootfs /
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
# Home Assistant Add-on: Samba share
|
||||
|
||||
Share your configuration over the network using Windows file sharing.
|
||||
|
||||
![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports i386 Architecture][i386-shield]
|
||||
|
||||
## About
|
||||
|
||||
This Add-on allows you to enable file sharing across different operating systems over a network.
|
||||
It lets you access your config files with Windows and macOS devices.
|
||||
|
||||
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
|
||||
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
|
||||
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
|
||||
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg
|
||||
[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
# https://dev.azure.com/home-assistant
|
||||
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
paths:
|
||||
include:
|
||||
- samba/*
|
||||
pr: none
|
||||
resources:
|
||||
repositories:
|
||||
- repository: azure
|
||||
type: github
|
||||
name: "home-assistant/ci-azure"
|
||||
endpoint: "home-assistant"
|
||||
|
||||
variables:
|
||||
- group: docker
|
||||
|
||||
jobs:
|
||||
- template: templates/azp-job-addon.yaml@azure
|
||||
parameters:
|
||||
addon: "samba"
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"build_from": {
|
||||
"aarch64": "homeassistant/aarch64-base:3.11",
|
||||
"amd64": "homeassistant/amd64-base:3.11",
|
||||
"armhf": "homeassistant/armhf-base:3.11",
|
||||
"armv7": "homeassistant/armv7-base:3.11",
|
||||
"i386": "homeassistant/i386-base:3.11"
|
||||
}
|
||||
}
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "Samba share",
|
||||
"version": "9.2.0",
|
||||
"slug": "samba",
|
||||
"description": "Expose Home Assistant folders with SMB/CIFS",
|
||||
"url": "https://github.com/home-assistant/hassio-addons/tree/master/samba",
|
||||
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
|
||||
"startup": "services",
|
||||
"boot": "auto",
|
||||
"init": false,
|
||||
"host_network": true,
|
||||
"map": ["config:rw", "ssl:rw", "addons:rw", "share:rw", "backup:rw"],
|
||||
"options": {
|
||||
"workgroup": "WORKGROUP",
|
||||
"port1": "445",
|
||||
"port2": "139",
|
||||
"username": "homeassistant",
|
||||
"password": null,
|
||||
"interface": "",
|
||||
"allow_hosts": [
|
||||
"10.0.0.0/8",
|
||||
"172.16.0.0/12",
|
||||
"192.168.0.0/16",
|
||||
"fe80::/10"
|
||||
],
|
||||
"veto_files": ["._*", ".DS_Store", "Thumbs.db", "icon?", ".Trashes"],
|
||||
"compatibility_mode": false
|
||||
},
|
||||
"schema": {
|
||||
"workgroup": "str",
|
||||
"port1": "str",
|
||||
"port2": "str",
|
||||
"username": "str",
|
||||
"password": "str",
|
||||
"interface": "str",
|
||||
"allow_hosts": ["str"],
|
||||
"veto_files": ["str"],
|
||||
"compatibility_mode": "bool"
|
||||
},
|
||||
"image_": "homeassistant/{arch}-addon-samba"
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Prepare the Samba service for running
|
||||
# ==============================================================================
|
||||
readonly CONF="/etc/samba/smb.conf"
|
||||
declare port1
|
||||
declare port2
|
||||
declare allow_hosts
|
||||
declare compatibility_mode
|
||||
declare delete_veto_files
|
||||
declare name
|
||||
declare password
|
||||
declare username
|
||||
declare veto_files
|
||||
|
||||
# Check Login data
|
||||
if ! bashio::config.has_value 'username' || ! bashio::config.has_value 'password'; then
|
||||
bashio::exit.nok "Setting a username and password is required!"
|
||||
fi
|
||||
|
||||
# Workgroup and interface
|
||||
sed -i "s|%%WORKGROUP%%|$(bashio::config 'workgroup')|g" "${CONF}"
|
||||
sed -i "s|%%INTERFACE%%|$(bashio::config 'interface')|g" "${CONF}"
|
||||
|
||||
# Veto files
|
||||
veto_files=""
|
||||
delete_veto_files="no"
|
||||
if bashio::config.has_value 'veto_files'; then
|
||||
veto_files=$(bashio::config "veto_files | join(\"/\")")
|
||||
veto_files="/${veto_files}/"
|
||||
delete_veto_files="yes"
|
||||
fi
|
||||
sed -i "s|%%VETO_FILES%%|${veto_files}|g" "${CONF}"
|
||||
sed -i "s|%%DELETE_VETO_FILES%%|${delete_veto_files}|g" "${CONF}"
|
||||
|
||||
# Read hostname from API or setting default "hassio"
|
||||
name=$(bashio::info.hostname)
|
||||
if bashio::var.is_empty "${name}"; then
|
||||
bashio::log.warning "Can't read hostname, using default."
|
||||
name="hassio"
|
||||
fi
|
||||
bashio::log.info "Hostname: ${name}"
|
||||
sed -i "s|%%NAME%%|${name}|g" "${CONF}"
|
||||
|
||||
# ports
|
||||
port1=$(bashio::config 'port1')
|
||||
port2=$(bashio::config 'port2')
|
||||
sed -i "s|%%PORT1%%|${port1}|g" "${CONF}"
|
||||
sed -i "s|%%PORT2%%|${port2}|g" "${CONF}"
|
||||
|
||||
# Allowed hosts
|
||||
allow_hosts=$(bashio::config "allow_hosts | join(\" \")")
|
||||
sed -i "s#%%ALLOW_HOSTS%%#${allow_hosts}#g" "${CONF}"
|
||||
|
||||
# Compatibility mode, enables the use of the legacy SMB1 protocol
|
||||
compatibility_mode=""
|
||||
if bashio::config.true "compatibility_mode"; then
|
||||
compatibility_mode+=" client min protocol = NT1\n"
|
||||
compatibility_mode+=" server min protocol = NT1\n"
|
||||
fi
|
||||
sed -i "s#%%COMPATIBILITY_MODE%%#${compatibility_mode}#g" "${CONF}"
|
||||
|
||||
# Init user
|
||||
username=$(bashio::config 'username')
|
||||
password=$(bashio::config 'password')
|
||||
|
||||
addgroup "${username}"
|
||||
adduser -D -H -G "${username}" -s /bin/false "${username}"
|
||||
|
||||
sed -i "s|%%USERNAME%%|${username}|g" "${CONF}"
|
||||
# shellcheck disable=SC1117
|
||||
echo -e "${password}\n${password}" \
|
||||
| smbpasswd -a -s -c "${CONF}" "${username}"
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
[global]
|
||||
netbios name = %%NAME%%
|
||||
workgroup = %%WORKGROUP%%
|
||||
server string = Samba Home Assistant
|
||||
|
||||
smb ports = %%PORT1%% %%PORT2%%
|
||||
|
||||
security = user
|
||||
ntlm auth = yes
|
||||
|
||||
load printers = no
|
||||
disable spoolss = yes
|
||||
|
||||
log level = 2
|
||||
|
||||
bind interfaces only = yes
|
||||
interfaces = %%INTERFACE%%
|
||||
hosts allow = %%ALLOW_HOSTS%%
|
||||
|
||||
%%COMPATIBILITY_MODE%%
|
||||
[config]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /config
|
||||
|
||||
valid users = %%USERNAME%%
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = %%VETO_FILES%%
|
||||
delete veto files = %%DELETE_VETO_FILES%%
|
||||
|
||||
[addons]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /addons
|
||||
|
||||
valid users = %%USERNAME%%
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = %%VETO_FILES%%
|
||||
delete veto files = %%DELETE_VETO_FILES%%
|
||||
|
||||
[ssl]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /ssl
|
||||
|
||||
valid users = %%USERNAME%%
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = %%VETO_FILES%%
|
||||
delete veto files = %%DELETE_VETO_FILES%%
|
||||
|
||||
[share]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /share
|
||||
|
||||
valid users = %%USERNAME%%
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = %%VETO_FILES%%
|
||||
delete veto files = %%DELETE_VETO_FILES%%
|
||||
|
||||
[backup]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /backup
|
||||
|
||||
valid users = %%USERNAME%%
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = %%VETO_FILES%%
|
||||
delete veto files = %%DELETE_VETO_FILES%%
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/execlineb -S1
|
||||
# ==============================================================================
|
||||
# Take down the S6 supervision tree based on service exit code
|
||||
# ==============================================================================
|
||||
if { s6-test ${1} -ne 0 }
|
||||
if { s6-test ${1} -ne 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Start nmbd service
|
||||
# ==============================================================================
|
||||
exec nmbd \
|
||||
--foreground \
|
||||
--log-stdout \
|
||||
--no-process-group
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/execlineb -S1
|
||||
# ==============================================================================
|
||||
# Take down the S6 supervision tree based on service exit code
|
||||
# ==============================================================================
|
||||
if { s6-test ${1} -ne 0 }
|
||||
if { s6-test ${1} -ne 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Start smbd service
|
||||
# ==============================================================================
|
||||
exec smbd \
|
||||
--foreground \
|
||||
--log-stdout \
|
||||
--no-process-group
|
||||
Reference in New Issue
Block a user