add samba with old data
This commit is contained in:
53
samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run
Normal file
53
samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/command/with-contenv bashio
|
||||
# vim: ft=bash
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Prepare the Samba service for running
|
||||
# ==============================================================================
|
||||
declare password
|
||||
declare username
|
||||
declare -a interfaces=()
|
||||
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
|
||||
|
||||
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
|
||||
bashio::log.warning "Can't read hostname, using default."
|
||||
HOSTNAME="hassio"
|
||||
fi
|
||||
bashio::log.info "Hostname: ${HOSTNAME}"
|
||||
|
||||
# Get supported interfaces
|
||||
for interface in $(bashio::network.interfaces); do
|
||||
interface_enabled=$(bashio::network.enabled "${interface}")
|
||||
if bashio::var.true "${interface_enabled}"; then
|
||||
interfaces+=("${interface}")
|
||||
fi
|
||||
done
|
||||
if [ ${#interfaces[@]} -eq 0 ]; then
|
||||
bashio::exit.nok 'No supported interfaces found to bind on.'
|
||||
fi
|
||||
bashio::log.info "Interfaces: $(printf '%s ' "${interfaces[@]}")"
|
||||
|
||||
# Generate Samba configuration.
|
||||
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
|
||||
|
||||
# Init user
|
||||
username=$(bashio::config 'username')
|
||||
password=$(bashio::config 'password')
|
||||
addgroup "${username}"
|
||||
adduser -D -H -G "${username}" -s /bin/false "${username}"
|
||||
|
||||
(echo "$password"; echo "$password") \
|
||||
| smbpasswd -a -s -c "/etc/samba/smb.conf" "${username}"
|
1
samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/type
Normal file
1
samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/type
Normal file
@@ -0,0 +1 @@
|
||||
oneshot
|
1
samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/up
Normal file
1
samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/up
Normal file
@@ -0,0 +1 @@
|
||||
/etc/s6-overlay/s6-rc.d/init-smbd/run
|
27
samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/finish
Normal file
27
samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/finish
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/command/with-contenv bashio
|
||||
# vim: ft=bash
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Take down the S6 supervision tree when nmbd fails
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC2155
|
||||
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
|
10
samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/run
Normal file
10
samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/run
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/command/with-contenv bashio
|
||||
# vim: ft=bash
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Start nmbd service
|
||||
# ==============================================================================
|
||||
exec nmbd \
|
||||
--foreground \
|
||||
--debug-stdout \
|
||||
--no-process-group
|
1
samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/type
Normal file
1
samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/type
Normal file
@@ -0,0 +1 @@
|
||||
longrun
|
27
samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish
Normal file
27
samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/command/with-contenv bashio
|
||||
# vim: ft=bash
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Take down the S6 supervision tree when smbd fails
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC2155
|
||||
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
|
10
samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run
Normal file
10
samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/command/with-contenv bashio
|
||||
# vim: ft=bash
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Start smbd service
|
||||
# ==============================================================================
|
||||
exec smbd \
|
||||
--foreground \
|
||||
--debug-stdout \
|
||||
--no-process-group
|
1
samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/type
Normal file
1
samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/type
Normal file
@@ -0,0 +1 @@
|
||||
longrun
|
Reference in New Issue
Block a user