Skip to content

Commit

Permalink
Fix for release
Browse files Browse the repository at this point in the history
  • Loading branch information
dianlight committed Jul 8, 2023
1 parent 4e09b33 commit 5a1030e
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 19 deletions.
12 changes: 8 additions & 4 deletions sambanas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Changelog

## 10.0.2-nas3 [Unrelesed]
## 10.0.2-nas3

### ✨ Features
- Add support of `acl.usage` to specify what scope of disk is, usefull for network storage mount in ha ([DOCS.md][docs])

### 🩹 BugFix
- Always add docker network to whitelist - May FIX [#157](https://github.com/dianlight/hassio-addons/issues/157)
- Always add docker network to whitelist - Try fix [#157](https://github.com/dianlight/hassio-addons/issues/157)
- Correct cifs mount precedence. Try fix [[#159](https://github.com/dianlight/hassio-addons/issues/159)]

### 💥 BREAKING CHANGE
- Default `acl.timemachine` option now is set to `true`

### Planned
- Disk Type - Media / Backup etc etc
## 10.0.2-nas2
### ✨ Features
- Read only users [[#141](https://github.com/dianlight/hassio-addons/issues/141)]
Expand Down
9 changes: 8 additions & 1 deletion sambanas/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,14 @@ Defaults to none

If is true the share is exposed with timechine compatible setting.

Defaults to `false` for internal share.
Defaults to `false` for internal share, `true` forn extra disks.

### Option: `usage` (optional) (**valid only for external disks**)

Set the scope of the disk, usefull for ha network storage mount. Valid values are `media`,`backup`,`share`

Defaults to `media` for external disks if `medialibray` is enabled.


### Option: `interfaces` (optional) (**advanced users only**)

Expand Down
1 change: 1 addition & 0 deletions sambanas/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ schema:
ro_users:
- str?
timemachine: bool?
usage: list(media|backup|share)?
interfaces:
- str?
log_level: list(trace|debug|info|notice|warning|error|fatal)?
Expand Down
18 changes: 14 additions & 4 deletions sambanas/rootfs/etc/s6-overlay/s6-rc.d/cifs-supervisor-mount/run
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ if [ -f /tmp/cifs_network ]; then

bashio::log.info "Automount Shares..."

interface=$(bashio::network.name)
ipaddress=$(bashio::network.ipv4_address "${interface}")
#interface=$(bashio::network.name)
#ipaddress=$(bashio::network.ipv4_address "${interface}")
#interface=$(bashio::network 'network.info.docker.inerface' '.docker.interface')
#ipaddress=$(bashio::network 'network.info.docker.network' '.docker.address')
#hostname=$(bashio::addon.hostname)
ipaddress=$(bashio::addon.ip_address)
#bashio::log "Addon IP: ${hostname}/${ipaddress}"

username=$(bashio::config 'username')
password=$(bashio::config 'password')
Expand All @@ -23,11 +28,16 @@ if [ -f /tmp/cifs_network ]; then
#mounts=$(bashio::api.supervisor GET /mounts false)
#bashio::log "Mounts: ${mounts}"

#status=$(smbcontrol smbd ping)
#bashio::log "Samba Ready: ${status}"
#bashio::log "Children: $(smbcontrol smbd num-children)"

while read -r -a device; do
[[ "share config addons ssl backup media" =~ $device ]] && continue
cmdshare=$(jq -nrc --arg share "$device" --arg ip "${ipaddress/\/*/}" --arg user "$username" --arg pwd "$password" '.name=$share|.usage="media"|.type="cifs"|.server=$ip|.share=$share|.username=$user|.password=$pwd')
usage=$(jq -r --arg xshare "$device" '.acl[] | select(.share==$xshare) | .usage // "media"' <<<"$(bashio::addon.config)")
cmdshare=$(jq -nrc --arg usage "$usage" --arg share "$device" --arg ip "${ipaddress/\/*/}" --arg user "$username" --arg pwd "$password" '.name=$share|.usage=$usage|.type="cifs"|.server=$ip|.share=$share|.username=$user|.password=$pwd')
#bashio::log.info "${cmdshare}"
status=$(bashio::api.supervisor POST /mounts "${cmdshare}")
bashio::log.info "Return from Mount: ${status}"
#bashio::log.info "Return from Mount: ${status}"
done <<<"${available_shares}"
fi
2 changes: 1 addition & 1 deletion sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-samba/run
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ done

# Log exposed mounted shares
bashio::log.blue "---------------------------------------------------"
bashio::log.info "Exposed Disks Summary:\n$(awk '/\[.*\]/{ DISK=$0; next } /.*path =(.*)/{ printf "%-20s %s\n",DISK,$0 }' /etc/samba/smb.conf)"
bashio::log.info "Exposed Disks Summary:\n$(awk '/\[.*\]/{ DISK=$0; next } /.*path =(.*)/{ PATH=$0; next} /.*TM:(.*)/{ printf "%-20s %s %s#\n",DISK,PATH,$0 }' /etc/samba/smb.conf)"
bashio::log.blue "---------------------------------------------------"
Empty file.
30 changes: 21 additions & 9 deletions sambanas/rootfs/usr/share/tempio/smb.gtpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@

path = /{{- .share }}
valid users = {{ .users|default .username|join " " }} {{ .ro_users|join " " }}
{{ if .ro_users }}
read list = {{ .ro_users|join " " }}
{{ end }}
force user = root
force group = root
veto files = /{{ .veto_files | join "/" }}/
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
{{- if .timemachine|default false }}
# TM:{{ .timemachine }} {{- if .medialibrary.enable }} USAGE:{{ .usage | default "" }} {{ end }}
{{- if .timemachine }}
vfs objects = catia fruit streams_xattr
# Time Machine Settings Ref: https://github.com/markthomas93/samba.apple.templates
Expand All @@ -69,27 +72,36 @@
{{ end }}
{{ end }}
{{- $disks := concat (list "config" "addons" "ssl" "share" "backup" "media") (compact .moredisks|default list) -}}
{{- $dfdisk := list "config" "addons" "ssl" "share" "backup" "media" }}
{{- $disks := concat $dfdisk (compact .moredisks|default list) -}}
{{- $root := . -}}
{{- range $disk := $disks -}}
{{- $acld := false -}}
{{- range $dd := $root.acl -}}
{{- $ndisk := $disk | regexFind "[A-Za-z0-9_]+$" -}}
{{- if eq $dd.share $ndisk -}}
{{- $def := deepCopy $dd }}
{{- $acld = true -}}
{{- if not $dd.disabled -}}
{{- $_ := set $dd "share" $disk -}}
{{- template "SHT" deepCopy $root | mergeOverwrite $dd -}}
{{- if has $disk $dfdisk -}}
{{- $_ := set $def "timemachine" false -}}
{{- $_ := set $def "usage" "" -}}
{{- else -}}
{{- $_ := set $def "timemachine" true -}}
{{- $_ := set $def "usage" "media" -}}
{{- end }}
{{- template "SHT" deepCopy $root | mergeOverwrite $def $dd -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if not $acld -}}
{{- $dd := dict "share" $disk "timemachine" true -}}
{{- range $dnt := list "config" "addons" "ssl" "share" "backup" "media" -}}
{{- if eq $dnt $disk -}}
{{- $_ := set $dd "timemachine" false -}}
{{- end -}}
{{- end -}}
{{- template "SHT" deepCopy $root | mergeOverwrite $dd -}}
{{- $_ := set $dd "usage" "media" -}}
{{- if has $disk $dfdisk -}}
{{- $_ := set $dd "timemachine" false -}}
{{- $_ := set $dd "usage" "" -}}
{{- end }}
{{- template "SHT" (deepCopy $root | mergeOverwrite $dd) -}}
{{- end -}}
{{- end -}}

0 comments on commit 5a1030e

Please sign in to comment.