1
0
forked from finn/tinyboard

replace hardcoded hub references with prompts, defaults: oily.dad / armbian / hubkey

This commit is contained in:
Justin Oros
2026-04-16 10:13:48 -07:00
parent b8d2a3e5bc
commit 384cf476ff

View File

@@ -2,7 +2,7 @@
set -euo pipefail
HUB_HOST=""
HUB_USER="armbian"
HUB_USER=""
ARMBIAN_HOME="/home/armbian"
SSH_DIR="$ARMBIAN_HOME/.ssh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -44,6 +44,8 @@ header() { echo -e "\n${CYAN}═════════════════
read -rp "Hub hostname [oily.dad]: " HUB_HOST
HUB_HOST="${HUB_HOST:-oily.dad}"
read -rp "Hub SSH user [armbian]: " HUB_USER
HUB_USER="${HUB_USER:-armbian}"
header "TinyBoard Spoke Setup"
@@ -76,7 +78,8 @@ read -rp "Choose [1/2]: " KEY_CHOICE
case "$KEY_CHOICE" in
1)
KEY_NAME="oilykey"
read -rp "Key name [hubkey]: " KEY_NAME
KEY_NAME="${KEY_NAME:-hubkey}"
KEY_PATH="$SSH_DIR/$KEY_NAME"
mkdir -p "$SSH_DIR"
chown armbian:armbian "$SSH_DIR"
@@ -102,8 +105,8 @@ case "$KEY_CHOICE" in
read -rp "Press ENTER once the key has been added to ${HUB_HOST}..."
;;
2)
read -rp "Enter a name for the key file (e.g. oilykey): " KEY_NAME
KEY_NAME="${KEY_NAME:-oilykey}"
read -rp "Enter a name for the key file [hubkey]: " KEY_NAME
KEY_NAME="${KEY_NAME:-hubkey}"
KEY_PATH="$SSH_DIR/$KEY_NAME"
mkdir -p "$SSH_DIR"
chown armbian:armbian "$SSH_DIR"
@@ -131,7 +134,7 @@ header "Testing SSH Connection"
info "Testing connection to $HUB_HOST..."
retry_or_abort \
"sudo -u armbian ssh -i \"$KEY_PATH\" -o BatchMode=yes -o ConnectTimeout=10 \"$HUB_USER@$HUB_HOST\" exit" \
"SSH connection to $HUB_HOST failed. Check that finn added your public key."
"SSH connection to $HUB_HOST failed. Check that the hub owner added your public key."
header "Finding Available Tunnel Port"
info "Scanning for a free port on $HUB_HOST starting from $START_PORT..."
@@ -147,14 +150,14 @@ for PORT in $(seq "$START_PORT" $((START_PORT + 20))); do
fi
done
[ -n "$TUNNEL_PORT" ] || die "Could not find a free port between $START_PORT and $((START_PORT + 20)). Ask finn to free up a port."
[ -n "$TUNNEL_PORT" ] || die "Could not find a free port between $START_PORT and $((START_PORT + 20)). Ask the hub owner to free up a port."
header "Configuring compose.yaml"
info "Setting port to $TUNNEL_PORT and key to $KEY_NAME..."
sed -i "s|-R [0-9]*:localhost:22|-R ${TUNNEL_PORT}:localhost:22|g" "$COMPOSE"
sed -i "s|-i /home/armbian/.ssh/[^ ]*|-i /home/armbian/.ssh/${KEY_NAME}|g" "$COMPOSE"
sed -i "s|/home/armbian/.ssh/oilykey[^:]*:/home/armbian/.ssh/oilykey[^:]*|${SSH_DIR}/${KEY_NAME}:${SSH_DIR}/${KEY_NAME}|g" "$COMPOSE"
sed -i "s|/home/armbian/.ssh/[^:]*:/home/armbian/.ssh/[^:]*|${SSH_DIR}/${KEY_NAME}:${SSH_DIR}/${KEY_NAME}|g" "$COMPOSE"
sed -i "s|container_name: spoke-autossh|container_name: ${SPOKE_NAME}-autossh|g" "$COMPOSE"
sed -i "s|container_name: spoke-syncthing|container_name: ${SPOKE_NAME}-syncthing|g" "$COMPOSE"
sed -i "s|hostname: spoke-syncthing|hostname: ${SPOKE_NAME}-syncthing|g" "$COMPOSE"