move tailscale to own configure step
This commit is contained in:
+2
-24
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
TITLE="Federated Computer Core"
|
||||
DESCRIPTION="Superpanel, Tailscale, Nextcloud, email, files and Element"
|
||||
DESCRIPTION="Superpanel, Nextcloud, email, files and Element"
|
||||
|
||||
# What you entered last time, so running this again only does what's missing
|
||||
CORE_CONF="$HOME/.config/coredesktop/core.conf"
|
||||
@@ -24,13 +24,6 @@ superpanel_done() {
|
||||
[ -f "$SUPERPANEL_DESKTOP" ]
|
||||
}
|
||||
|
||||
# Tailscale has no status field naming its login server, so core.conf
|
||||
# records that it was set up for this Core
|
||||
tailscale_done() {
|
||||
[ "$CORE_TAILSCALE" = "$CORE_DOMAIN" ] \
|
||||
&& tailscale status --json 2> /dev/null | jq -e '.BackendState == "Running"' > /dev/null
|
||||
}
|
||||
|
||||
nextcloud_done() {
|
||||
"$GOA_ACCOUNT" exists owncloud "$CORE_USER@nextcloud.$CORE_DOMAIN" 2> /dev/null
|
||||
}
|
||||
@@ -58,7 +51,7 @@ element_done() {
|
||||
is_configured() {
|
||||
[ -n "$CORE_DOMAIN" ] || return 1
|
||||
core_names
|
||||
superpanel_done && tailscale_done && nextcloud_done && email_done && files_done && element_done
|
||||
superpanel_done && nextcloud_done && email_done && files_done && element_done
|
||||
}
|
||||
|
||||
save_conf() {
|
||||
@@ -67,7 +60,6 @@ save_conf() {
|
||||
printf 'CORE_DOMAIN=%q\n' "$CORE_DOMAIN"
|
||||
printf 'CORE_EMAIL=%q\n' "$CORE_EMAIL"
|
||||
printf 'CORE_NAME=%q\n' "$CORE_NAME"
|
||||
printf 'CORE_TAILSCALE=%q\n' "$CORE_TAILSCALE"
|
||||
} > "$CORE_CONF"
|
||||
}
|
||||
|
||||
@@ -100,19 +92,6 @@ setup_superpanel() {
|
||||
echo "Added Superpanel to your applications."
|
||||
}
|
||||
|
||||
setup_tailscale() {
|
||||
# --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."
|
||||
sudo tailscale up --reset --force-reauth --login-server "https://headscale.$CORE_DOMAIN" \
|
||||
--accept-routes --operator="$USER" || return 1
|
||||
CORE_TAILSCALE="$CORE_DOMAIN"
|
||||
save_conf
|
||||
}
|
||||
|
||||
setup_nextcloud() {
|
||||
[ -n "$APP_PASSWORD" ] || { echo "This needs your Core password, and Nextcloud didn't accept it."; return 1; }
|
||||
"$GOA_ACCOUNT" add << EOF || return 1
|
||||
@@ -320,7 +299,6 @@ run_configure() {
|
||||
|
||||
echo
|
||||
step superpanel "Superpanel in your applications"
|
||||
step tailscale "Tailscale with your Core (headscale.$CORE_DOMAIN)"
|
||||
step nextcloud "Nextcloud in Online Accounts"
|
||||
step email "Email in Online Accounts"
|
||||
step files "Nextcloud files at $MOUNT"
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
TITLE="Tailscale"
|
||||
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
|
||||
is_configured() {
|
||||
[ -n "$CORE_DOMAIN" ] && [ "$TAILSCALE_DOMAIN" = "$CORE_DOMAIN" ] \
|
||||
&& tailscale status --json 2> /dev/null | jq -e '.BackendState == "Running"' > /dev/null
|
||||
}
|
||||
|
||||
run_configure() {
|
||||
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"
|
||||
echo "This computer is on your Core's Tailscale network."
|
||||
}
|
||||
Reference in New Issue
Block a user