Skip to content

Commit db512cb

Browse files
committed
feat: Taildrive shares
Share homeassistant directories to your Tailnet using Taildrive.
1 parent 7150d95 commit db512cb

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

tailscale/config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ privileged:
2424
devices:
2525
- /dev/net/tun
2626
map:
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
2835
ports:
2936
41641/udp: null
3037
schema:
@@ -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?

tailscale/rootfs/etc/s6-overlay/s6-rc.d/taildrive/dependencies.d/post-tailscaled

Whitespace-only changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oneshot
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/etc/s6-overlay/s6-rc.d/taildrive/run

tailscale/translations/en.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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: >-

0 commit comments

Comments
 (0)