Find storage and AI servers on the tailnet, not only over mDNS
Ports CoreDesktop's 16e5a9c. 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>. Smoketest: 45-tailnet, with a stand-in tailscale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,6 @@ git -C ../coredesktop log --oneline <marker>..HEAD -- configure configure.d sand
|
|||||||
|
|
||||||
Since `4a4a3bd`, to look at:
|
Since `4a4a3bd`, to look at:
|
||||||
|
|
||||||
- [ ] `16e5a9c` Find storage and AI servers on the tailnet, not only over mDNS
|
|
||||||
- [ ] `05b13b2` Test the agent sandbox from inside: port
|
- [ ] `05b13b2` Test the agent sandbox from inside: port
|
||||||
`smoketest/scenarios/60-security.sh`, which runs a script through
|
`smoketest/scenarios/60-security.sh`, which runs a script through
|
||||||
sandbox/bin's wrappers and checks what it can't read, write or reach,
|
sandbox/bin's wrappers and checks what it can't read, write or reach,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ Each item installs what it needs the first time you set it up, after asking.
|
|||||||
- To turn backups off, run `configure backup` again. It also offers to delete the backups from your Nextcloud files (they go to Nextcloud's trash bin).
|
- To turn backups off, run `configure backup` again. It also offers to delete the backups from your Nextcloud files (they go to Nextcloud's trash bin).
|
||||||
- **AI agents**: offers to install Claude Code, opencode and Hermes Agent with each one's own installer, and runs them in a sandbox (see below). `configure claude`, `configure opencode` and `configure hermes` sign in to them and choose their model providers.
|
- **AI agents**: offers to install Claude Code, opencode and Hermes Agent with each one's own installer, and runs them in a sandbox (see below). `configure claude`, `configure opencode` and `configure hermes` sign in to them and choose their model providers.
|
||||||
- **Languages**: installs programming languages and tools with [mise](https://mise.jdx.dev), from mise's own apt repository: Ruby on Rails, or any tool mise knows (`mise registry` lists them), such as `node@lts` or `java@21`. To update them: `mise upgrade`. To remove one: `mise unuse -g <tool>`.
|
- **Languages**: installs programming languages and tools with [mise](https://mise.jdx.dev), from mise's own apt repository: Ruby on Rails, or any tool mise knows (`mise registry` lists them), such as `node@lts` or `java@21`. To update them: `mise upgrade`. To remove one: `mise unuse -g <tool>`.
|
||||||
- **AI servers**: LLM 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:
|
- **AI servers**: LLM 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. Once you've run `configure tailscale`, it also asks the computers on the Core's network, so a laptop away from home still finds them; a machine found both ways is listed once, by its Tailscale name. Or you enter a server's address. For the server you choose, it:
|
||||||
- lets the sandboxed agents reach it (that port only)
|
- lets the sandboxed agents reach it (that port only)
|
||||||
- adds it to opencode with its models
|
- adds it to opencode with its models
|
||||||
- offers to make it Hermes' model
|
- offers to make it Hermes' model
|
||||||
@@ -85,7 +85,7 @@ Each item installs what it needs the first time you set it up, after asking.
|
|||||||
|
|
||||||
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".
|
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".
|
||||||
- **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. Printers already added (e.g. by cups-browsed) are left alone. To choose without being asked, set a default printer or print a test page, run `~/.local/share/federated-connector/connector/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. Printers already added (e.g. by cups-browsed) are left alone. To choose without being asked, set a default printer or print a test page, run `~/.local/share/federated-connector/connector/system/setup-printers.sh --help`.
|
||||||
- **Network storage**: shared folders from other machines on your network, mounted in /mnt and added to the COSMIC 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`).
|
- **Network storage**: shared folders from other machines on your network, mounted in /mnt and added to the COSMIC Files sidebar. It finds SMB servers (Windows, Samba and NAS boxes, and Macs with File Sharing on) and machines you can ssh to. 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 both ways is listed once, by its Tailscale name, and mounted at /mnt/<its short name> either way. 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/federated-connector/smb, readable only by root.
|
- 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/federated-connector/smb, readable only by root.
|
||||||
- An SFTP folder is mounted by sshfs as you, at login, with the SSH keys in your Bitwarden SSH agent or your keyring's, so the server has to accept one of them (it can't ask for a password).
|
- An SFTP folder is mounted by sshfs as you, at login, with the SSH keys in your Bitwarden SSH agent or your keyring's, so the server has to accept one of them (it can't ask for a password).
|
||||||
- "Remove one" unmounts it and takes it back out.
|
- "Remove one" unmounts it and takes it back out.
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ SANDBOX_CONF="$CONF_DIR/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 "$CONNECTOR/configure.d/lib/mdns.sh"
|
source "$CONNECTOR/configure.d/lib/mdns.sh"
|
||||||
|
source "$CONNECTOR/configure.d/lib/tailnet.sh"
|
||||||
source "$CONNECTOR/configure.d/lib/json.sh"
|
source "$CONNECTOR/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
|
||||||
@@ -42,13 +43,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
|
||||||
@@ -200,17 +201,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
|
||||||
echo "Looking for LLM servers on your network..."
|
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..."
|
||||||
|
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
|
||||||
|
|||||||
+36
-14
@@ -13,6 +13,7 @@ STORAGE_CONF="$CONF_DIR/storage"
|
|||||||
# Passwords for SMB shares, readable only by root, which mounts them
|
# Passwords for SMB shares, readable only by root, which mounts them
|
||||||
SMB_CREDENTIALS="/etc/federated-connector/smb"
|
SMB_CREDENTIALS="/etc/federated-connector/smb"
|
||||||
source "$CONNECTOR/configure.d/lib/mdns.sh"
|
source "$CONNECTOR/configure.d/lib/mdns.sh"
|
||||||
|
source "$CONNECTOR/configure.d/lib/tailnet.sh"
|
||||||
source "$CONNECTOR/configure.d/lib/sidebar.sh"
|
source "$CONNECTOR/configure.d/lib/sidebar.sh"
|
||||||
|
|
||||||
is_configured() {
|
is_configured() {
|
||||||
@@ -26,10 +27,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
|
||||||
@@ -101,7 +103,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() {
|
||||||
@@ -177,7 +179,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() {
|
||||||
@@ -219,30 +221,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)"
|
||||||
mdns_services | while IFS='|' read -r name type host _; do
|
tailnet="$(tailnet_hosts)"
|
||||||
[[ "${host,,}" == "${own,,}" ]] && continue
|
shorts="$(for host in $tailnet; do short_host "$host"; done)"
|
||||||
case "$type" in
|
{
|
||||||
_smb._tcp) echo "smb|$host|$name" ;;
|
mdns_services | while IFS='|' read -r name type host _; do
|
||||||
_sftp-ssh._tcp) echo "sftp|$host|$name" ;;
|
[[ "${host,,}" == "${own,,}" ]] && continue
|
||||||
esac
|
grep -qixF "$(short_host "$host")" <<< "$shorts" && continue
|
||||||
done | sort -u
|
case "$type" in
|
||||||
|
_smb._tcp) echo "smb|$host|$name" ;;
|
||||||
|
_sftp-ssh._tcp) echo "sftp|$host|$name" ;;
|
||||||
|
esac
|
||||||
|
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
|
||||||
echo "Looking for shared folders on your network..."
|
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..."
|
||||||
|
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
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ Each run writes its logs to `smoketest/results/<time>/`, one per scenario, and p
|
|||||||
| `20-goa` | `goa-account` with Online Accounts 3.50. It adds Nextcloud and email (quoting a name), adding again changes nothing, and it pauses email and ends the pause. Test a Core takes an unreachable mail server as a sign-in failure, not a wrong password. Removing leaves nothing in the keyring. |
|
| `20-goa` | `goa-account` with Online Accounts 3.50. It adds Nextcloud and email (quoting a name), adding again changes nothing, and it pauses email and ends the pause. Test a Core takes an unreachable mail server as a sign-in failure, not a wrong password. Removing leaves nothing in the keyring. |
|
||||||
| `30-core-local` | Superpanel's entry, Element's config (in ~/.config, or the Flatpak's folder), and the COSMIC Files sidebar. The sidebar check reads and writes ron's pretty format with network places and escaped names, keeps COSMIC Files' defaults, and leaves a file it can't read alone. Then davfs2's secret, read back. |
|
| `30-core-local` | Superpanel's entry, Element's config (in ~/.config, or the Flatpak's folder), and the COSMIC Files sidebar. The sidebar check reads and writes ron's pretty format with network places and escaped names, keeps COSMIC Files' defaults, and leaves a file it can't read alone. Then davfs2's secret, read back. |
|
||||||
| `40-backup` | restic and rclone from apt, with `rclone serve webdav` standing in for Nextcloud and the secrets in the keyring. `system/backup` makes a snapshot that leaves out caches and the install, a file restores from it, and without the passphrase it fails. |
|
| `40-backup` | restic and rclone from apt, with `rclone serve webdav` standing in for Nextcloud and the secrets in the keyring. `system/backup` makes a snapshot that leaves out caches and the install, a file restores from it, and without the passphrase it fails. |
|
||||||
|
| `45-tailnet` | `lib/tailnet.sh` with a stand-in `tailscale`: the other online computers, without phones; nothing when Tailscale is stopped or missing. `configure ai-servers` and `configure storage` ask the tailnet's machines as well as mDNS's, list a machine found both ways once by its tailnet name, and mount a tailnet server at /mnt/<short name>. |
|
||||||
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or Federated Connector's settings, or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
|
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or Federated Connector's settings, or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
|
||||||
| `55-hermes-homeserver` | Hermes' gateway reaches only a Matrix server you've allowed: a server in Hermes' settings is to do until `configure hermes` allows it, a wildcard or escape codes never count, and `configure agents` carries over the server an old drop-in allowed. `edit_json` fills an empty file from its default. |
|
| `55-hermes-homeserver` | Hermes' gateway reaches only a Matrix server you've allowed: a server in Hermes' settings is to do until `configure hermes` allows it, a wildcard or escape codes never count, and `configure agents` carries over the server an old drop-in allowed. `edit_json` fills an empty file from its default. |
|
||||||
| `60-packages` *(all)* | davfs2 installs with `mount.davfs` setuid, and `davfs2_ready` fixes one installed without. sshfs' `fusermount3` and smbclient are where `configure storage` expects them, and so is GTK's CUPS print backend. mise installs from its apt repository and a new bash has it. |
|
| `60-packages` *(all)* | davfs2 installs with `mount.davfs` setuid, and `davfs2_ready` fixes one installed without. sshfs' `fusermount3` and smbclient are where `configure storage` expects them, and so is GTK's CUPS print backend. mise installs from its apt repository and a new bash has it. |
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
# Scenarios set what the runner and items read
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
DESCRIPTION="Storage and AI servers found on the Core's tailnet as well as over mDNS"
|
||||||
|
TIER=quick
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
TAILNET_JSON='{
|
||||||
|
"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}
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
|
||||||
|
scenario() {
|
||||||
|
local bin="$HOME/.local/bin" status_json="$HOME/tailscale.json" probes="$HOME/probes"
|
||||||
|
mkdir -p "$bin"
|
||||||
|
# A stand-in tailscale that prints $status_json for `status --json`
|
||||||
|
printf '#!/bin/bash\ncat %q\n' "$status_json" > "$bin/tailscale"
|
||||||
|
chmod +x "$bin/tailscale"
|
||||||
|
echo '{"BackendState": "Stopped", "Peer": {}}' > "$status_json"
|
||||||
|
|
||||||
|
source "$CONNECTOR/configure.d/lib/tailnet.sh"
|
||||||
|
|
||||||
|
step "lib/tailnet.sh"
|
||||||
|
check_eq "nothing while Tailscale is stopped" "" "$(tailnet_hosts)"
|
||||||
|
check_not "not joined while it's stopped" tailnet_joined
|
||||||
|
echo "$TAILNET_JSON" > "$status_json"
|
||||||
|
check_eq "the other online computers, without phones or the trailing dot" \
|
||||||
|
"$(printf 'llm.tail.example\nnas.tail.example')" "$(tailnet_hosts)"
|
||||||
|
check "joined while it runs" tailnet_joined
|
||||||
|
check_eq "nothing without Tailscale" "" "$(PATH=/usr/bin:/bin tailnet_hosts)"
|
||||||
|
check_eq "short_host shortens a tailnet name" box "$(short_host box.tail.example)"
|
||||||
|
check_eq "and a .local one" box "$(short_host box.local)"
|
||||||
|
check_eq "not an address" 192.168.0.5 "$(short_host 192.168.0.5)"
|
||||||
|
check "box.tail.example is a tailnet name" is_tailnet_host box.tail.example
|
||||||
|
check_not "box.local isn't" is_tailnet_host box.local
|
||||||
|
check_not "nor 100.64.0.3" is_tailnet_host 100.64.0.3
|
||||||
|
check_eq "a machine found both ways is listed once, by its tailnet name" \
|
||||||
|
"$(printf 'llm.tail.example\nnas.tail.example\nlab.local\npi-star.local')" \
|
||||||
|
"$(with_tailnet_hosts "$(printf 'lab.local\nllm.local\npi-star.local')")"
|
||||||
|
|
||||||
|
step "configure ai-servers"
|
||||||
|
source "$CONNECTOR/configure.d/50-ai-servers.sh"
|
||||||
|
mdns_hosts() { printf 'llm.local\npi-star.local\n'; }
|
||||||
|
curl() {
|
||||||
|
echo "$*" >> "$probes"
|
||||||
|
case "$*" in
|
||||||
|
*http://llm.tail.example:11434/v1/models*) echo '{"data": [{"id": "gemma4:12b"}]}' ;;
|
||||||
|
*) return 7 ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
: > "$probes"
|
||||||
|
check_eq "find_servers finds the server on the tailnet" "llm.tail.example:11434|1" "$(find_servers)"
|
||||||
|
check "it asks the machine only on the tailnet" grep -qF http://nas.tail.example:11434/v1/models "$probes"
|
||||||
|
check "and the one only on mDNS" grep -qF http://pi-star.local:11434/v1/models "$probes"
|
||||||
|
check_not "not a machine twice" grep -qF llm.local "$probes"
|
||||||
|
unset -f curl
|
||||||
|
|
||||||
|
step "configure storage"
|
||||||
|
source "$CONNECTOR/configure.d/60-storage.sh"
|
||||||
|
mdns_own_host() { echo basement.local; }
|
||||||
|
mdns_services() {
|
||||||
|
printf '%s\n' 'PI-STAR|_smb._tcp|pi-star.local|192.168.0.9|445|' \
|
||||||
|
'llm|_sftp-ssh._tcp|llm.local|192.168.0.7|22|' \
|
||||||
|
'basement|_smb._tcp|basement.local|192.168.0.2|445|'
|
||||||
|
}
|
||||||
|
port_open() { [ "$1:$2" = nas.tail.example:22 ] || [ "$1:$2" = llm.tail.example:445 ]; }
|
||||||
|
check_eq "find_storage lists each machine once, tailnet ones by their tailnet name" \
|
||||||
|
"$(printf 'sftp|nas.tail.example|nas\nsmb|llm.tail.example|llm\nsmb|pi-star.local|PI-STAR')" \
|
||||||
|
"$(find_storage)"
|
||||||
|
STORAGE_CONF="$HOME/storage"
|
||||||
|
check_eq "a tailnet server mounts at /mnt/<short name>" /mnt/nas-data "$(mount_point nas.tail.example data)"
|
||||||
|
|
||||||
|
rm -f "$bin/tailscale" "$status_json" "$probes"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user