add the offscale line, and fix a set -e bug the test exposed
The menu is one function now rather than being written out twice — it is shown
again after ? prints the long answer — and option 1 carries your line: offscale is
just tailscale and headscale, with our own sugar on top.
The bug it surfaced is the more useful half. load_answers used
[[ -z "${MACHINE_ROLE:-}" ]] && MACHINE_ROLE="$value"
as the last statement in a while-read loop body. When the variable is already set
the test is false, the compound returns non-zero, and as the final statement in a
loop body under `set -e` that ends the script. The failure is silent about its
cause: the trap prints "Step: unknown" and a line number inside the library,
before pre-flight has run.
It needed both conditions to appear — an answers file on disk AND the variables
already set in the environment — which is why every earlier test missed it and
running with env overrides hit it immediately. Written as if/then now, and the
other lib files scanned for the same shape.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -120,10 +120,17 @@ load_answers() {
|
|||||||
[[ "$key" =~ ^[A-Z_]+$ ]] || continue
|
[[ "$key" =~ ^[A-Z_]+$ ]] || continue
|
||||||
[[ -n "$value" ]] || continue
|
[[ -n "$value" ]] || continue
|
||||||
# The environment wins over what was saved.
|
# The environment wins over what was saved.
|
||||||
|
#
|
||||||
|
# Written as if/then rather than `[[ … ]] && assign`. That form returns
|
||||||
|
# non-zero when the test is false, and as the last statement in a loop body
|
||||||
|
# under `set -e` it takes the whole script down — which is exactly what
|
||||||
|
# happened the first time this ran with the variables already set in the
|
||||||
|
# environment: the file loaded fine, every value was already present, and the
|
||||||
|
# run died at "Step: unknown" before pre-flight.
|
||||||
case "$key" in
|
case "$key" in
|
||||||
MACHINE_ROLE) [[ -z "${MACHINE_ROLE:-}" ]] && MACHINE_ROLE="$value" ;;
|
MACHINE_ROLE) if [[ -z "${MACHINE_ROLE:-}" ]]; then MACHINE_ROLE="$value"; fi ;;
|
||||||
SETUP_USERNAME) [[ -z "${SETUP_USERNAME:-}" ]] && SETUP_USERNAME="$value" ;;
|
SETUP_USERNAME) if [[ -z "${SETUP_USERNAME:-}" ]]; then SETUP_USERNAME="$value"; fi ;;
|
||||||
OFFICER_ROOT) [[ -z "${OFFICER_ROOT:-}" ]] && OFFICER_ROOT="$value" ;;
|
OFFICER_ROOT) if [[ -z "${OFFICER_ROOT:-}" ]]; then OFFICER_ROOT="$value"; fi ;;
|
||||||
esac
|
esac
|
||||||
done <"$ANSWERS_FILE"
|
done <"$ANSWERS_FILE"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,20 @@ tailscale_help() {
|
|||||||
echo " lock you out of the machine, so there is always a second way in."
|
echo " lock you out of the machine, so there is always a second way in."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The menu itself, in a function because it is shown twice — once to ask, and
|
||||||
|
# again after ? has printed the long answer, so the reader is not dropped back at
|
||||||
|
# a bare prompt having forgotten what the options were.
|
||||||
|
tailscale_network_menu() {
|
||||||
|
info "Which network should this machine join?"
|
||||||
|
echo ""
|
||||||
|
echo " [1] set up your own network (offscale)"
|
||||||
|
echo " offscale is just tailscale and headscale, with our own sugar on top"
|
||||||
|
echo " [2] use a network you already run (headscale, offscale)"
|
||||||
|
echo " [3] the easy route (tailscale.com)"
|
||||||
|
echo " [?] what are tailscale, headscale and offscale?"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
# The long answer, printed when somebody types ?. Covers all three names,
|
# The long answer, printed when somebody types ?. Covers all three names,
|
||||||
# because the menu offers all three and two of them are not words anyone outside
|
# because the menu offers all three and two of them are not words anyone outside
|
||||||
# this project would know.
|
# this project would know.
|
||||||
|
|||||||
@@ -441,13 +441,7 @@ if ! skip; then
|
|||||||
SUMMARY+=("Tailscale: connected, unchanged ($(tailscale_ip))")
|
SUMMARY+=("Tailscale: connected, unchanged ($(tailscale_ip))")
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
info "Which network should this machine join?"
|
tailscale_network_menu
|
||||||
echo ""
|
|
||||||
echo " [1] set up your own network (offscale)"
|
|
||||||
echo " [2] use a network you already run (headscale, offscale)"
|
|
||||||
echo " [3] the easy route (tailscale.com)"
|
|
||||||
echo " [?] what are tailscale, headscale and offscale?"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
TS_LOGIN_SERVER=""
|
TS_LOGIN_SERVER=""
|
||||||
TS_PLANE=""
|
TS_PLANE=""
|
||||||
@@ -478,13 +472,7 @@ if ! skip; then
|
|||||||
echo ""
|
echo ""
|
||||||
tailscale_networks_help
|
tailscale_networks_help
|
||||||
echo ""
|
echo ""
|
||||||
info "Which network should this machine join?"
|
tailscale_network_menu
|
||||||
echo ""
|
|
||||||
echo " [1] set up your own network (offscale)"
|
|
||||||
echo " [2] use a network you already run (headscale, offscale)"
|
|
||||||
echo " [3] the easy route (tailscale.com)"
|
|
||||||
echo " [?] what are tailscale, headscale and offscale?"
|
|
||||||
echo ""
|
|
||||||
;;
|
;;
|
||||||
*) warn "Pick 1, 2, 3 or ?." ;;
|
*) warn "Pick 1, 2, 3 or ?." ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user