Fix ANSI rendering and Infisical key storage in operator wizard

echo calls in summary/final sections were missing -e flag so ANSI
escape codes printed literally instead of rendering.

Infisical SSH key storage was targeting a non-existent 'bigbrother'
folder, silently failing to store the private key. Removed folder
argument so keys store at root where creds CLI can retrieve them.
This commit is contained in:
Cobra
2026-04-07 15:22:16 -04:00
parent e00769631a
commit 42c05f37e6
+19 -19
View File
@@ -409,25 +409,25 @@ fi
# ══════════════════════════════════════════════════════════════════════════════ # ══════════════════════════════════════════════════════════════════════════════
section "Configuration Summary" section "Configuration Summary"
echo "Device ID: ${BOLD}${DEVICE_ID}${NC}" echo -e "Device ID: ${BOLD}${DEVICE_ID}${NC}"
echo "Hostname: ${BOLD}${BB_HOSTNAME}${NC}" echo -e "Hostname: ${BOLD}${BB_HOSTNAME}${NC}"
echo "Target: ${BOLD}/dev/${DEVICE}${NC}" echo -e "Target: ${BOLD}/dev/${DEVICE}${NC}"
echo "Image: ${BOLD}$(basename $IMAGE)${NC}" echo -e "Image: ${BOLD}$(basename $IMAGE)${NC}"
echo "" echo ""
if [[ "$ROOT_PASS_IS_AUTO" == true ]]; then if [[ "$ROOT_PASS_IS_AUTO" == true ]]; then
echo "Root Pass: ${BOLD}${RED}AUTO-GENERATED — RECORD THIS: ${DEFAULT_ROOT_PASS}${NC}" echo -e "Root Pass: ${BOLD}${RED}AUTO-GENERATED — RECORD THIS: ${DEFAULT_ROOT_PASS}${NC}"
else else
echo "Root Pass: ${BOLD}[custom]${NC}" echo -e "Root Pass: ${BOLD}[custom]${NC}"
fi fi
echo "WiFi: ${BOLD}$([ -n "$WIFI_SSID" ] && echo "$WIFI_SSID" || echo "disabled")${NC}" echo -e "WiFi: ${BOLD}$([ -n "$WIFI_SSID" ] && echo "$WIFI_SSID" || echo "disabled")${NC}"
echo "SSH Mode: ${BOLD}${SSH_MODE}${NC}" echo -e "SSH Mode: ${BOLD}${SSH_MODE}${NC}"
echo "Auto-start: ${BOLD}${BB_MODE}${NC}" echo -e "Auto-start: ${BOLD}${BB_MODE}${NC}"
if [[ "$BB_VPN" == "autossh" ]]; then if [[ "$BB_VPN" == "autossh" ]]; then
echo "VPN: ${BOLD}autossh → ${AUTOSSH_USER}@${AUTOSSH_SERVER}:${AUTOSSH_PORT} (remote port ${AUTOSSH_REMOTE_PORT})${NC}" echo -e "VPN: ${BOLD}autossh → ${AUTOSSH_USER}@${AUTOSSH_SERVER}:${AUTOSSH_PORT} (remote port ${AUTOSSH_REMOTE_PORT})${NC}"
else else
echo "VPN: ${BOLD}${BB_VPN}${NC}" echo -e "VPN: ${BOLD}${BB_VPN}${NC}"
fi fi
echo "Alerter: ${BOLD}$([ -n "$BB_ALERTER_TYPE" ] && echo "$BB_ALERTER_TYPE" || echo "disabled")${NC}" echo -e "Alerter: ${BOLD}$([ -n "$BB_ALERTER_TYPE" ] && echo "$BB_ALERTER_TYPE" || echo "disabled")${NC}"
echo "" echo ""
echo -n -e "${CYAN}Proceed with flashing and configuration? (y/n):${NC} " echo -n -e "${CYAN}Proceed with flashing and configuration? (y/n):${NC} "
@@ -524,8 +524,8 @@ if [[ "$SSH_MODE" == "generate" ]]; then
echo "$PUBKEY" > "${SSH_DIR}/authorized_keys" echo "$PUBKEY" > "${SSH_DIR}/authorized_keys"
INFISICAL_KEY="SSH_PRIVKEY_$(echo "$DEVICE_ID" | tr '[:lower:]-' '[:upper:]_')" INFISICAL_KEY="SSH_PRIVKEY_$(echo "$DEVICE_ID" | tr '[:lower:]-' '[:upper:]_')"
if [[ -x "$CREDS" ]] && "$CREDS" set "$INFISICAL_KEY" "$PRIVKEY" bigbrother 2>/dev/null; then if [[ -x "$CREDS" ]] && "$CREDS" set "$INFISICAL_KEY" "$PRIVKEY" 2>/dev/null; then
info "Private key stored in Infisical: bigbrother/${INFISICAL_KEY}" info "Private key stored in Infisical: ${INFISICAL_KEY}"
else else
warn "Could not store in Infisical. SAVE THIS PRIVATE KEY:" warn "Could not store in Infisical. SAVE THIS PRIVATE KEY:"
echo "---" echo "---"
@@ -770,7 +770,7 @@ info "SD card ready to remove"
# ══════════════════════════════════════════════════════════════════════════════ # ══════════════════════════════════════════════════════════════════════════════
section "Setup Complete" section "Setup Complete"
echo "${GREEN}Insert SD card into device and power on.${NC}" echo -e "${GREEN}Insert SD card into device and power on.${NC}"
echo "" echo ""
echo "The device will:" echo "The device will:"
echo " 1. Boot and connect to WiFi (if configured)" echo " 1. Boot and connect to WiFi (if configured)"
@@ -782,12 +782,12 @@ echo " 6. Send alerter webhook (if configured)"
echo "" echo ""
echo "No further operator interaction required. Device walks away autonomously." echo "No further operator interaction required. Device walks away autonomously."
echo "" echo ""
echo "${CYAN}To SSH after first-boot:${NC}" echo -e "${CYAN}To SSH after first-boot:${NC}"
if [[ "$SSH_MODE" == "generate" ]]; then if [[ "$SSH_MODE" == "generate" ]]; then
INFISICAL_KEY="SSH_PRIVKEY_$(echo "$DEVICE_ID" | tr '[:lower:]-' '[:upper:]_')" INFISICAL_KEY="SSH_PRIVKEY_$(echo "$DEVICE_ID" | tr '[:lower:]-' '[:upper:]_')"
if [[ -x "$CREDS" ]]; then if [[ -x "$CREDS" ]]; then
echo " ${CREDS} get ${INFISICAL_KEY} bigbrother > /tmp/${DEVICE_ID}.key" echo " ${CREDS} get ${INFISICAL_KEY} > /tmp/${DEVICE_ID}.key"
echo " chmod 600 /tmp/${DEVICE_ID}.key" echo " chmod 600 /tmp/${DEVICE_ID}.key"
echo " ssh -i /tmp/${DEVICE_ID}.key root@<DEVICE_IP>" echo " ssh -i /tmp/${DEVICE_ID}.key root@<DEVICE_IP>"
fi fi
@@ -798,13 +798,13 @@ fi
echo "" echo ""
if [[ "$BB_VPN" == "autossh" ]]; then if [[ "$BB_VPN" == "autossh" ]]; then
echo "" echo ""
echo "${CYAN}Tunnel connection (after first boot):${NC}" echo -e "${CYAN}Tunnel connection (after first boot):${NC}"
echo " From operator server: ssh -p ${AUTOSSH_REMOTE_PORT} root@127.0.0.1" echo " From operator server: ssh -p ${AUTOSSH_REMOTE_PORT} root@127.0.0.1"
echo " One-liner from anywhere (requires GatewayPorts yes on server):" echo " One-liner from anywhere (requires GatewayPorts yes on server):"
echo " ssh -p ${AUTOSSH_REMOTE_PORT} root@${AUTOSSH_SERVER}" echo " ssh -p ${AUTOSSH_REMOTE_PORT} root@${AUTOSSH_SERVER}"
fi fi
echo "" echo ""
echo "${CYAN}Monitor first-boot:${NC}" echo -e "${CYAN}Monitor first-boot:${NC}"
echo " ssh root@<DEVICE_IP> 'tail -f /root/bb-firstboot.log'" echo " ssh root@<DEVICE_IP> 'tail -f /root/bb-firstboot.log'"
echo "" echo ""