From d24eddc8698cf0b3b8ffafea0d1150093644e48f Mon Sep 17 00:00:00 2001 From: chickenbellyfin Date: Sun, 13 Aug 2023 09:32:42 -0700 Subject: [PATCH] Add CONFIG_FILE env var to set YAML config path --- README.md | 1 + entrypoint.sh | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 18e4ab8..96933d9 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ Image: crazymax/samba:latest * `SAMBA_WIDE_LINKS`: Controls whether or not links in the UNIX file system may be followed by the server. (default `yes`) * `SAMBA_HOSTS_ALLOW`: Set of hosts which are permitted to access a service. (default `127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16`) * `SAMBA_INTERFACES`: Allows you to override the default network interfaces list. +* `CONFIG_FILE`: YAML configuration path (default `/data/config.yml`) > More info: https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html diff --git a/entrypoint.sh b/entrypoint.sh index 5aacd1e..a4c7bf8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash - TZ=${TZ:-UTC} +CONFIG_FILE=${CONFIG_FILE:-/data/config.yml} SAMBA_WORKGROUP=${SAMBA_WORKGROUP:-WORKGROUP} SAMBA_SERVER_STRING=${SAMBA_SERVER_STRING:-Docker Samba Server} @@ -107,8 +107,8 @@ bind interfaces only = yes EOL fi -if [[ "$(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' /data/config.yml 2>/dev/null | jq '.auth')" != "null" ]]; then - for auth in $(yq -j e '(.. | select(tag == "!!str")) |= envsubst' /data/config.yml 2>/dev/null | jq -r '.auth[] | @base64'); do +if [[ "$(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' $CONFIG_FILE 2>/dev/null | jq '.auth')" != "null" ]]; then + for auth in $(yq -j e '(.. | select(tag == "!!str")) |= envsubst' $CONFIG_FILE 2>/dev/null | jq -r '.auth[] | @base64'); do _jq() { echo "${auth}" | base64 --decode | jq -r "${1}" } @@ -124,8 +124,8 @@ if [[ "$(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' / done fi -if [[ "$(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' /data/config.yml 2>/dev/null | jq '.global')" != "null" ]]; then - for global in $(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' /data/config.yml 2>/dev/null | jq -r '.global[] | @base64'); do +if [[ "$(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' $CONFIG_FILE 2>/dev/null | jq '.global')" != "null" ]]; then + for global in $(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' $CONFIG_FILE 2>/dev/null | jq -r '.global[] | @base64'); do echo "Add global option: $(echo "$global" | base64 --decode)" cat >> /etc/samba/smb.conf </dev/null | jq '.share')" != "null" ]]; then - for share in $(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' /data/config.yml 2>/dev/null | jq -r '.share[] | @base64'); do +if [[ "$(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' $CONFIG_FILE 2>/dev/null | jq '.share')" != "null" ]]; then + for share in $(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' $CONFIG_FILE 2>/dev/null | jq -r '.share[] | @base64'); do _jq() { echo "${share}" | base64 --decode | jq -r "${1}" }