forked from finn/tinyboard
fix ARMBIAN_HOME unbound variable, retry_or_abort quoting, and hardcoded path in sed
This commit is contained in:
@@ -3,8 +3,7 @@ set -euo pipefail
|
||||
|
||||
HUB_HOST=""
|
||||
HUB_USER=""
|
||||
ARMBIAN_HOME="/home/$SPOKE_USER"
|
||||
SSH_DIR="$ARMBIAN_HOME/.ssh"
|
||||
SPOKE_USER=""
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SPOKE_DIR="$SCRIPT_DIR"
|
||||
COMPOSE="$SPOKE_DIR/compose.yaml"
|
||||
@@ -48,6 +47,8 @@ read -rp "Hub SSH user [armbian]: " HUB_USER
|
||||
HUB_USER="${HUB_USER:-armbian}"
|
||||
read -rp "Spoke local user [armbian]: " SPOKE_USER
|
||||
SPOKE_USER="${SPOKE_USER:-armbian}"
|
||||
ARMBIAN_HOME="/home/$SPOKE_USER"
|
||||
SSH_DIR="$ARMBIAN_HOME/.ssh"
|
||||
|
||||
header "TinyBoard Spoke Setup"
|
||||
|
||||
@@ -195,7 +196,7 @@ sudo -u "$SPOKE_USER" ssh-keyscan -H "$HUB_HOST" >> "$SSH_DIR/known_hosts" 2>/de
|
||||
header "Testing SSH Connection"
|
||||
info "Testing connection to $HUB_HOST..."
|
||||
retry_or_abort \
|
||||
"sudo -u "$SPOKE_USER" ssh -i \"$KEY_PATH\" -o BatchMode=yes -o ConnectTimeout=10 \"$HUB_USER@$HUB_HOST\" exit" \
|
||||
"sudo -u \"$SPOKE_USER\" ssh -i \"$KEY_PATH\" -o BatchMode=yes -o ConnectTimeout=10 \"$HUB_USER@$HUB_HOST\" exit" \
|
||||
"SSH connection to $HUB_HOST failed. Check that the hub owner added your public key."
|
||||
|
||||
header "Finding Available Tunnel Port"
|
||||
@@ -218,7 +219,7 @@ 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|-i /home/[^ ]*/\.ssh/[^ ]*|-i ${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"
|
||||
|
||||
Reference in New Issue
Block a user