File tree Expand file tree Collapse file tree 6 files changed +53
-0
lines changed
rootfs/etc/s6-overlay/s6-rc.d/taildrive Expand file tree Collapse file tree 6 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,14 @@ privileged:
2424devices :
2525 - /dev/net/tun
2626map :
27+ - homeassistant_config:rw
28+ - addon_config:rw
29+ - ssl:rw
30+ - addons:rw
31+ - backup:rw
2732 - share:rw
33+ - media:rw
34+ - all_addon_configs:rw
2835ports :
2936 41641/udp : null
3037schema :
@@ -44,4 +51,6 @@ schema:
4451 tags :
4552 - " match(^tag:[a-zA-Z][a-zA-Z0-9-]*$)?"
4653 taildrop : bool?
54+ taildrive :
55+ - " match(^(?i:(homeassistant_config|addon_config|ssl|addons|backup|share|media))$)"
4756 userspace_networking : bool?
Original file line number Diff line number Diff line change 1+ #!/command/with-contenv bashio
2+ # shellcheck shell=bash
3+ # ==============================================================================
4+ # Home Assistant Community Add-on: Tailscale
5+ # Exposes Home Assistant directories over Taildrive
6+ # ==============================================================================
7+
8+ # Read configured directories from the add-on configuration.
9+ if ! mapfile -t configured_dirs < <(bashio::config "taildrive"); then
10+ bashio::exit.nok "Error reading configured directories from add-on configuration."
11+ fi
12+
13+ # Read currently shared directories into an array from tailscale drive list.
14+ # The output of which looks like:
15+ # name path as
16+ # ---- ---- --
17+ # config /config config
18+ if ! mapfile -t shared_dirs < <(/opt/tailscale drive list | tail -n +3 | awk '{print $1}'); then
19+ bashio::exit.nok "Error reading shared directories from Tailscale."
20+ fi
21+
22+ # If a directory is configured but not shared, share it.
23+ for dir in "${configured_dirs[@]}"; do
24+ if ! printf '%s\0' "${shared_dirs[@]}" | grep -Fxqz -- "${dir}"; then
25+ # Share the directory
26+ /opt/tailscale drive share "${dir}" "/${dir}"
27+ fi
28+ done
29+
30+ # If a directory is shared but not configured, unshare it.
31+ for dir in "${shared_dirs[@]}"; do
32+ if ! printf '%s\0' "${configured_dirs[@]}" | grep -Fxqz -- "${dir}"; then
33+ # Unshare the directory
34+ /opt/taildrive drive unshare "${dir}"
35+ fi
36+ done
Original file line number Diff line number Diff line change 1+ oneshot
Original file line number Diff line number Diff line change 1+ /etc/s6-overlay/s6-rc.d/taildrive/run
Original file line number Diff line number Diff line change @@ -90,6 +90,12 @@ configuration:
9090 This option allows you to enable Taildrop, a file sharing service
9191 that allows you to share files with other Tailscale nodes.
9292 When not set, this option is enabled by default.
93+ taildrive :
94+ name : Taildrive Shares
95+ description : >-
96+ This option allows you to specify which Home Assistant directories you
97+ want to share with other Tailscale nodes using Taildrive.
98+ The listed values are the only allowed values.
9399 userspace_networking :
94100 name : Userspace networking mode
95101 description : >-
You can’t perform that action at this time.
0 commit comments