Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samba: Update Samba add-on to allow selectively enabling folders #3701

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d2fc1ef
Updating to add option to enable specific shares for exporting, and t…
as-kholin Jul 28, 2024
ae11735
Updating translations for descriptive titles for the different folders
as-kholin Jul 29, 2024
a3105fc
Update DOCS.md to explain settings. Update init-smbd to block startu…
as-kholin Jul 29, 2024
6f4c772
remove unintentional extra line
as-kholin Jul 29, 2024
09ef073
Updating grammer per coderabbitai
as-kholin Jul 29, 2024
537522e
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Jul 29, 2024
8a0d55d
Incrementing version number
as-kholin Jul 29, 2024
7d313cb
Added Changelog update, and changed the version update in config to m…
as-kholin Jul 29, 2024
8d6ccb5
Updating to account for coderabbitai feedback on CHANGELOG
as-kholin Jul 29, 2024
40ccb71
Rebase to home-assistant/addons PR #3704 - Samba: correct benign idma…
as-kholin Jul 30, 2024
f1417d3
Letsencrypt: Add support for noris network DNS provider (#3697)
nana-ska Jul 30, 2024
372c2a7
Rebasing CHANGELOG updates
as-kholin Jul 29, 2024
e3e3dd7
Merging in changes from upstream
as-kholin Jul 31, 2024
8e9b5bd
Correct YAMLLing errors in user-facing descriptions due to long lines
as-kholin Jul 31, 2024
d020619
Correct typo on user descriptions in translations
as-kholin Jul 31, 2024
d62e9db
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Aug 5, 2024
dae9c99
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Aug 6, 2024
26c70a7
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Aug 6, 2024
acc72b5
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Aug 14, 2024
58b754e
Per frenck's feedback:
as-kholin Aug 14, 2024
1093201
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Aug 16, 2024
0f8f768
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Aug 26, 2024
86699ce
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Aug 27, 2024
a8b41c3
Correct missed adjustment when config variable names were changed
as-kholin Aug 30, 2024
ed18112
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Sep 2, 2024
5d6903b
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Sep 5, 2024
0ed4082
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Sep 11, 2024
f8322c4
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Sep 12, 2024
15a5626
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Sep 13, 2024
da6295e
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Sep 23, 2024
9bc5fda
Correct unintended Translation adjustment
as-kholin Sep 24, 2024
7b4c04d
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Sep 27, 2024
89bd885
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Sep 28, 2024
62492fb
Merge branch 'home-assistant:master' into smb_selective_enable
as-kholin Oct 4, 2024
6f8282f
Merge remote-tracking branch 'upstream/master' into smb_selective_enable
as-kholin Oct 10, 2024
9f62db3
Revamped selective enable
as-kholin Oct 10, 2024
25b4758
Updated translation to 80 character line limit
as-kholin Oct 10, 2024
e830809
Updated documentation based on CodeRabbit Feedback
as-kholin Oct 10, 2024
11acf7b
Merge remote-tracking branch 'upstream/master' into smb_selective_enable
as-kholin Oct 21, 2024
47495b8
Merge remote-tracking branch 'upstream/master' into smb_selective_enable
as-kholin Oct 25, 2024
9fb8782
Merge remote-tracking branch 'upstream/master' into smb_selective_enable
as-kholin Nov 3, 2024
a940a04
Merge remote-tracking branch 'upstream/master' into smb_selective_enable
as-kholin Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions samba/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Changelog
## 12.4.0

- Add the ability to enable and disable specific shares
- Add optional logging of samba configuration at startup

## 12.3.2

- Suppress benign idmap logged error
Expand Down
27 changes: 24 additions & 3 deletions samba/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Follow these steps to get the add-on installed on your system:

1. In the configuration section, set a username and password.
You can specify any username and password; these are not related in any way to the login credentials you use to log in to Home Assistant or to log in to the computer with which you will use Samba share.
2. Save the configuration.
3. Start the add-on.
4. Check the add-on log output to see the result.
2. Review the enabled shares. Disable any you do not plan to use (they can be re-enabled later)
3. Save the configuration.
4. Start the add-on.
5. Check the add-on log output to see the result.

## Connection

Expand All @@ -40,6 +41,14 @@ Add-on configuration:
workgroup: WORKGROUP
username: homeassistant
password: YOUR_PASSWORD
enabled_shares:
- addons
- addon_configs
- backup
- config
- media
- share
- ssl
allow_hosts:
- 10.0.0.0/8
- 172.16.0.0/12
Expand All @@ -52,6 +61,7 @@ veto_files:
- ".DS_Store"
- Thumbs.db
compatibility_mode: false
debug: false
```

### Option: `workgroup` (required)
Expand All @@ -66,6 +76,10 @@ The username you would like to use to authenticate with the Samba server.

The password that goes with the username configured for authentication.

### Option: `enabled_shares` (required)

List of Samba shares able to be accessed.

### Option: `allow_hosts` (required)

List of hosts/networks allowed to access the shared folders.
Expand All @@ -85,6 +99,13 @@ when you absolutely need it and understand the possible consequences.

Defaults to `false`.

### Option: `debug` (optional)

Outputs the resulting Samba config in the log. Generally, unless you
know what you would be wanting to do with this information, not necessary.

Optional config. If not defined, then it will default to `false`.

## Support

Got questions?
Expand Down
13 changes: 12 additions & 1 deletion samba/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 12.3.2
version: 12.4.0
slug: samba
name: Samba share
description: Expose Home Assistant folders with SMB/CIFS
Expand Down Expand Up @@ -27,6 +27,14 @@ options:
username: homeassistant
password: null
workgroup: WORKGROUP
enabled_shares:
- addons
- addon_configs
- backup
- config
- media
- share
- ssl
compatibility_mode: false
veto_files:
- ._*
Expand All @@ -45,9 +53,12 @@ schema:
username: str
password: password
workgroup: str
enabled_shares:
- "match(^(?i:(addons|addon_configs|backup|config|media|share|ssl))$)"
compatibility_mode: bool
veto_files:
- str
allow_hosts:
- str
debug: bool?
startup: services
10 changes: 9 additions & 1 deletion samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ if ! bashio::config.has_value 'username' || ! bashio::config.has_value 'password
bashio::exit.nok "Setting a username and password is required!"
fi

bashio::config.require "enabled_shares" "Samba is a tool for sharing folders. Starting it without sharing any folders defeats the purpose."

# Read hostname from API or setting default "hassio"
HOSTNAME=$(bashio::info.hostname)
if bashio::var.is_empty "${HOSTNAME}"; then
Expand All @@ -30,11 +32,17 @@ fi
bashio::log.info "Interfaces: $(printf '%s ' "${interfaces[@]}")"

# Generate Samba configuration.
jq ".interfaces = $(jq -c -n '$ARGS.positional' --args -- "${interfaces[@]}")" /data/options.json \
jq ".interfaces = $(jq -c -n '$ARGS.positional' --args -- "${interfaces[@]}") |
.enabled_shares.[] |= ascii_downcase" /data/options.json \
| tempio \
-template /usr/share/tempio/smb.gtpl \
-out /etc/samba/smb.conf

if bashio::config.true 'debug'; then
bashio::log.yellow "Resulting Samba config:"
bashio::log.yellow "$(cat /etc/samba/smb.conf)"
fi

# Init user
username=$(bashio::config 'username')
password=$(bashio::config 'password')
Expand Down
14 changes: 14 additions & 0 deletions samba/rootfs/usr/share/tempio/smb.gtpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
dos charset = CP850
unix charset = UTF-8

{{ if (has "config" .enabled_shares) }}
[config]
browseable = yes
writeable = yes
Expand All @@ -36,7 +37,9 @@
force group = root
veto files = /{{ .veto_files | join "/" }}/
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
{{ end }}

{{ if (has "addons" .enabled_shares) }}
[addons]
browseable = yes
writeable = yes
Expand All @@ -47,7 +50,9 @@
force group = root
veto files = /{{ .veto_files | join "/" }}/
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
{{ end }}

{{ if (has "addon_configs" .enabled_shares) }}
[addon_configs]
browseable = yes
writeable = yes
Expand All @@ -58,7 +63,9 @@
force group = root
veto files = /{{ .veto_files | join "/" }}/
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
{{ end }}

{{ if (has "ssl" .enabled_shares) }}
[ssl]
browseable = yes
writeable = yes
Expand All @@ -69,7 +76,9 @@
force group = root
veto files = /{{ .veto_files | join "/" }}/
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
{{ end }}

{{ if (has "share" .enabled_shares) }}
[share]
browseable = yes
writeable = yes
Expand All @@ -80,7 +89,9 @@
force group = root
veto files = /{{ .veto_files | join "/" }}/
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
{{ end }}

{{ if (has "backup" .enabled_shares) }}
[backup]
browseable = yes
writeable = yes
Expand All @@ -91,7 +102,9 @@
force group = root
veto files = /{{ .veto_files | join "/" }}/
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
{{ end }}

{{ if (has "media" .enabled_shares) }}
[media]
browseable = yes
writeable = yes
Expand All @@ -102,3 +115,4 @@
force group = root
veto files = /{{ .veto_files | join "/" }}/
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
{{ end }}
11 changes: 11 additions & 0 deletions samba/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ configuration:
workgroup:
name: Workgroup
description: Change WORKGROUP to reflect your network needs.
enabled_shares:
name: >-
Enabled Shares - allowed values are:
addons, addon_configs, backup, config, media, share, or ssl
description: >-
List of file shares to make available. Any you wish to add must be typed.
The listed values are the only allowed values.
Config cannot be saved if any non-allowed value is in the list.
compatibility_mode:
name: Enable Compatibility Mode
description: >-
Expand All @@ -21,3 +29,6 @@ configuration:
allow_hosts:
name: Allowed Hosts
description: List of hosts/networks allowed to access the shared folders.
debug:
name: Debug Logging
description: Log the resulting Samba config in the log