Files
coredesktop/configure.d/15-tailscale.sh
T
davidandClaude Opus 5.5 9dc5eb193d
shellcheck / shellcheck (push) Failing after 19s
Add upgrade safeguards, hardware setup, sign-in options and Taildrop from Omarchy
Adapted from Omarchy (github.com/omacom/omarchy) for Arch with GNOME:

- A pacman hook stops a full upgrade run without update (pacman -Syu,
  yay -Syu), which would skip the snapshot and update's checks. update
  and install.sh set COREDESKTOP_ALLOW_PACMAN=1, which the hook finds on
  pacman or any process above it; you can set it too.
- When the Arch upgrade stops on files no package owns, update lists
  them and asks to move them to /var/lib/coredesktop/replaced and try
  again, putting back what the retry didn't replace. When packages
  conflict, it runs pacman again so you can choose.
- update and install keep the computer from sleeping until they finish.
- system/hardware.sh (install, and a migration): the Wi-Fi country from
  the time zone, thermald and intel-lpmd on Intel laptops, and Wi-Fi 6
  on Intel BE200/BE211 cards, whose driver gets Wi-Fi 7 wrong.
- configure security-key and configure fingerprint: touch a FIDO2 key
  or a finger instead of typing your password for sudo and polkit,
  falling back to the password. Each shows only when the hardware is
  there. The fingerprint skips to the password with the lid shut.
- webapp: put a website in the app grid as its own app window.
- Taildrop: Files' Scripts > Send with Tailscale, and a user service
  that saves files sent here to Downloads, started when configure
  tailscale joins.
- A NetworkManager dispatcher script pauses a Tailscale exit node while
  you sign in to a captive portal, and resumes it once online.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 12:08:06 -07:00

81 lines
2.8 KiB
Bash

#!/bin/bash
# configure reads TITLE and DESCRIPTION
# shellcheck disable=SC2034
TITLE="Tailscale"
# shellcheck disable=SC2034
DESCRIPTION="Join your Core's Tailscale network"
CORE_CONF="$HOME/.config/coredesktop/core.conf"
TAILSCALE_CONF="$HOME/.config/coredesktop/tailscale.conf"
[ -f "$CORE_CONF" ] && source "$CORE_CONF"
[ -f "$TAILSCALE_CONF" ] && source "$TAILSCALE_CONF"
is_installed() {
command -v tailscale
}
# Tailscale has no status field naming its login server, so tailscale.conf
# records which Core it was set up for
joined() {
[ -n "$TAILSCALE_DOMAIN" ] \
&& tailscale status --json 2> /dev/null | jq -e '.BackendState == "Running"' > /dev/null
}
# Done when on the main Core's network
is_configured() {
[ -n "$CORE_DOMAIN" ] && [ "$TAILSCALE_DOMAIN" = "$CORE_DOMAIN" ] && joined
}
# Log out rather than only go down, so this computer's key is expired on
# headscale and it's off the network until it joins again
leave_network() {
sudo tailscale logout || return 1
rm -f "$TAILSCALE_CONF"
systemctl --user stop coredesktop-taildrop.service 2> /dev/null
echo "This computer has left your Core's Tailscale network. To join again: configure tailscale"
}
run_configure() {
local choice
if joined &> /dev/null; then
echo "This computer is on $TAILSCALE_DOMAIN's Tailscale network (headscale.$TAILSCALE_DOMAIN)."
echo
if [ "$TAILSCALE_DOMAIN" = "$CORE_DOMAIN" ]; then
echo " 1) Join it again"
else
echo " 1) Join your main Core's network instead (headscale.$CORE_DOMAIN)"
fi
echo " 2) Leave the network"
echo " q) Leave it as it is"
echo
read -rp "Choose: " choice
case "$choice" in
1) ;;
2) leave_network; return ;;
*) return 0 ;;
esac
fi
if [ -z "$CORE_DOMAIN" ]; then
echo "This joins your Core's Tailscale network, so set up your Core first: configure core"
return 1
fi
# --reset and --force-reauth move the machine from any other tailnet;
# --operator lets you, and the Tailscale GNOME extension, use it without sudo
if ! systemctl is-active -q tailscaled; then
sudo systemctl enable --now tailscaled || return 1
fi
echo "Open the link below to sign in to your Core's Tailscale network (headscale.$CORE_DOMAIN)."
sudo tailscale up --reset --force-reauth --login-server "https://headscale.$CORE_DOMAIN" \
--accept-routes --operator="$USER" || return 1
mkdir -p "$(dirname "$TAILSCALE_CONF")"
printf 'TAILSCALE_DOMAIN=%q\n' "$CORE_DOMAIN" > "$TAILSCALE_CONF"
# Save files sent here to Downloads (system/taildrop.sh)
systemctl --user restart coredesktop-taildrop.service 2> /dev/null
echo "This computer is on your Core's Tailscale network. To send files to your other"
echo "computers on it, right-click them in Files: Scripts > Send with Tailscale."
}