Set up Pop!_OS for a Federated Core, like CoreDesktop's configure
A port of CoreDesktop's configure to Pop!_OS 24.04 with COSMIC, in the shape of connector-macos: its own install.sh, update and configure, installed in ~/.local/share/federated-connector/connector. Every configure item is ported: the Core (email, calendars and contacts through GNOME Online Accounts and Evolution, as COSMIC has no accounts of its own; Superpanel; files over davfs2; Element; Tally; the email watcher), Tailscale, backups, AI agents in the sandbox and their sign-ins, languages with mise, AI servers, printers, network storage and the agent sandbox. Folders go in the COSMIC Files sidebar. Each item installs what it needs from apt, Flathub or the tool's own apt repository when you set it up. smoketest/run checks it in Ubuntu 24.04 containers with Docker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
# configure reads TITLE and DESCRIPTION
|
||||
# shellcheck disable=SC2034
|
||||
TITLE="Tailscale"
|
||||
# shellcheck disable=SC2034
|
||||
DESCRIPTION="Join your Core's Tailscale network"
|
||||
|
||||
CORE_CONF="$CONF_DIR/core.conf"
|
||||
TAILSCALE_CONF="$CONF_DIR/tailscale.conf"
|
||||
[ -f "$CORE_CONF" ] && source "$CORE_CONF"
|
||||
[ -f "$TAILSCALE_CONF" ] && source "$TAILSCALE_CONF"
|
||||
|
||||
# Tailscale's own installer adds its apt repository (pkgs.tailscale.com), so
|
||||
# Pop!_OS' updates keep it up to date. It's downloaded, then run, rather than
|
||||
# piped into a shell.
|
||||
install_tailscale() {
|
||||
local tmp status
|
||||
echo "Tailscale isn't installed. It comes from Tailscale's own apt repository."
|
||||
confirm_yes "Install it?" || return 1
|
||||
tmp="$(mktemp -d)" || return 1
|
||||
if curl -fsSL --max-time 60 -o "$tmp/install.sh" https://tailscale.com/install.sh; then
|
||||
sh "$tmp/install.sh"
|
||||
status=$?
|
||||
else
|
||||
echo "Couldn't download Tailscale's installer."
|
||||
status=1
|
||||
fi
|
||||
rm -rf "$tmp"
|
||||
return $status
|
||||
}
|
||||
|
||||
# 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"
|
||||
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
|
||||
|
||||
command -v tailscale > /dev/null || install_tailscale || return 1
|
||||
|
||||
# --reset and --force-reauth move the machine from any other tailnet;
|
||||
# --operator lets you 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"
|
||||
echo "This computer is on your Core's Tailscale network."
|
||||
}
|
||||
Reference in New Issue
Block a user