improvements to configure

This commit is contained in:
2026-10-29 06:36:51 -06:00
parent 1bd73df94f
commit 7209f7424c
7 changed files with 348 additions and 22 deletions
+35 -2
View File
@@ -14,12 +14,45 @@ is_installed() {
# Tailscale has no status field naming its login server, so tailscale.conf
# records which Core it was set up for
is_configured() {
[ -n "$CORE_DOMAIN" ] && [ "$TAILSCALE_DOMAIN" = "$CORE_DOMAIN" ] \
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