Skip to content

Commit

Permalink
Merge pull request #68 from chickenbellyfin/master
Browse files Browse the repository at this point in the history
Add CONFIG_FILE env var to set YAML config path
  • Loading branch information
crazy-max committed Aug 13, 2023
2 parents 4f87dd8 + d24eddc commit 1738734
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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}"
}
Expand All @@ -124,17 +124,17 @@ 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 <<EOL
$(echo "$global" | base64 --decode)
EOL
done
fi

if [[ "$(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' /data/config.yml 2>/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}"
}
Expand Down

0 comments on commit 1738734

Please sign in to comment.