Taildrop to Downloads, exit nodes past captive portals, stay awake
Ports the rest of CoreDesktop's 9dc5eb1 that applies to Pop!_OS. - configure tailscale turns on federated-connector-taildrop.service, which saves files sent here with Taildrop to Downloads and says so in a notification. COSMIC Files has no Scripts menu, so CoreDesktop's "Send with Tailscale" isn't ported; send with tailscale file cp. Leaving the network turns it off. - It also installs a NetworkManager dispatcher script that stops using a Tailscale exit node while you sign in to a captive portal, and uses it again once online. Pop!_OS checks connectivity (20-connectivity-pop), so NetworkManager sees the portal. - A computer joined before this shows Tailscale as to do, and configure tailscale adds both without signing in again. update restarts the Taildrop service on the new version, as it does the email watcher. - install.sh keeps the computer from sleeping until an install or update finishes. The pacman guard, unowned files and hardware.sh are Arch only. Smoketest: 75-taildrop-portal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
# shellcheck shell=bash
|
||||
# Scenarios set what the runner and items read
|
||||
# shellcheck disable=SC2034
|
||||
DESCRIPTION="Taildrop saves files to Downloads; an exit node pauses for a captive portal"
|
||||
TIER=quick
|
||||
|
||||
scenario() {
|
||||
local bin="$HOME/.local/bin" calls="$HOME/tailscale-calls" status_json="$HOME/tailscale.json"
|
||||
local portal="$CONNECTOR/system/captive-portal" state="$HOME/exit-node-paused" sent="$HOME/sent" pid i
|
||||
mkdir -p "$bin"
|
||||
# A stand-in tailscale: `status --json` prints $status_json, and every call
|
||||
# is recorded
|
||||
cat > "$bin/tailscale" << EOF
|
||||
#!/bin/bash
|
||||
echo "\$*" >> "$calls"
|
||||
case "\$1 \$2" in
|
||||
"status --json") cat "$status_json" ;;
|
||||
"file get")
|
||||
# The first call receives two files; later ones wait, as with nothing sent
|
||||
if [ ! -e "$HOME/received-once" ]; then
|
||||
touch "$HOME/received-once"
|
||||
echo "wrote /home/pop/Downloads/a.txt as /home/pop/Downloads/a.txt (12 bytes)"
|
||||
echo "wrote /home/pop/Downloads/b b.pdf as /home/pop/Downloads/b b (1).pdf (3400 bytes)"
|
||||
else
|
||||
sleep 30
|
||||
fi ;;
|
||||
esac
|
||||
EOF
|
||||
chmod +x "$bin/tailscale"
|
||||
printf '#!/bin/bash\nprintf "%%s\\n" "$@" > %q\n' "$sent" > "$bin/notify-send"
|
||||
chmod +x "$bin/notify-send"
|
||||
|
||||
step "system/captive-portal"
|
||||
echo '{"ExitNodeStatus": {"TailscaleIPs": ["100.64.0.9/32"]}}' > "$status_json"
|
||||
: > "$calls"
|
||||
CAPTIVE_PORTAL_STATE="$state" CONNECTIVITY_STATE=PORTAL "$portal" wlan0 up
|
||||
check_not "it does nothing but on a connectivity change" grep -q "^set" "$calls"
|
||||
CAPTIVE_PORTAL_STATE="$state" CONNECTIVITY_STATE=PORTAL "$portal" wlan0 connectivity-change
|
||||
check "behind a portal, it stops using the exit node" grep -qx "set --exit-node=" "$calls"
|
||||
check_eq "and remembers it" 100.64.0.9 "$(cat "$state")"
|
||||
echo '{"ExitNodeStatus": null}' > "$status_json"
|
||||
: > "$calls"
|
||||
CAPTIVE_PORTAL_STATE="$state" CONNECTIVITY_STATE=FULL "$portal" wlan0 connectivity-change
|
||||
check "online again, it uses it again" grep -qx "set --exit-node=100.64.0.9" "$calls"
|
||||
check_not "and forgets it" test -e "$state"
|
||||
echo 100.64.0.9 > "$state"
|
||||
echo '{"ExitNodeStatus": {"TailscaleIPs": ["100.64.0.7/32"]}}' > "$status_json"
|
||||
: > "$calls"
|
||||
CAPTIVE_PORTAL_STATE="$state" CONNECTIVITY_STATE=FULL "$portal" wlan0 connectivity-change
|
||||
check_not "but not if you've picked another one meanwhile" grep -q "^set" "$calls"
|
||||
echo '{"ExitNodeStatus": null}' > "$status_json"
|
||||
: > "$calls"
|
||||
CAPTIVE_PORTAL_STATE="$state" CONNECTIVITY_STATE=PORTAL "$portal" wlan0 connectivity-change
|
||||
check_not "without an exit node, a portal changes nothing" grep -q "^set" "$calls"
|
||||
|
||||
step "system/taildrop"
|
||||
: > "$calls"
|
||||
"$CONNECTOR/system/taildrop" &
|
||||
pid=$!
|
||||
for i in $(seq 50); do [ -s "$sent" ] && break; sleep 0.1; done
|
||||
pkill -P "$pid" 2> /dev/null; kill "$pid" 2> /dev/null
|
||||
check "it receives into Downloads" grep -q "file get --wait --conflict=rename --verbose $HOME/Downloads" "$calls"
|
||||
check "Downloads is there" test -d "$HOME/Downloads"
|
||||
check "the notification counts the files" grep -qx "Received 2 files" "$sent"
|
||||
check "and names them" grep -qx "b b (1).pdf" "$sent"
|
||||
|
||||
step "configure tailscale's Taildrop and captive portal"
|
||||
export DISPATCHER_DIR="$HOME/dispatcher.d"
|
||||
source "$CONNECTOR/configure.d/15-tailscale.sh"
|
||||
# No systemd user manager or root here
|
||||
systemctl() { case "$*" in *is-enabled*) [ -e "$UNITS/enabled" ] ;; *enable*) touch "$UNITS/enabled" ;; esac; }
|
||||
sudo() { if [ "$1" = install ]; then install -D -m 755 "${@: -2:1}" "${@: -1}"; else "$@"; fi; }
|
||||
check_not "not set up yet" extras_ok
|
||||
check "install_extras" install_extras
|
||||
check "the service is installed" cmp -s "$CONNECTOR/system/systemd/$TAILDROP_UNIT" "$UNITS/$TAILDROP_UNIT"
|
||||
check "the captive portal script is" test -x "$CAPTIVE_PORTAL"
|
||||
check "extras_ok" extras_ok
|
||||
echo "# older" >> "$CAPTIVE_PORTAL"
|
||||
check_not "an older captive portal script isn't" extras_ok
|
||||
remove_extras
|
||||
check_not "remove_extras removes the service" test -e "$UNITS/$TAILDROP_UNIT"
|
||||
unset -f systemctl sudo
|
||||
unset DISPATCHER_DIR
|
||||
|
||||
rm -rf "$bin/tailscale" "$bin/notify-send" "$calls" "$status_json" "$sent" "$HOME/received-once" \
|
||||
"$HOME/dispatcher.d" "$HOME/Downloads" "$state"
|
||||
}
|
||||
Reference in New Issue
Block a user