feat!: claudebox becomes box — the Claude box is one template among several #52
2 changed files with 27 additions and 17 deletions
15
bin/box
15
bin/box
|
|
@ -472,7 +472,7 @@ wait_agent() {
|
|||
local n="$1" i
|
||||
echo "box: waiting for instance agent..."
|
||||
for i in $(seq 1 90); do
|
||||
if incus exec "$n" -- true >/dev/null 2>&1; then return; fi
|
||||
if incus exec "$n" -- true </dev/null >/dev/null 2>&1; then return; fi
|
||||
[ "$i" -eq 90 ] && die "instance agent never came up (incus console $n to inspect)"
|
||||
sleep 2
|
||||
done
|
||||
|
|
@ -500,7 +500,7 @@ reset_identity() {
|
|||
systemd-machine-id-setup >/dev/null 2>&1 || dbus-uuidgen > /etc/machine-id
|
||||
ln -sf /etc/machine-id /var/lib/dbus/machine-id
|
||||
test -s /etc/machine-id
|
||||
' || die "could not reset the clone's machine-id"
|
||||
' </dev/null || die "could not reset the clone's machine-id"
|
||||
# The new id only takes effect at boot. Ask nicely, then insist — a clone that
|
||||
# keeps its source's DHCP lease is worse than an unclean stop of a box that
|
||||
# booted 30 seconds ago.
|
||||
|
|
@ -592,15 +592,20 @@ cmd_new() {
|
|||
# A failed cloud-init used to print a screen of dots and the word "error",
|
||||
# with nothing to act on — the box's own log holds the reason, and nobody
|
||||
# was told it existed. Show it, and leave the box up to inspect.
|
||||
if ! incus exec "$instance" -- cloud-init status --wait; then
|
||||
# Every non-interactive exec pins stdin. With a TTY on stdin, 'incus exec'
|
||||
# goes interactive — and when box's own output is redirected (a script, the
|
||||
# drill), the session can wedge open after the remote command has exited,
|
||||
# blocking forever on a websocket that will never close. Caught live: a
|
||||
# mint stuck at 'status: done'. Only shell/exec/tmux may own the terminal.
|
||||
if ! incus exec "$instance" -- cloud-init status --wait </dev/null; then
|
||||
echo >&2
|
||||
echo "box: cloud-init FAILED in $name. What it says:" >&2
|
||||
incus exec "$instance" -- cloud-init status --long 2>&1 | sed 's/^/ /' >&2
|
||||
incus exec "$instance" -- cloud-init status --long </dev/null 2>&1 | sed 's/^/ /' >&2
|
||||
echo >&2
|
||||
echo "box: the errors, from the box's log:" >&2
|
||||
incus exec "$instance" -- sh -c \
|
||||
"grep -iE '^(E:|Err:)|Temporary failure|Could not resolve|Unable to fetch' /var/log/cloud-init-output.log | tail -8" \
|
||||
2>/dev/null | sed 's/^/ /' >&2
|
||||
</dev/null 2>/dev/null | sed 's/^/ /' >&2
|
||||
echo >&2
|
||||
echo "box: '$name' is still up — inspect it, then delete it:" >&2
|
||||
echo " box incus $name -- exec {} -- tail -50 /var/log/cloud-init-output.log" >&2
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@
|
|||
# pre-0.4.0 claudebox, so the next drill run starts from a truly bare host and
|
||||
# its verdict means something.
|
||||
#
|
||||
# bash drill/wipe.sh # asks first
|
||||
# bash drill/wipe.sh # asks first; KEEPS cached images (an
|
||||
# # image is upstream's artifact — wiping
|
||||
# # it buys nothing but a re-download)
|
||||
# bash drill/wipe.sh --yes # no prompt
|
||||
# bash drill/wipe.sh --purge-storage # also delete cached images AND the
|
||||
# # 'default' storage pool, so setup-host
|
||||
# # exercises its pool bootstrap (#29)
|
||||
# bash drill/wipe.sh --purge-storage # also delete the 'default' storage
|
||||
# # pool (and the images inside it), so
|
||||
# # setup-host exercises its bootstrap (#29)
|
||||
#
|
||||
# What teardown-host.sh does NOT cover, this does: instances the drill names
|
||||
# but never tagged, instances of either tag generation, cached images, and
|
||||
|
|
@ -40,8 +42,8 @@ This wipes EVERY trace of box/claudebox from this host ($(hostname)):
|
|||
· networks boxnet + claudenet, ACLs box-isolate + claude-isolate
|
||||
· profiles box-net + claude-dev
|
||||
· firewall units, scripts and nft tables of BOTH name generations
|
||||
· every cached Incus image (the next mint re-downloads)
|
||||
$( [ "$PURGE_STORAGE" = 1 ] && echo " · the 'default' storage pool (--purge-storage)" )
|
||||
$( [ "$PURGE_STORAGE" = 1 ] && echo " · the 'default' storage pool AND its cached images (--purge-storage)" \
|
||||
|| echo " · (cached images are KEPT — the next mint stays fast; --purge-storage removes them with the pool)" )
|
||||
Uncommitted work inside any box is LOST. Only do this on a drill host.
|
||||
EOF
|
||||
[ -t 0 ] || { echo "wipe: no TTY to confirm on — pass --yes if you mean it." >&2; exit 2; }
|
||||
|
|
@ -79,13 +81,16 @@ if command -v incus >/dev/null; then
|
|||
incus network acl delete "$acl" >/dev/null 2>&1 && say "deleted ACL $acl"
|
||||
done
|
||||
|
||||
# --- cached images: the pool's other tenants -------------------------------
|
||||
for f in $(incus image list -f csv -c f 2>/dev/null); do
|
||||
incus image delete "$f" >/dev/null 2>&1 && say "deleted image $f"
|
||||
done
|
||||
|
||||
# --- the pool itself (opt-in): lets setup-host's bootstrap run for real ----
|
||||
# --- cached images: NOT wiped by default -----------------------------------
|
||||
# An image is upstream's artifact, content-addressed by fingerprint — not a
|
||||
# drill artifact. Deleting it buys zero cleanliness and costs the next mint
|
||||
# a full re-download. It only goes when the pool it lives in goes.
|
||||
if [ "$PURGE_STORAGE" = 1 ]; then
|
||||
# --- the pool (opt-in): lets setup-host's bootstrap run for real ---------
|
||||
# Images live in the pool and block its deletion — they go first.
|
||||
for f in $(incus image list -f csv -c f 2>/dev/null); do
|
||||
incus image delete "$f" >/dev/null 2>&1 && say "deleted image $f"
|
||||
done
|
||||
incus profile device remove default root >/dev/null 2>&1 && say "removed default profile's root device"
|
||||
if incus storage delete default >/dev/null 2>&1; then
|
||||
say "deleted storage pool 'default' — setup-host will rebuild it (btrfs where it can)"
|
||||
|
|
|
|||
Loading…
Reference in a new issue