mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-18 21:54:20 +01:00
samba: 9.4.0 (Alpine 3.13 + tempio) (#2023)
* Upgrade Alpine Linux to 3.13 * Rewrite Samba configuration using tempio * Update changelog and bump version to 9.4.0
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## 9.4.0
|
||||
|
||||
- Upgrade Alpine Linux to 3.13
|
||||
- Rewrite configuration generation code
|
||||
|
||||
## 9.3.1
|
||||
|
||||
- Update options schema for passwords
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"build_from": {
|
||||
"aarch64": "homeassistant/aarch64-base:3.12",
|
||||
"amd64": "homeassistant/amd64-base:3.12",
|
||||
"armhf": "homeassistant/armhf-base:3.12",
|
||||
"armv7": "homeassistant/armv7-base:3.12",
|
||||
"i386": "homeassistant/i386-base:3.12"
|
||||
"aarch64": "ghcr.io/home-assistant/aarch64-base:3.13",
|
||||
"amd64": "ghcr.io/home-assistant/amd64-base:3.13",
|
||||
"armhf": "ghcr.io/home-assistant/armhf-base:3.13",
|
||||
"armv7": "ghcr.io/home-assistant/armv7-base:3.13",
|
||||
"i386": "ghcr.io/home-assistant/i386-base:3.13"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Samba share",
|
||||
"version": "9.3.1",
|
||||
"version": "9.4.0",
|
||||
"slug": "samba",
|
||||
"description": "Expose Home Assistant folders with SMB/CIFS",
|
||||
"url": "https://github.com/home-assistant/hassio-addons/tree/master/samba",
|
||||
@@ -8,7 +8,14 @@
|
||||
"startup": "services",
|
||||
"init": false,
|
||||
"host_network": true,
|
||||
"map": ["config:rw", "ssl:rw", "addons:rw", "share:rw", "backup:rw", "media:rw"],
|
||||
"map": [
|
||||
"config:rw",
|
||||
"ssl:rw",
|
||||
"addons:rw",
|
||||
"share:rw",
|
||||
"backup:rw",
|
||||
"media:rw"
|
||||
],
|
||||
"options": {
|
||||
"workgroup": "WORKGROUP",
|
||||
"username": "homeassistant",
|
||||
|
||||
@@ -2,64 +2,34 @@
|
||||
# ==============================================================================
|
||||
# Prepare the Samba service for running
|
||||
# ==============================================================================
|
||||
readonly CONF="/etc/samba/smb.conf"
|
||||
declare allow_hosts
|
||||
declare compatibility_mode
|
||||
declare delete_veto_files
|
||||
declare name
|
||||
declare password
|
||||
declare username
|
||||
declare veto_files
|
||||
export HOSTNAME
|
||||
|
||||
# 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
|
||||
HOSTNAME=$(bashio::info.hostname)
|
||||
if bashio::var.is_empty "${HOSTNAME}"; then
|
||||
bashio::log.warning "Can't read hostname, using default."
|
||||
name="hassio"
|
||||
HOSTNAME="hassio"
|
||||
fi
|
||||
bashio::log.info "Hostname: ${name}"
|
||||
sed -i "s|%%NAME%%|${name}|g" "${CONF}"
|
||||
bashio::log.info "Hostname: ${HOSTNAME}"
|
||||
|
||||
# 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}"
|
||||
# Generate Samba configuration.
|
||||
tempio \
|
||||
-conf /data/options.json \
|
||||
-template /usr/share/tempio/smb.gtpl \
|
||||
-out /etc/samba/smb.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}"
|
||||
| smbpasswd -a -s -c "/etc/samba/smb.conf" "${username}"
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
[global]
|
||||
netbios name = %%NAME%%
|
||||
workgroup = %%WORKGROUP%%
|
||||
server string = Samba Home Assistant
|
||||
|
||||
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%%
|
||||
|
||||
[media]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /media
|
||||
|
||||
valid users = %%USERNAME%%
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = %%VETO_FILES%%
|
||||
delete veto files = %%DELETE_VETO_FILES%%
|
||||
87
samba/rootfs/usr/share/tempio/smb.gtpl
Normal file
87
samba/rootfs/usr/share/tempio/smb.gtpl
Normal file
@@ -0,0 +1,87 @@
|
||||
[global]
|
||||
netbios name = {{ env "HOSTNAME" }}
|
||||
workgroup = {{ .workgroup }}
|
||||
server string = Samba Home Assistant
|
||||
|
||||
security = user
|
||||
ntlm auth = yes
|
||||
|
||||
load printers = no
|
||||
disable spoolss = yes
|
||||
|
||||
log level = 2
|
||||
|
||||
bind interfaces only = yes
|
||||
interfaces = {{ .interface }}
|
||||
hosts allow = {{ .allow_hosts | join " " }}
|
||||
|
||||
{{ if .compatibility_mode }}
|
||||
client min protocol = NT1
|
||||
server min protocol = NT1
|
||||
{{ end }}
|
||||
|
||||
[config]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /config
|
||||
|
||||
valid users = {{ .username }}
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = /{{ .veto_files | join "/" }}/
|
||||
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
|
||||
|
||||
[addons]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /addons
|
||||
|
||||
valid users = {{ .username }}
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = /{{ .veto_files | join "/" }}/
|
||||
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
|
||||
|
||||
[ssl]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /ssl
|
||||
|
||||
valid users = {{ .username }}
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = /{{ .veto_files | join "/" }}/
|
||||
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
|
||||
|
||||
[share]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /share
|
||||
|
||||
valid users = {{ .username }}
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = /{{ .veto_files | join "/" }}/
|
||||
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
|
||||
|
||||
[backup]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /backup
|
||||
|
||||
valid users = {{ .username }}
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = /{{ .veto_files | join "/" }}/
|
||||
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
|
||||
|
||||
[media]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /media
|
||||
|
||||
valid users = {{ .username }}
|
||||
force user = root
|
||||
force group = root
|
||||
veto files = /{{ .veto_files | join "/" }}/
|
||||
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
|
||||
Reference in New Issue
Block a user