forked from home-assistant/addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samba: Compatibility mode & upgrades (home-assistant#1244)
* samba: Compatibility mode & upgrades * samba: Add missing newline to nmbd service * Update build.json Co-authored-by: Pascal Vizeli <[email protected]>
- Loading branch information
Showing
12 changed files
with
148 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/with-contenv bashio | ||
# ============================================================================== | ||
# 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 | ||
|
||
# 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}" | ||
|
||
# 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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
# ============================================================================== | ||
# Start nmbd service | ||
# ============================================================================== | ||
exec nmbd \ | ||
--foreground \ | ||
--log-stdout \ | ||
--no-process-group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
# ============================================================================== | ||
# Start smbd service | ||
# ============================================================================== | ||
exec smbd \ | ||
--foreground \ | ||
--log-stdout \ | ||
--no-process-group |