Find storage and AI servers on the tailnet, not only over mDNS
shellcheck / shellcheck (push) Failing after 18s

configure storage and configure ai-servers now also ask the other online
computers on the Core's tailnet, so a laptop away from home still finds the
MiniServer and the LLM box. A machine found both ways is listed once, by its
tailnet name, and tailnet servers mount at /mnt/<short name>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 14:30:38 -07:00
co-authored by Claude Opus 5.5
parent 7e80d37986
commit 16e5a9c79d
5 changed files with 220 additions and 26 deletions
+2 -2
View File
@@ -295,9 +295,9 @@ It covers:
- Signing in to Claude Code, opencode and Hermes Agent and choosing their model providers. - Signing in to Claude Code, opencode and Hermes Agent and choosing their model providers.
- **Languages** to install with mise, such as Ruby on Rails (see Mise above). - **Languages** to install with mise, such as Ruby on Rails (see Mise above).
- **Printers** on your network. It lists the printers it finds, whether they're reached directly or shared by another computer, and adds the ones you choose as printers on this computer, without drivers (IPP Everywhere), so they're in every print dialog. A printer another computer shares that can also be reached directly is marked, and not chosen unless you pick it, so printing doesn't depend on that computer being on. Printers already added, e.g. in GNOME Settings, are left alone. To choose without being asked, set a default printer or try it first, run `~/.local/share/coredesktop/system/setup-printers.sh --help`. - **Printers** on your network. It lists the printers it finds, whether they're reached directly or shared by another computer, and adds the ones you choose as printers on this computer, without drivers (IPP Everywhere), so they're in every print dialog. A printer another computer shares that can also be reached directly is marked, and not chosen unless you pick it, so printing doesn't depend on that computer being on. Printers already added, e.g. in GNOME Settings, are left alone. To choose without being asked, set a default printer or try it first, run `~/.local/share/coredesktop/system/setup-printers.sh --help`.
- **Network storage**: shared folders from other machines on your network, mounted in /mnt and added to the Files sidebar. It finds SMB servers (Windows, Samba and NAS boxes, and Macs with File Sharing on) and machines you can ssh to, or you enter an address (`smb://nas.local/files`, `sftp://me@server.local/srv/data`). An SMB share is in /etc/fstab and mounts the first time you open its folder, so a server that's off doesn't hold anything up; its password is kept in /etc/coredesktop/smb, readable only by root. An SFTP folder is mounted by sshfs as you, at login, with the SSH keys in your Bitwarden or GNOME SSH agent, so the server has to accept one of them (it can't ask for a password). Agents in the sandbox can read these folders, and change one only if you start the agent in it. "Remove one" unmounts it and takes it back out. - **Network storage**: shared folders from other machines on your network, mounted in /mnt and added to the Files sidebar. It finds SMB servers (Windows, Samba and NAS boxes, and Macs with File Sharing on) and machines you can ssh to, or you enter an address (`smb://nas.local/files`, `sftp://me@server.local/srv/data`). Once you've run `configure tailscale`, it also finds them on the Core's network, so a laptop away from home still finds the MiniServer: it asks each computer there whether it takes SSH or SMB connections. A machine found on both is listed once, by its Tailscale name, and mounted at /mnt/<its short name> either way. An SMB share is in /etc/fstab and mounts the first time you open its folder, so a server that's off doesn't hold anything up; its password is kept in /etc/coredesktop/smb, readable only by root. An SFTP folder is mounted by sshfs as you, at login, with the SSH keys in your Bitwarden or GNOME SSH agent, so the server has to accept one of them (it can't ask for a password). Agents in the sandbox can read these folders, and change one only if you start the agent in it. "Remove one" unmounts it and takes it back out.
- **Agent sandbox**, if WinBoat is set up: the sandbox hides WinBoat's settings (~/.winboat) from agents, since they include your Windows password. To let agents read them, e.g. to have one help with WinBoat, run `configure sandbox` and switch it; switch it again to hide them. This only covers the sandboxed agents (opencode, Hermes, Cline), not Claude Code's own sandbox. Your SSH keys, password stores and the rest stay hidden either way. - **Agent sandbox**, if WinBoat is set up: the sandbox hides WinBoat's settings (~/.winboat) from agents, since they include your Windows password. To let agents read them, e.g. to have one help with WinBoat, run `configure sandbox` and switch it; switch it again to hide them. This only covers the sandboxed agents (opencode, Hermes, Cline), not Claude Code's own sandbox. Your SSH keys, password stores and the rest stay hidden either way.
- **AI servers** on your network, such as Ollama on a Mac. It finds the machines on your network over mDNS and asks each one on the ports LLM servers use (11434 Ollama, 1234 LM Studio, 8080 llama.cpp, 8000 vLLM), since LLM servers don't announce themselves; or you enter a server's address. For the server you choose, it lets the sandboxed agents reach it (that port only), adds it to opencode with its models, offers to make it Hermes' model, and lets the commands Claude Code runs reach it too. Claude Code itself keeps using Anthropic's models. A server has to accept connections from other machines: in Ollama's settings, turn on "Expose Ollama to the network"; in LM Studio, "Serve on Local Network". "Remove a server" takes it back out of all of them. - **AI servers** on your network, such as Ollama on a Mac. It finds the machines on your network over mDNS, and once you've run `configure tailscale` the computers on the Core's network too (each listed once), and asks each one on the ports LLM servers use (11434 Ollama, 1234 LM Studio, 8080 llama.cpp, 8000 vLLM), since LLM servers don't announce themselves; or you enter a server's address. For the server you choose, it lets the sandboxed agents reach it (that port only), adds it to opencode with its models, offers to make it Hermes' model, and lets the commands Claude Code runs reach it too. Claude Code itself keeps using Anthropic's models. A server has to accept connections from other machines: in Ollama's settings, turn on "Expose Ollama to the network"; in LM Studio, "Serve on Local Network". "Remove a server" takes it back out of all of them.
- **Security key**, if one is plugged in: a FIDO2 key (YubiKey, Nitrokey, SoloKey, ...) to touch instead of typing your password for sudo and the password prompts of GNOME's apps and settings. Without the key, they ask for your password as before. Run it again to add a spare key, or to stop using keys. - **Security key**, if one is plugged in: a FIDO2 key (YubiKey, Nitrokey, SoloKey, ...) to touch instead of typing your password for sudo and the password prompts of GNOME's apps and settings. Without the key, they ask for your password as before. Run it again to add a spare key, or to stop using keys.
- **Fingerprint**, if this computer has a fingerprint reader: the same, with your fingerprint. It enrolls your right index finger, unless you've already enrolled one in Settings > System > Users. The login and lock screens take it too. With the laptop's lid shut, it goes straight to your password. Run it again to stop. - **Fingerprint**, if this computer has a fingerprint reader: the same, with your fingerprint. It enrolls your right index finger, unless you've already enrolled one in Settings > System > Users. The login and lock screens take it too. With the laptop's lid shut, it goes straight to your password. Run it again to stop.
+12 -6
View File
@@ -14,6 +14,7 @@ SANDBOX_CONF="$HOME/.config/coredesktop/sandbox/base.json"
CLAUDE_SETTINGS="$HOME/.claude/settings.json" CLAUDE_SETTINGS="$HOME/.claude/settings.json"
OPENCODE_CONF="$HOME/.config/opencode/opencode.json" OPENCODE_CONF="$HOME/.config/opencode/opencode.json"
source "$COREDESKTOP/configure.d/lib/mdns.sh" source "$COREDESKTOP/configure.d/lib/mdns.sh"
source "$COREDESKTOP/configure.d/lib/tailnet.sh"
source "$COREDESKTOP/configure.d/lib/json.sh" source "$COREDESKTOP/configure.d/lib/json.sh"
# Ports LLM servers listen on by default, and who uses each. All of them answer # Ports LLM servers listen on by default, and who uses each. All of them answer
@@ -22,7 +23,7 @@ LLM_PORTS=(11434 1234 8080 8000)
declare -A LLM_PORT_NAMES=([11434]=Ollama [1234]="LM Studio" [8080]=llama.cpp [8000]=vLLM) declare -A LLM_PORT_NAMES=([11434]=Ollama [1234]="LM Studio" [8080]=llama.cpp [8000]=vLLM)
is_installed() { is_installed() {
command -v avahi-browse command -v avahi-browse || command -v tailscale
} }
is_configured() { is_configured() {
@@ -45,13 +46,13 @@ server_kind() {
fi fi
} }
# The LLM servers on the network: "host:port|models" per line. mDNS finds the # The LLM servers on the network: "host:port|models" per line. mDNS and the
# machines, but LLM servers don't announce themselves on it, so each machine # tailnet find the machines, but LLM servers don't announce themselves, so
# is asked on the usual ports. # each machine is asked on the usual ports.
find_servers() { find_servers() {
local dir host port local dir host port
dir="$(mktemp -d)" || return 1 dir="$(mktemp -d)" || return 1
for host in $(mdns_hosts); do for host in $(with_tailnet_hosts "$(mdns_hosts)"); do
for port in "${LLM_PORTS[@]}"; do for port in "${LLM_PORTS[@]}"; do
(server_models "$host:$port" | wc -l > "$dir/$host:$port") & (server_models "$host:$port" | wc -l > "$dir/$host:$port") &
done done
@@ -203,17 +204,22 @@ remove_server() {
# Find servers on the network and add the one you choose # Find servers on the network and add the one you choose
find_and_add() { find_and_add() {
local servers server models choice i local servers server models choice i
if tailnet_joined; then
echo "Looking for LLM servers on your network and the Core's (Tailscale)..."
else
echo "Looking for LLM servers on your network..." echo "Looking for LLM servers on your network..."
fi
mapfile -t servers < <(find_servers) mapfile -t servers < <(find_servers)
if [ ${#servers[@]} -eq 0 ]; then if [ ${#servers[@]} -eq 0 ]; then
echo "No LLM servers found. A server has to accept connections from other machines:" echo "No LLM servers found. A server has to accept connections from other machines:"
echo "in Ollama's settings, turn on \"Expose Ollama to the network\" (or set OLLAMA_HOST=0.0.0.0);" echo "in Ollama's settings, turn on \"Expose Ollama to the network\" (or set OLLAMA_HOST=0.0.0.0);"
echo "in LM Studio, turn on \"Serve on Local Network\". Or enter its address instead." echo "in LM Studio, turn on \"Serve on Local Network\". Or enter its address instead."
tailnet_joined || echo "To find the Core's servers away from home too, run: configure tailscale"
return 0 return 0
fi fi
for i in "${!servers[@]}"; do for i in "${!servers[@]}"; do
IFS='|' read -r server models <<< "${servers[$i]}" IFS='|' read -r server models <<< "${servers[$i]}"
printf ' %2d) %-28s %s, %s models\n' $((i + 1)) "$server" "$(server_kind "$server")" "$models" printf ' %2d) %-36s %s, %s models\n' $((i + 1)) "$server" "$(server_kind "$server")" "$models"
done done
read -rp "Which server? " choice read -rp "Which server? " choice
if ! [[ "$choice" =~ ^[0-9]+$ ]] || (( choice < 1 || choice > ${#servers[@]} )); then if ! [[ "$choice" =~ ^[0-9]+$ ]] || (( choice < 1 || choice > ${#servers[@]} )); then
+30 -8
View File
@@ -14,9 +14,10 @@ STORAGE_CONF="$HOME/.config/coredesktop/storage"
SMB_CREDENTIALS="/etc/coredesktop/smb" SMB_CREDENTIALS="/etc/coredesktop/smb"
BOOKMARKS="$HOME/.config/gtk-3.0/bookmarks" BOOKMARKS="$HOME/.config/gtk-3.0/bookmarks"
source "$COREDESKTOP/configure.d/lib/mdns.sh" source "$COREDESKTOP/configure.d/lib/mdns.sh"
source "$COREDESKTOP/configure.d/lib/tailnet.sh"
is_installed() { is_installed() {
command -v avahi-browse command -v avahi-browse || command -v tailscale
} }
is_configured() { is_configured() {
@@ -30,10 +31,11 @@ slug() {
echo "${s:-share}" echo "${s:-share}"
} }
# /mnt/<host>[-<name>], with -2, -3... if that's taken # /mnt/<host>[-<name>], with -2, -3... if that's taken. The host is its short
# name: box.local and box.tail.example are both /mnt/box.
mount_point() { mount_point() {
local base n=2 point local base n=2 point
base="/mnt/$(slug "${1%.local}")" base="/mnt/$(slug "$(short_host "$1")")"
[ -n "$2" ] && base="$base-$(slug "$2")" [ -n "$2" ] && base="$base-$(slug "$2")"
point="$base" point="$base"
while [ -e "$point" ] || grep -qsF "|$point" "$STORAGE_CONF"; do while [ -e "$point" ] || grep -qsF "|$point" "$STORAGE_CONF"; do
@@ -104,7 +106,7 @@ add_smb() {
smb_fstab_line "$source" "$point" "$credentials" | sudo tee -a /etc/fstab > /dev/null || return 1 smb_fstab_line "$source" "$point" "$credentials" | sudo tee -a /etc/fstab > /dev/null || return 1
sudo systemctl daemon-reload || return 1 sudo systemctl daemon-reload || return 1
sudo systemctl restart "$(systemd-escape -p --suffix=automount "$point")" || return 1 sudo systemctl restart "$(systemd-escape -p --suffix=automount "$point")" || return 1
finish_add smb "$source" "$point" "$share on ${host%.local}" finish_add smb "$source" "$point" "$share on $(short_host "$host")"
} }
remove_smb() { remove_smb() {
@@ -183,7 +185,7 @@ add_sftp() {
sftp_unit "$source" "$point" > "$HOME/.config/systemd/user/$unit" || return 1 sftp_unit "$source" "$point" > "$HOME/.config/systemd/user/$unit" || return 1
systemctl --user daemon-reload systemctl --user daemon-reload
systemctl --user enable --now "$unit" || return 1 systemctl --user enable --now "$unit" || return 1
finish_add sftp "$source" "$point" "${host%.local}${path:+ $(basename "$path")}" finish_add sftp "$source" "$point" "$(short_host "$host")${path:+ $(basename "$path")}"
} }
remove_sftp() { remove_sftp() {
@@ -229,30 +231,50 @@ remove_storage() {
echo "$point is no longer mounted." echo "$point is no longer mounted."
} }
# The file servers on the network: "kind|host|name" per line # The file servers on the network: "kind|host|name" per line. Machines on the
# Core's tailnet don't announce anything there, so each is asked on the SFTP
# (22) and SMB (445) ports; one also found over mDNS is listed by its tailnet
# name only. A port that answers isn't proof, but add_sftp and add_smb say
# what's wrong if it isn't the server they expect.
find_storage() { find_storage() {
local own name type host local own name type host tailnet shorts
own="$(mdns_own_host)" own="$(mdns_own_host)"
tailnet="$(tailnet_hosts)"
shorts="$(for host in $tailnet; do short_host "$host"; done)"
{
mdns_services | while IFS='|' read -r name type host _; do mdns_services | while IFS='|' read -r name type host _; do
[[ "${host,,}" == "${own,,}" ]] && continue [[ "${host,,}" == "${own,,}" ]] && continue
grep -qixF "$(short_host "$host")" <<< "$shorts" && continue
case "$type" in case "$type" in
_smb._tcp) echo "smb|$host|$name" ;; _smb._tcp) echo "smb|$host|$name" ;;
_sftp-ssh._tcp) echo "sftp|$host|$name" ;; _sftp-ssh._tcp) echo "sftp|$host|$name" ;;
esac esac
done | sort -u done
for host in $tailnet; do
( port_open "$host" 22 && echo "sftp|$host|$(short_host "$host")"
port_open "$host" 445 && echo "smb|$host|$(short_host "$host")" ) &
done
wait
} | sort -u
} }
find_and_add() { find_and_add() {
local found kind host name choice i local found kind host name choice i
if tailnet_joined; then
echo "Looking for shared folders on your network and the Core's (Tailscale)..."
else
echo "Looking for shared folders on your network..." echo "Looking for shared folders on your network..."
fi
mapfile -t found < <(find_storage) mapfile -t found < <(find_storage)
if [ ${#found[@]} -eq 0 ]; then if [ ${#found[@]} -eq 0 ]; then
echo "Nothing found. A Mac shares folders over SMB once File Sharing is on (System Settings >" echo "Nothing found. A Mac shares folders over SMB once File Sharing is on (System Settings >"
echo "General > Sharing). Or enter the address instead." echo "General > Sharing). Or enter the address instead."
tailnet_joined || echo "To find the Core's servers away from home too, run: configure tailscale"
return 0 return 0
fi fi
for i in "${!found[@]}"; do for i in "${!found[@]}"; do
IFS='|' read -r kind host name <<< "${found[$i]}" IFS='|' read -r kind host name <<< "${found[$i]}"
is_tailnet_host "$host" && host="$(short_host "$host") (Tailscale)"
printf ' %2d) %-26s %s\n' $((i + 1)) "$host" "$( [ "$kind" = smb ] && echo "SMB shared folders" || echo "SFTP (over SSH)")" printf ' %2d) %-26s %s\n' $((i + 1)) "$host" "$( [ "$kind" = smb ] && echo "SMB shared folders" || echo "SFTP (over SSH)")"
done done
read -rp "Which? " choice read -rp "Which? " choice
+62
View File
@@ -0,0 +1,62 @@
#!/bin/bash
#
# Purpose : Find the other machines on the Core's tailnet, for the configure.d
# items that find servers (storage, ai-servers) beyond the LAN that
# mDNS reaches. Source this file.
# true if this machine is on a tailnet now
tailnet_joined() {
command -v tailscale > /dev/null || return 1
tailscale status --json 2> /dev/null | jq -e '.BackendState == "Running"' > /dev/null 2>&1
}
# The other online computers on the tailnet, one MagicDNS name per line
# (box.tail.example). Phones and tablets are left out: nobody serves files or
# models from them, and each one costs a probe. Nothing if Tailscale isn't
# installed or running.
tailnet_hosts() {
command -v tailscale > /dev/null || return 0
tailscale status --json 2> /dev/null \
| jq -r 'select(.BackendState == "Running") | .Peer // {} | .[]
| select(.Online)
| select(.OS | IN("linux", "macOS", "windows", "freebsd"))
| .DNSName // "" | rtrimstr(".") | select(. != "")' 2> /dev/null \
| sort -u
}
# true if host $1 takes TCP connections on port $2 within 2 seconds
port_open() {
timeout 2 bash -c ': < "/dev/tcp/$1/$2"' _ "$1" "$2" 2> /dev/null
}
# The name to show and to use in paths: box.tail.example -> box, box.local ->
# box. An IP address stays whole.
short_host() {
if [[ "$1" =~ ^[0-9.]+$ || "$1" == *:* ]]; then
echo "$1"
else
echo "${1%%.*}"
fi
}
# true if $1 is a tailnet name rather than a .local one or an address
is_tailnet_host() {
[[ "$1" == *.* && "$1" != *.local && ! "$1" =~ ^[0-9.]+$ && "$1" != *:* ]]
}
# The tailnet's machines, then the hosts in $1 (one per line, e.g. from
# mdns_hosts) that aren't on the tailnet too. A machine at home is both
# box.local and box.tail.example; its tailnet name keeps working away from home.
with_tailnet_hosts() {
local host key
local -A seen=()
for host in $(tailnet_hosts); do
key="$(short_host "${host,,}")"
seen[$key]=1
echo "$host"
done
for host in $1; do
key="$(short_host "${host,,}")"
[ -n "${seen[$key]:-}" ] || echo "$host"
done
}
+106 -2
View File
@@ -2,8 +2,9 @@
load test_helper load test_helper
# The mDNS helper and the configure items built on it (ai-servers, storage), # The mDNS and tailnet helpers and the configure items built on them
# with fake avahi-browse, curl and smbclient. Nothing here touches the network. # (ai-servers, storage), with fake avahi-browse, tailscale, curl and smbclient.
# Nothing here touches the network.
setup() { setup() {
common_setup common_setup
@@ -23,6 +24,11 @@ EOF
export AVAHI export AVAHI
stub avahi-browse 'cat "$AVAHI"' stub avahi-browse 'cat "$AVAHI"'
stub hostnamectl 'echo basement' stub hostnamectl 'echo basement'
# Tailscale is stopped unless a test calls on_tailnet
TAILSCALE_JSON="$BATS_TEST_TMPDIR/tailscale.json"
echo '{"BackendState": "Stopped", "Peer": {}}' > "$TAILSCALE_JSON"
export TAILSCALE_JSON
stub tailscale 'cat "$TAILSCALE_JSON"'
confirm_yes() { return 0; } confirm_yes() { return 0; }
confirm() { return 0; } confirm() { return 0; }
@@ -55,6 +61,73 @@ EOF
[ "$output" = "$(printf 'lab.local\nllm.local\npi-star.local')" ] [ "$output" = "$(printf 'lab.local\nllm.local\npi-star.local')" ]
} }
# --- lib/tailnet.sh ------------------------------------------------------------------
# What tailscale status --json prints on a tailnet with: llm (also on mDNS as
# llm.local), nas (only on the tailnet), an offline machine, a phone, and this
# machine (Self, which isn't a Peer)
on_tailnet() {
cat > "$TAILSCALE_JSON" << 'EOF'
{
"BackendState": "Running",
"Self": {"HostName": "basement", "DNSName": "basement.tail.example.", "OS": "linux", "Online": true},
"Peer": {
"nodekey:1": {"HostName": "LLM", "DNSName": "llm.tail.example.", "OS": "macOS", "Online": true},
"nodekey:2": {"HostName": "nas", "DNSName": "nas.tail.example.", "OS": "linux", "Online": true},
"nodekey:3": {"HostName": "old", "DNSName": "old.tail.example.", "OS": "linux", "Online": false},
"nodekey:4": {"HostName": "phone", "DNSName": "phone.tail.example.", "OS": "iOS", "Online": true}
}
}
EOF
}
@test "tailnet_hosts lists the other online computers, without the trailing dot" {
source "$REPO/configure.d/lib/tailnet.sh"
on_tailnet
run tailnet_hosts
[ "$status" -eq 0 ]
[ "$output" = "$(printf 'llm.tail.example\nnas.tail.example')" ]
tailnet_joined
}
@test "tailnet_hosts lists nothing when Tailscale isn't running" {
source "$REPO/configure.d/lib/tailnet.sh"
run tailnet_hosts
[ "$status" -eq 0 ]
[ -z "$output" ]
refute tailnet_joined
}
@test "tailnet_hosts lists nothing without Tailscale" {
source "$REPO/configure.d/lib/tailnet.sh"
on_tailnet
# A PATH with what tailnet_hosts needs, but no tailscale
mkdir "$BATS_TEST_TMPDIR/path"
for tool in jq sort timeout; do ln -s "$(command -v "$tool")" "$BATS_TEST_TMPDIR/path/"; done
PATH="$BATS_TEST_TMPDIR/path" run tailnet_hosts
[ "$status" -eq 0 ]
[ -z "$output" ]
PATH="$BATS_TEST_TMPDIR/path" refute tailnet_joined
}
@test "short_host shortens tailnet and .local names, not addresses" {
source "$REPO/configure.d/lib/tailnet.sh"
[ "$(short_host box.tail.example)" = box ]
[ "$(short_host box.local)" = box ]
[ "$(short_host box)" = box ]
[ "$(short_host 192.168.0.5)" = 192.168.0.5 ]
is_tailnet_host box.tail.example
refute is_tailnet_host box.local
refute is_tailnet_host 100.64.0.3
}
@test "with_tailnet_hosts lists a machine found both ways once, by its tailnet name" {
source "$REPO/configure.d/lib/tailnet.sh"
on_tailnet
run with_tailnet_hosts "$(printf 'lab.local\nllm.local\npi-star.local')"
[ "$output" = "$(printf 'llm.tail.example\nnas.tail.example\nlab.local\npi-star.local')" ]
}
# --- configure ai-servers -------------------------------------------------------------- # --- configure ai-servers --------------------------------------------------------------
setup_ai() { setup_ai() {
@@ -169,6 +242,21 @@ setup_ai() {
[ ! -e "$SANDBOX_CONF" ] [ ! -e "$SANDBOX_CONF" ]
} }
@test "find_servers asks the machines on the tailnet too, and a machine found both ways once" {
setup_ai
on_tailnet
stub curl 'case "$*" in
*http://llm.tail.example:11434/v1/models*) echo "{\"data\": [{\"id\": \"gemma4:12b\"}]}" ;;
*) exit 7 ;;
esac'
run find_servers
[ "$status" -eq 0 ]
[ "$output" = "llm.tail.example:11434|1" ]
called curl -sf -m 3 http://nas.tail.example:11434/v1/models
called curl -sf -m 3 http://pi-star.local:11434/v1/models
refute grep -qF llm.local "$STUB_LOG"
}
# --- configure storage ------------------------------------------------------------------- # --- configure storage -------------------------------------------------------------------
@test "find_storage lists SMB and SFTP servers, not this machine" { @test "find_storage lists SMB and SFTP servers, not this machine" {
@@ -178,6 +266,21 @@ setup_ai() {
[ "$output" = "$(printf 'sftp|llm.local|llm\nsmb|pi-star.local|PI-STAR')" ] [ "$output" = "$(printf 'sftp|llm.local|llm\nsmb|pi-star.local|PI-STAR')" ]
} }
@test "find_storage asks the machines on the tailnet, and lists one found both ways by its tailnet name" {
source "$REPO/configure.d/60-storage.sh"
on_tailnet
# nas answers on SSH, llm (also llm.local over mDNS) on SSH and SMB
port_open() {
case "$1:$2" in
nas.tail.example:22 | llm.tail.example:22 | llm.tail.example:445) return 0 ;;
*) return 1 ;;
esac
}
run find_storage
[ "$status" -eq 0 ]
[ "$output" = "$(printf 'sftp|llm.tail.example|llm\nsftp|nas.tail.example|nas\nsmb|llm.tail.example|llm\nsmb|pi-star.local|PI-STAR')" ]
}
@test "smb_shares lists disk shares, without admin shares, and passes the password outside the arguments" { @test "smb_shares lists disk shares, without admin shares, and passes the password outside the arguments" {
source "$REPO/configure.d/60-storage.sh" source "$REPO/configure.d/60-storage.sh"
stub smbclient 'echo "PASSWD=$PASSWD" >> "$STUB_LOG" stub smbclient 'echo "PASSWD=$PASSWD" >> "$STUB_LOG"
@@ -204,6 +307,7 @@ printf "Disk|files|Shared files\nDisk|C\$|Default share\nIPC|IPC\$|IPC Service\n
mkdir -p "$(dirname "$STORAGE_CONF")" mkdir -p "$(dirname "$STORAGE_CONF")"
echo "sftp|me@bats-test-host.local:|/mnt/bats-test-host" > "$STORAGE_CONF" echo "sftp|me@bats-test-host.local:|/mnt/bats-test-host" > "$STORAGE_CONF"
[ "$(mount_point bats-test-host.local '')" = /mnt/bats-test-host-2 ] [ "$(mount_point bats-test-host.local '')" = /mnt/bats-test-host-2 ]
[ "$(mount_point bats-test-nas.tail.example '')" = /mnt/bats-test-nas ]
} }
@test "sftp_unit runs sftp-mount as a user service" { @test "sftp_unit runs sftp-mount as a user service" {