expanded lab script maybe we need to switvh to smoething other than bash soon
This commit is contained in:
parent
9274ab1e17
commit
4cb3852039
1 changed files with 77 additions and 49 deletions
|
@ -1,5 +1,11 @@
|
||||||
{ lib, stdenv, writeShellScriptBin, rsync, openssh, ... }:
|
{
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
writeShellScriptBin,
|
||||||
|
rsync,
|
||||||
|
openssh,
|
||||||
|
...
|
||||||
|
}:
|
||||||
writeShellScriptBin "lab" ''
|
writeShellScriptBin "lab" ''
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
@ -62,7 +68,7 @@ writeShellScriptBin "lab" ''
|
||||||
local target_host="sma@grey-area"
|
local target_host="sma@grey-area"
|
||||||
;;
|
;;
|
||||||
"reverse-proxy")
|
"reverse-proxy")
|
||||||
local target_host="sma@reverse-proxy"
|
local target_host="sma@reverse-proxy.tail807ea.ts.net"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "Unknown machine: $machine"
|
error "Unknown machine: $machine"
|
||||||
|
@ -141,20 +147,42 @@ writeShellScriptBin "lab" ''
|
||||||
# Test SSH connectivity with debug info if in verbose mode
|
# Test SSH connectivity with debug info if in verbose mode
|
||||||
if [[ $verbose -eq 1 ]]; then
|
if [[ $verbose -eq 1 ]]; then
|
||||||
log "Testing SSH connection to $machine (LAN)..."
|
log "Testing SSH connection to $machine (LAN)..."
|
||||||
${openssh}/bin/ssh -v -o ConnectTimeout=5 -o BatchMode=yes "$ssh_user@$machine" "echo ✓ SSH connection to $machine successful" 2>&1 | grep -E '(debug1|Authentication|Connection)'
|
${openssh}/bin/ssh -v -o ConnectTimeout=5 -o BatchMode=yes "$ssh_user@$machine" "echo ✓ SSH connection to $machine successful" 2>&1
|
||||||
|
|
||||||
log "Testing SSH connection to $machine.tailnet (Tailscale)..."
|
# Use specific hostname for reverse-proxy
|
||||||
${openssh}/bin/ssh -v -o ConnectTimeout=5 -o BatchMode=yes "$ssh_user@$machine.tailnet" "echo ✓ SSH connection to $machine.tailnet successful" 2>&1 | grep -E '(debug1|Authentication|Connection)'
|
if [[ "$machine" == "reverse-proxy" ]]; then
|
||||||
|
log "Testing SSH connection to reverse-proxy.tail807ea.ts.net (Tailscale)..."
|
||||||
|
${openssh}/bin/ssh -v -o ConnectTimeout=5 -o BatchMode=yes "$ssh_user@reverse-proxy.tail807ea.ts.net" "echo ✓ SSH connection to reverse-proxy.tail807ea.ts.net successful" 2>&1
|
||||||
|
else
|
||||||
|
log "Testing SSH connection to $machine.tailnet (Tailscale)..."
|
||||||
|
${openssh}/bin/ssh -v -o ConnectTimeout=5 -o BatchMode=yes "$ssh_user@$machine.tailnet" "echo ✓ SSH connection to $machine.tailnet successful" 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Try with normal SSH first (for LAN)
|
# For reverse-proxy, try Tailscale first as it's likely only accessible that way
|
||||||
if ${openssh}/bin/ssh -o ConnectTimeout=2 -o BatchMode=yes "$ssh_user@$machine" "echo OK" >/dev/null 2>&1; then
|
if [[ "$machine" == "reverse-proxy" ]]; then
|
||||||
success " $machine: ✓ Online (LAN)"
|
# Use the specific Tailscale hostname for reverse-proxy
|
||||||
# Try with Tailscale hostname as fallback
|
if ${openssh}/bin/ssh -o ConnectTimeout=5 -o BatchMode=yes "$ssh_user@reverse-proxy.tail807ea.ts.net" "echo OK" >/dev/null 2>&1; then
|
||||||
elif ${openssh}/bin/ssh -o ConnectTimeout=2 -o BatchMode=yes "$ssh_user@$machine.tailnet" "echo OK" >/dev/null 2>&1; then
|
success " $machine: ✓ Online (Tailscale)"
|
||||||
success " $machine: ✓ Online (Tailscale)"
|
elif ${openssh}/bin/ssh -o ConnectTimeout=2 -o BatchMode=yes "$ssh_user@$machine" "echo OK" >/dev/null 2>&1; then
|
||||||
|
success " $machine: ✓ Online (LAN)"
|
||||||
|
else
|
||||||
|
warn " $machine: ⚠ Unreachable"
|
||||||
|
if [[ $verbose -eq 1 ]]; then
|
||||||
|
log " ℹ️ Note: reverse-proxy is likely only accessible via Tailscale"
|
||||||
|
log " ℹ️ Check if Tailscale is running on both machines and if the SSH service is active"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# For other machines, try LAN first then Tailscale as fallback
|
||||||
else
|
else
|
||||||
warn " $machine: ⚠ Unreachable"
|
if ${openssh}/bin/ssh -o ConnectTimeout=2 -o BatchMode=yes "$ssh_user@$machine" "echo OK" >/dev/null 2>&1; then
|
||||||
|
success " $machine: ✓ Online (LAN)"
|
||||||
|
# Try with Tailscale hostname as fallback
|
||||||
|
elif ${openssh}/bin/ssh -o ConnectTimeout=3 -o BatchMode=yes "$ssh_user@$machine.tailnet" "echo OK" >/dev/null 2>&1; then
|
||||||
|
success " $machine: ✓ Online (Tailscale)"
|
||||||
|
else
|
||||||
|
warn " $machine: ⚠ Unreachable"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue