1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/env bash
# april-check.sh: make sure `ssh april` works without a person at the
# keyboard, before a build hands it work. Sourced by build-inc.sh and
# kexec-test.sh; exits the calling script if not.
#
# Tailscale SSH regularly asks for a fresh login ("Tailscale SSH requires
# an additional check. To authenticate, visit: https://login.tailscale.com/
# ..."), and until someone visits that link every ssh waits silently. A
# script then just hangs. So: one short ssh, and if it does not answer in
# time, show what it printed (the link) and stop.
april_check() {
local out
out=$(mktemp)
if timeout 15 ssh -o BatchMode=yes -o ConnectTimeout=10 april true >"$out" 2>&1 </dev/null; then
rm -f "$out"
return 0
fi
echo "april does not answer ssh:" >&2
grep --extended-regexp 'https://login\.tailscale\.com/[^ ]*|.' "$out" | sed 's/^/ /' >&2
if grep --quiet 'login.tailscale.com' "$out"; then
echo "Tailscale SSH wants a fresh login: open the link above, then rerun." >&2
fi
rm -f "$out"
exit 1
}
april_check
|