1
0
forked from finn/tinyboard

fix KEY_PATH init, compose.yaml sed, registry write, known_hosts dedup, fusermount3 compat

This commit is contained in:
Justin Oros
2026-04-18 13:34:59 -07:00
parent 26b623eef7
commit aeda90799d
3 changed files with 31 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ set -euo pipefail
RCLONE_CONF="${HOME}/.config/rclone/rclone.conf"
SSH_DIR="${HOME}/.ssh"
REGISTRY="${HOME}/.config/tinyboard/spokes"
RED='\033[0;31m'
GREEN='\033[0;32m'
@@ -76,7 +77,10 @@ header "Checking Tunnel"
info "Scanning spoke host key..."
KEYSCAN=$(ssh-keyscan -p "$TUNNEL_PORT" -H localhost 2>/dev/null)
[ -n "$KEYSCAN" ] || die "Spoke not reachable on port $TUNNEL_PORT — is the tunnel up?"
echo "$KEYSCAN" >> "$SSH_DIR/known_hosts"
KEYSCAN_KEY=$(echo "$KEYSCAN" | awk '{print $3}')
if ! grep -qF "$KEYSCAN_KEY" "$SSH_DIR/known_hosts" 2>/dev/null; then
echo "$KEYSCAN" >> "$SSH_DIR/known_hosts"
fi
info "Verifying spoke is reachable on port $TUNNEL_PORT..."
retry_or_abort \
@@ -128,6 +132,17 @@ else
warn "rclone test failed. Check the remote config in $RCLONE_CONF."
fi
header "Registering Spoke"
mkdir -p "$(dirname "$REGISTRY")"
MOUNT_POINT="${HOME}/mnt/${SPOKE_NAME}"
mkdir -p "$MOUNT_POINT"
if grep -q "^${SPOKE_NAME} " "$REGISTRY" 2>/dev/null; then
warn "$SPOKE_NAME already in registry, updating."
(grep -v "^${SPOKE_NAME} " "$REGISTRY" || true) > "${REGISTRY}.tmp" && mv "${REGISTRY}.tmp" "$REGISTRY"
fi
echo "${SPOKE_NAME} ${TUNNEL_PORT} ${KEY_PATH} ${MOUNT_POINT}" >> "$REGISTRY"
info "$SPOKE_NAME registered."
header "Onboarding Complete"
echo -e " Spoke: ${GREEN}$SPOKE_NAME${NC}"
echo -e " Port: ${GREEN}$TUNNEL_PORT${NC}"