Skip to content

Commit

Permalink
samba: Migrate add-on layout to S6 Overlay (#3001)
Browse files Browse the repository at this point in the history
Co-authored-by: Franck Nijhof <[email protected]>
  • Loading branch information
lmagyar and frenck authored Nov 12, 2023
1 parent 260b09d commit b91defb
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 23 deletions.
4 changes: 4 additions & 0 deletions samba/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 11.1.0

- Migrate add-on layout to S6 Overlay

## 11.0.0

- The `config` share has been renamed to `homeassistant` to match upstream changes.
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv bashio
#!/command/with-contenv bashio
# ==============================================================================
# Prepare the Samba service for running
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-smbd/run
Empty file.
25 changes: 25 additions & 0 deletions samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Take down the S6 supervision tree when nmbd fails
# ==============================================================================
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
readonly exit_code_service="${1}"
readonly exit_code_signal="${2}"
readonly service="nmbd"

bashio::log.info \
"Service ${service} exited with code ${exit_code_service}" \
"(by signal ${exit_code_signal})"

if [[ "${exit_code_service}" -eq 256 ]]; then
if [[ "${exit_code_container}" -eq 0 ]]; then
echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
fi
[[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt
elif [[ "${exit_code_service}" -ne 0 ]]; then
if [[ "${exit_code_container}" -eq 0 ]]; then
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
fi
exec /run/s6/basedir/bin/halt
fi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/command/with-contenv bashio
# ==============================================================================
# Start nmbd service
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
25 changes: 25 additions & 0 deletions samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Take down the S6 supervision tree when smbd fails
# ==============================================================================
readonly exit_code_container=$(</run/s6-linux-init-container-results/exitcode)
readonly exit_code_service="${1}"
readonly exit_code_signal="${2}"
readonly service="smbd"

bashio::log.info \
"Service ${service} exited with code ${exit_code_service}" \
"(by signal ${exit_code_signal})"

if [[ "${exit_code_service}" -eq 256 ]]; then
if [[ "${exit_code_container}" -eq 0 ]]; then
echo $((128 + $exit_code_signal)) > /run/s6-linux-init-container-results/exitcode
fi
[[ "${exit_code_signal}" -eq 15 ]] && exec /run/s6/basedir/bin/halt
elif [[ "${exit_code_service}" -ne 0 ]]; then
if [[ "${exit_code_container}" -eq 0 ]]; then
echo "${exit_code_service}" > /run/s6-linux-init-container-results/exitcode
fi
exec /run/s6/basedir/bin/halt
fi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/command/with-contenv bashio
# ==============================================================================
# Start smbd service
# ==============================================================================
Expand Down
1 change: 1 addition & 0 deletions samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
10 changes: 0 additions & 10 deletions samba/rootfs/etc/services.d/nmbd/finish

This file was deleted.

10 changes: 0 additions & 10 deletions samba/rootfs/etc/services.d/smbd/finish

This file was deleted.

0 comments on commit b91defb

Please sign in to comment.