- user-data customization. Can ask to specify the user instead of hardcoded to
abhinav. this can also be controlled from an environment variable. - VM configuration
- the current configuration script is simple. It essentially sets up Tailscale, UFW and Docker only. We can have additional configuration scripts and divide them in simple, advanced, more advanced etc where they can install additional things like Claude code etc.
- Make working within VM easy : in cloudinit or in configuration files, we migt want to add things like autocompelte, history search, jq, fzf etc everything that essentially makes working with VMs easier. Additionally we can install samba server. We can also install VS code extensions that helps working with and navigating the repo easily - e.g. Markdown files handling liek we do in obsidian etc.
Wishlist (Might implement later. Dont implement this right now - overengineering and wastage of time)
Please note the wishlist is more like my fleeting thoughts. They might require more thinking and brainstorming. Dont implement these right now. They might also contain things that we might be un-necessary right now and we might be over-engineering and doing a wastage of time.
- Make this repo to have skills etc. Essentially this can evolve into a agent workspace and we can have decisions and instructions and commands and scripts. This will allow us to further abstract the use-cases. We can then later also use this to troubleshoot some problems that we might be facing in the individual vms. Additionally, new functionalities can probable be better managed. Think this through. We can have various commands like init etc.
- Snapshot scripts (
21/22snapshot scripts) - Restart scenarios and checking - Check the restart scenarios - do we need to again setup the configuration etc. Check both -
-
- Restart of the host machine
-
- Restart of the vms
-
- Move this from a host level setup to a repo level setup - The idea is that we can have multiple such fleets running on a linux host (e.g one of the fleet runs on nvme disk and other on ssd and other of external hdd.). This way you can have multiple storage pools (which are name scoped in some manner). Probably we would have to move the configurations from system level environment variables to repo level environment variables. Also the state, we might want to have a state in every repo that mentions the names of the various storage pools. At the host level, there should be some namespacing. Additionally, since we will the using the common base
virshwe might want to remove the vm level states and instead read it directly throughvirsh. Think through this in detail.- Move from individual yaml state files to a global repository. Think this through later. Dont waste your time on this.
- VM
- Portability to VMs from one linux host to another. Can we just copy the files or do we have to do some setup of Libvirt etc
- Note : This is possible. You would need all the files - seed-iso, qcow2 and also the definition xml file. You might have to make some changes to the xml file based on the folder structure of the new linux host machine.
- Connectivity - either through various types of vms or by configuring a particular VM
- What if we want to have a GUI (rather than a pur server mode) - Some GUI server running. What if we want to see changes in the gui to be streamed, the changes can be through cli or agent or computer use agent
- Having GUI - Being able to use the VM as a human but using GUI. Virtual computer (I want to see/ control the VM)
- Having "AI operated computer" (I want AI to operate the VM - maybe collaboratively.) - The agent can be on the vm or on my mac machine. Computer use infra.
- Working an a agent computer - Sharing the same screen (One or multiple AI agents)
- Additionally can have something like grok bot where the computer is the same, but multiple agents work on that computer with their own screen. You can get access to the browser to be able to add your credentials to the browser. (Something like grok computer or perplexity computer)
- Notes :
- Can have various protocols - VNC, RDP etc
- Something to research - OpenHands, KASM workspaces, virt-viewer / QEMU display, RDP - (Ubuntu - XFCE, WRDP ; Macbook - RDP, XFCE, Chrome), noVNC, Apache Guacamole
- Being able to access the filesystem
- Samba server
- Object storage
- FTP server
- File server using http etc
- What if we want to have a GUI (rather than a pur server mode) - Some GUI server running. What if we want to see changes in the gui to be streamed, the changes can be through cli or agent or computer use agent
- Portability to VMs from one linux host to another. Can we just copy the files or do we have to do some setup of Libvirt etc
- Might have to create a script that gets into the vm and checks the configuration of the vm including the ufw rules, tailnet connection status etc and help us fix the issues. Something like doctor_vm and test_vm
- Rename test.sh to smoke_test.sh since it should ideally be testing the complete fleet system by setting up vms across lifecycle, configuring etc. - Think through this and fix this later.
- Check if we can manage using Cockpit - a GUI based control center
- Base Cloud Image upgrade workflow and process
- CLI tool development (Long shot - Dont invest your time on this right now)
- Change from scripts to an actual cli tool that I can design. That would make it more distributable
- When making into a CLI tool, you can actually make the tool a little more generic and support other types of sandboxes like - microvms, docker containers etc
- While implementing the cli tool, you could also implement a gateway of sort and expose using an API so that AI agents can provision and manage the sandboxes on demand
Claude and Other Coding Agents can add their log here :-
Implemented scripts/84_host_change_libvirt_storage_pools.sh (previously a
stub with just TODO comments), the "edit storage pools" script SETUP.md
already linked to. Host-level admin script (sudo throughout, same style as
81/83), not a lifecycle script -- takes a required <new-libvirt-home>
positional arg plus -y/--force, --dry-run, --purge-old, -h/--help.
Design points worth recording:
- VM discovery is scoped to this toolkit's own state files
(
STORAGE_POOL_DISKS/*.state.yaml, same pattern50_list_vms.shuses), notvirsh list --all-- so any other libvirt domain on the host that this repo doesn't manage is never stopped, edited, or restarted. - Two migration hazards specific to this repo's disk model, both
handled: (1) a VM's qcow2 overlay embeds its base image's absolute
path in its own metadata (
qemu-img create -F qcow2 -b "$BASE_IMAGE"in00_init_vm.sh) -- moving the images pool alone would silently break every overlay's backing-file pointer, so this script runsqemu-img rebase -uon each managed VM's disk after the move. (2) the libvirt domain XML itself hardcodes absolute<source file='...'/>paths for both the qcow2 disk and the cloud-init seed ISO (virt-install --disk path=..., not pool/volume-relative) -- so each managed domain isdumpxml'd, path-substituted, anddefine'd again against the new location. - Old data is kept by default, not deleted --
rsyncverifies file counts per pool before anything old is touched, and actual deletion only happens with the explicit--purge-oldflag, after every other step (pools redefined, VMs updated, VMs restarted) has already succeeded. - Rewrites
/etc/profile.d/sandbox.sh(backed up first) with a staticLIBVIRT_HOME="$NEW_LIBVIRT_HOME", deliberately dropping the mountpoint-conditional (STORAGE_POOL_HOME/mountpoint -q /mnt/extreme_ssd) pattern from82_host_setup_bootstrap_script.shin favor of a fixed path, since running this script at all is the user making an explicit, one-time choice of new location. Also patches anyLIBVIRT_HOME/STORAGE_POOL_*override lines found in this repo's.env(backed up first, and only those specific var-name lines are touched/logged -- never the full file, since.envcan hold secrets).
Verified in this session: bash -n and shellcheck clean (0 warnings),
--help works with zero environment configured (checked before
require_env, matching every other script's convention), missing-arg /
same-path / nested-path / unknown-flag / relative-path rejections all
produce the expected ERROR: and exit 1, and argument-sanity checks
(same-path, nested-path) were deliberately ordered before the sudo virsh uri connectivity check so a plain input mistake doesn't require a
working libvirt connection to be caught. Not exercised end-to-end in this
part of the session -- this dev sandbox has no libvirtd/passwordless
sudo, so the pipeline itself was syntax/logic-reviewed only at this point.
Update, same day -- end-to-end verified against the user's real host.
This coding sandbox has no libvirt/passwordless sudo, so the user ran the
actual migration themselves in their own terminal while I drove: 09_doctor_host.sh
(19/19 pass) -> full 08_test.sh (13/13 steps, clean) -> created a real
running VM (migration-test-vm) -> 84_host_change_libvirt_storage_pools.sh /home/abhinav/libvirt-migration-test --dry-run (plan looked correct) -> the
real run, migrating across an actual filesystem boundary (/Data ext4 ->
/home ext4, a different block device).
Found and fixed a real bug on the first live attempt: virsh pool-is-active <pool> is not a real virsh subcommand (error: unknown command, exit 1) -- every if sudo virsh pool-is-active ... guard in the
script (the pool-deactivation loop, and twice inside ensure_pool())
therefore always evaluated as "not active," so pool-destroy was silently
skipped everywhere it gated one, and pool-undefine was attempted against
a still-active default pool, which errored and (correctly, under
set -e) aborted the script. Confirmed the host was left in a safe
partial state at that point (rsync copy to the new location already
verified for all 5 pools, but old pools/domain untouched) before making any
fix. Replaced all three guarded calls with unconditional attempts wrapped
in || true (destroying/starting a pool that's already in that state just
errors harmlessly) -- there is no real -is-active predicate for storage
pools to check against, so this is the correct fix, not a workaround.
Re-verified bash -n/shellcheck clean, then had the user re-run the
identical command -- this time it completed cleanly through pool redefine,
per-VM qemu-img rebase -u (confirmed via qemu-img info that the new
qcow2's backing file now points at the new images path, while the
untouched old qcow2 at /Data/libvirt still points at the old one --
proof -u only touched metadata, not the old copy), domain XML redefine
(virsh dumpxml showed both the disk and seed-ISO source paths updated),
and the /etc/profile.d/sandbox.sh/.env rewrite (diffed .env against
its own auto-created backup: exactly the 6 intended lines changed, line
count identical before/after, confirming no secret lines were touched).
Then actually booted the migrated VM (01_start_vm.sh) and confirmed it
functions, not just that the metadata looks right: got its DHCP lease, SSH
worked, and 06_doctor_vm.sh passed every on-disk and guest check against
the new paths. Re-ran 09_doctor_host.sh and 85_host_check_libvirt_config.sh
afterward too -- both clean, both correctly reporting the new location.
Also flagged, then fixed on request: the identical virsh pool-is-active
mistake existed in 83_host_configure_libvirt_storage_pools.sh (the
pool-bootstrap script this one's ensure_pool() was modeled on) -- it
hadn't surfaced there yet only because that script had so far always run
against pools that were already inactive at that point in its own flow; a
second, idempotent re-run against already-active pools would have hit the
same pool-start-with-no-|| true failure this script hit. Fixed by adding
a pool_is_active() helper (checks the State: line from pool-info,
captured to a variable before grepping it rather than piped straight into
grep -q, per the SIGPIPE-under-pipefail gotcha already documented in
DECISIONS.md) and using it in both spots that used to call the nonexistent
predicate. Also chmod +x'd 83 itself -- like the pre-Write-tool bug
noted in the 2026-08-18 (3) entry below, it had been created without the
execute bit and ./scripts/83_....sh failed with "Permission denied"
before ever reaching the actual fix. Verified live by having the user
re-run 83 against this same host's pools, now already active and already
pointing at the post-migration location -- exactly the scenario that used
to be fatal. Printed "Pool definition is already correct." / "Pool is
already active." for all 5 pools and completed cleanly to "Done." (One
unrelated, harmless thing visible in that output: 83's very first
diagnostic line, grep -E '^(user|group)' /etc/libvirt/qemu.conf, runs
without sudo on a root-only-readable file and prints a permission-denied
warning -- purely informational, doesn't affect anything since the script
continues past it either way. Left alone, not part of what was asked.)
Old data at /Data/libvirt was removed at the user's request once the
migration was confirmed working (emptied via plain rm -rf/rmdir on the
5 pool subdirs -- no sudo needed, since they're libvirt-qemu:kvm 775
setgid and this user is in the kvm group; only the bare top-level
/Data/libvirt directory itself remains, since removing it needs write
access to its root-owned parent /Data -- harmless to leave behind). The
test VM (migration-test-vm) was destroyed via 04_destroy_vm.sh --force.
Host ended the session with zero VMs and 09_doctor_host.sh clean against
the new /home/abhinav/libvirt-migration-test location.
Update, same day -- moved again, to the root partition, and found a
second real bug (in libvirt itself, not this repo). 80_host_check_specs.sh
revealed /Data's underlying disk (sda, TOSHIBA MQ04ABF100) is actually a
spinning HDD (ROTA=1), not the SSD the user believed it to be -- that
alone explained most of the slowness that motivated this whole migration.
The host's NVMe (nvme0n1, ROTA=0) is fully partitioned already (/:
278G free, /home: 82G free, no room to carve a new volume without a risky
live resize), so the choice was between those two mountpoints. User wanted
/ for the extra headroom, named /libvirt (mirroring the old
/Data/libvirt naming).
That migration completed via 84 with no errors -- but 01_start_vm.sh
then failed on a fresh test VM (speed-test-vm) with internal error: cannot load AppArmor profile. journalctl -u libvirtd pinpointed it
exactly: virt-aa-helper: error: /libvirt/disks/speed-test-vm.qcow2 /
error: skipped restricted file. Traced this to actual libvirt source
(fetched src/security/virt-aa-helper.c from GitHub, since strings on
the installed binary didn't surface it cleanly): valid_path()'s
restricted[] deny-list contains the literal 4-character string "/lib"
-- no trailing slash -- matched via a naive STRPREFIX() (does-the-path-
start-with-this-string), not a proper path-component boundary check. Any
disk path starting with /lib gets blocked, including a completely
unrelated top-level directory that just happens to share that prefix:
/libvirt. Confirmed not a bug in this repo or 84 -- it's a genuine
upstream libvirt naming footgun, unrelated to the pool-is-active bugs
fixed earlier today. Nothing to patch here; the fix is just to not name the
directory something starting with /lib.
Presented the user 3 unaffected alternatives (/srv/libvirt --
FHS-correct location for service data; /vmstore; /virt); user picked
/srv/libvirt. Destroyed the broken speed-test-vm (defined but never
successfully started), migrated again via 84 (/libvirt ->
/srv/libvirt, no VMs to carry this time), and this time a fresh VM
(speed-test-vm2) started, booted, and finished cloud-init cleanly --
7 seconds from 01_start_vm.sh to SSH-reachable, full cloud-init
disabled (steady-state complete) at 34s including a mid-provisioning
reboot, 06_doctor_vm.sh all green. Destroyed it and cleaned up both
leftover intermediate copies (/home/abhinav/libvirt-migration-test
fully removed since its parent is the user's own home; /libvirt's
contents removed the same no-sudo way as /Data/libvirt earlier, bare
top-level dir left behind since / is root-owned).
Also found and fixed a minor gap in 84 itself while reviewing the
session's own artifacts: one of the .env backups created during the
middle (/libvirt) migration run (.env.bak.20260821150706) ended up
0 bytes, while the live .env and the backups from the runs immediately
before/after it were all correct and complete -- so no data was actually
lost, but the specific safety net that backup was supposed to provide had
silently failed. Cause not conclusively identified (the cp returned
success and the script's own subsequent grep/sed calls against that
same .env clearly saw valid content, so the corruption is isolated to
that one backup artifact). Rather than chase an unreproducible one-off
further, hardened update_profile()/update_env_file() in 84 to
cmp -s the backup against the original immediately after copying it and
die before proceeding if they don't match -- cheap, and directly
motivated by concrete evidence this can happen, not speculative.
bash -n/shellcheck clean after the change; not yet re-exercised against
a real failure of this kind (would need to fake a cp corruption to test
the new guard directly).
Session ended with: LIBVIRT_HOME=/srv/libvirt, zero VMs, 09_doctor_host.sh
clean, /Data/libvirt and the two intermediate copies all cleaned up (/libvirt
minus its unremovable-without-sudo empty top-level dir), and 83/84/85
all fixed, chmod +x'd, and verified live end-to-end on this host.
End-to-end verification of the Tailscale auth-key setup and the
destroy-time API cleanup from log entry (5) below, once the user generated
real credentials (a reusable+ephemeral key tagged tag:dmz-ephemeral, and
an OAuth client scoped to Devices Core write + that same tag) and added
them to .env. Ran a real lifecycle against this host and the user's real
tailnet (dog-tortoise.ts.net): 09_doctor_host.sh -> create+boot a test
VM (ts-func-test) -> 11_configure_vm.sh --skip-docker (joins Tailscale,
enables UFW) -> 06_doctor_vm.sh (all checks passed, including
guest-side Tailscale/UFW) -> 04_destroy_vm.sh --force -> recreated a
second VM with the identical name -> configured it again -> destroyed it
again. Every "VM deleted"/"tailnet device removed" claim was cross-checked
independently (via tailscale status on the host and a fresh Tailscale API
device listing), not just trusted from the scripts' own log output.
Confirmed the core fix works: the recreated VM registered as exactly
ts-func-test with no -1 suffix, i.e. the OAuth-based device deletion in
04_destroy_vm.sh (added in log entry (5)) genuinely frees the hostname
before a same-named VM is recreated -- the scenario this was all built for.
Found and fixed a real security bug while testing, unrelated to the
work in (5): the very first 11_configure_vm.sh run printed the actual
TAILSCALE_AUTHKEY value in plaintext to stdout (visible in this session's
tool output). Root cause: configure_bring_up_tailscale() in
scripts/lib/configure_steps.sh correctly pipes the authkey over stdin
(to keep it out of ps on the remote host) but forced ssh -tt (pty
allocation) on that same call for live-output streaming -- and a pty
echoes back whatever it receives on stdin, undoing the whole point of
piping it. Fixed by dropping -tt from that one call site only (every
other remote step in the file still uses it, since they don't pipe
secrets). Re-verified by re-running configuration against a live VM and
grepping the full output for the key pattern -- zero matches on the fixed
version (the first re-verification attempt was a false positive: the rerun
had actually failed to reach the VM at all, for an unrelated reason below,
so it never reached the vulnerable code path -- caught this by checking the
run's actual exit status/log content instead of trusting a piped
grep -c exit code). Told the user to revoke/regenerate the exposed
key at https://login.tailscale.com/admin/settings/keys since it's now in
this transcript; a reusable key revocation doesn't disconnect devices
already joined with it, so this doesn't require re-touching the test VM.
Also hit, incidentally: TAILSCALE_TAILNET was unset in .env (just
TAILSCALE_AUTHKEY/TAILSCALE_API_CLIENT_ID/_SECRET had been added), and
once UFW came up on the test VM its DHCP/NAT IP stopped being reachable (by
design) with no TAILSCALE_TAILNET to build the Tailscale-hostname SSH
fallback -- so the very next 11_configure_vm.sh/06_doctor_vm.sh call
would have been unable to reach the guest at all. Set
TAILSCALE_TAILNET="dog-tortoise.ts.net" in .env (found via tailscale status --json on this host) and cleaned up a stale duplicate
TAILSCALE_TAILNET="" block in .env left over from an earlier
env.sample copy (referenced the old 05_destroy_vm.sh script name, from
before that script was renumbered). Not a code bug -- env.sample already
documents this var -- but worth flagging since its absence surfaces as a
generic "can't reach VM" failure with no obvious link to UFW.
Left the test host clean: no VMs (50_list_vms.sh confirms empty), no
leftover tailnet devices, ssh-keygen -R'd the throwaway IPs this session
touched directly (the scripts' own SSH calls already use
UserKnownHostsFile=/dev/null, so nothing from them persisted).
DECISIONS.md's "Decision : Tailscale device cleanup on destroy" entry
updated in place to reflect verified status instead of "believed correct
but unverified."
Discussed Tailscale auth-key strategy for these sandbox VMs against the
user's existing tag taxonomy (dmz-persistent/dmz-ephemeral/
machine-ephemeral) and ACL grants -- recommended a single reusable +
ephemeral key tagged tag:dmz-ephemeral (matches these VMs' actual shape:
throwaway, outbound-internet-only, reachable by the user's own member
devices via the existing autogroup:member -> * grant regardless of tag).
No code needed for that part -- configure_steps.sh's tailscale up --authkey=... --hostname=$VMNAME already just inherits whatever
tag/ephemeral properties the key itself carries.
Then walked through two concrete scenarios (destroy -> recreate same name;
stop -> restart after a gap) and found neither guarantees reclaiming the
same tailnet hostname, because none of 01_start_vm.sh/02_stop_vm.sh/
04_destroy_vm.sh ever talk to Tailscale -- an ephemeral node only gets
cleaned up on Tailscale's own schedule, not this toolkit's, so a fast
destroy+recreate can collide with a still-present stale device (Tailscale
auto-suffixes the new one, e.g. myvm-1) and a long stop can outlast the
ephemeral-cleanup window (VM comes back with no working tailscale0).
Fixed the destroy/recreate gap: new scripts/lib/tailscale_api.sh
(OAuth-client-based -- exchanges TAILSCALE_API_CLIENT_ID/_SECRET for a
short-lived bearer token, looks up the tailnet device by hostname, deletes
it), wired into 04_destroy_vm.sh as a best-effort step after local
teardown. Chose OAuth-client over a personal API token (can be scoped to
both a permission -- Devices Core write-only -- and a tag, e.g. only
tag:dmz-ephemeral, so the credential can't touch anything else on the
tailnet) and over SSH-based tailscale logout (works even if the guest is
already unreachable by the time destroy runs, since it talks to Tailscale's
control plane directly from the host). Both env vars are optional --
missing them just logs a skip note rather than failing the destroy. Added
jq as an optional dependency (present on this host already) -- noted in
SETUP.md and as a non-fatal check in 09_doctor_host.sh, mirroring the
existing kvm-ok-optional pattern. Documented the full rationale in
DECISIONS.md ("Decision : Tailscale device cleanup on destroy") and
updated lifecycle.md's 04_destroy_vm.sh/01_start_vm.sh sections.
Deliberately left the stop/long-restart gap as a documented caveat rather
than a code change (lifecycle.md, 01_start_vm.sh section) -- fixing it
the same way (delete-on-stop) would break the common fast stop/restart case
where the same node/session should just resume for free; the fix there is
manual (11_configure_vm.sh <vmname> --skip-docker --skip-ufw to rejoin)
if it's ever actually hit.
Verified: bash -n on all touched/new files, shellcheck clean on
scripts/lib/tailscale_api.sh (pre-existing warnings elsewhere untouched),
and the two jq filters used in it tested standalone against sample
JSON (token extraction, device-id-by-hostname lookup) -- both produced the
expected output. Not exercised against the real Tailscale API in this
session (no OAuth client configured on this host yet) -- treat
tailscale_api.sh as "believed correct but unverified end-to-end" until
run against a real tailnet with real credentials.
Renamed 09_doctor.sh -> 09_doctor_host.sh (it only ever checked the
host, not any VM -- the name was ambiguous next to the new script below) and
added 06_doctor_vm.sh: per-VM diagnostics, filling the "is this VM
actually configured right" gap 05_status_vm.sh (dumps info, doesn't judge
it) and 09_doctor_host.sh (host-only) both leave open. Checks, in two
groups ([PASS]/[FAIL] per check, exit 1 on any failure):
- libvirt/on-disk (always): state file / domain / disk / seed-ISO / base
image all exist; domain's actual vCPUs, max-memory, and autostart (via
virsh dominfo) and the qcow2's actual virtual size (viaresize_disk_current_gb, reused fromlib/resize_steps.sh) all matchstate.yaml-- catches drift from a partial resize or a manualvirshedit. - guest (only if the VM is running): qemu-guest-agent responds, SSH is
reachable (reuses
configure_resolve_ssh_hostfromlib/configure_steps.sh), cloud-init finished, and -- only for whichever of Docker/Tailscale/UFWstate.yamlactually recorded as configured, notskipped-- that the guest's live state agrees.
Updated 08_test.sh (Step 1 + its own docstring/usage) to call
09_doctor_host.sh, and README.md/lifecycle.md/DECISIONS.md for both
the rename and the new script.
Verified end-to-end against this real host, not just bash -n: ran
09_doctor_host.sh (19/19 checks passed) and a full 08_test.sh pass
(13/13) to confirm the rename didn't break anything downstream. For
06_doctor_vm.sh, ran three throwaway VMs through
init -> start -> (wait for cloud-init) -> 11_configure_vm.sh --skip-tailscale --skip-ufw -> 06_doctor_vm.sh -> destroy (all
self-cleaned, no leftovers). First real run caught an actual bug: the
cloud-init check only accepted status: done, but this repo's
user-data.tmpl touches /etc/cloud/cloud-init.disabled as its last
runcmd step (see "cloud-init only runs once" under 11_configure_vm.sh in
lifecycle.md), so cloud-init status legitimately reports disabled, not
done, on any check after first boot -- every run after the VM's first
boot was a guaranteed false-positive [FAIL]. Fixed to accept done or
disabled; re-ran and got a clean all-[PASS] result including live
Docker/SSH/guest-agent checks. Tailscale/UFW guest-check branches
themselves are still unverified against a real tailnet -- no
TAILSCALE_AUTHKEY on this host, same caveat as 11_configure_vm.sh's
existing log entries below.
End-to-end verification of the automated/interactive merge + --help work
(2026-08-18 (2) below) against this real host -- previously only
syntax-checked. Ran 09_doctor.sh, a full 08_test.sh pass, and manual
coverage of the two scripts 08_test.sh doesn't exercise
(12_resize_vm.sh entirely; 11_configure_vm.sh's non-Tailscale steps).
Found and fixed two real bugs:
- Merged scripts weren't executable.
Writedoesn't preserve/set the execute bit the waygit mvwould have, so00_init_vm.sh,11_configure_vm.sh, and12_resize_vm.shwere created-rw-rw-r---- every invocation failed with "Permission denied" (08_test.shcaught this immediately on its first run). Fixed withchmod +x. 12_resize_vm.shwas broken against any running VM, for any field.resize_disk_current_gb()inscripts/lib/resize_steps.shcallsqemu-img infounconditionally (even for a RAM-only or autostart-only resize, since it's needed for the "Current:"/"Requested:" print rows) -- butqemu-img infowithout-U/--force-sharecan't get a lock on a qcow2 that's actively attached to a running domain, so it failed with "Failed to get shared 'write' lock",bytesended up as the literal string"null", and the arithmetic on it crashed withset -u's "unbound variable" under that name. Pre-existing bug inresize_steps.sh's function body (untouched by the merge) --12_resize_vm-automated.sh/-interactive.shhad the same bug before the merge, it had just never been run against a live host before (see prior "not verified end-to-end" caveats). Fixed by adding-Uto theqemu-img infocall -- safe here since it's read-only metadata inspection and virtual-size doesn't change except throughresize_apply_disk_grow, which only runs while stopped.
Also fixed a minor, unrelated flakiness noticed during the 08_test.sh run:
Step 6 (03_reboot_vm.sh) issued a reboot and Step 7 immediately attempted
a graceful stop with no wait in between; virsh reboot doesn't change
libvirt's reported domain state (stays "running" the whole time), so
there's nothing to poll for there, and the guest's ACPI listener isn't
always back up yet when the stop request lands -- causing an unnecessary
--force fallback (observed once, see below). Fixed by waiting for the
guest's SSH to come back up after reboot before Step 7 runs.
Full manual coverage exercised: 00_init_vm.sh (already-exists guard,
unknown-flag/invalid-name/missing-vmname rejection, rollback leaves no
partial artifacts); 12_resize_vm.sh (RAM+vCPU resize while running
stops/applies/restarts correctly, no-op detection, disk grow, shrink
refusal, immediate autostart toggle with no restart, -i mode blank-input
no-op / real-value-with-confirm / decline-aborts-cleanly, unknown flag);
11_configure_vm.sh (missing-authkey die path, not-running die path, real
Docker install + idempotent re-run, -i mode step decline, unknown flag).
Tailscale/UFW steps in 11_configure_vm.sh were NOT exercised -- no
TAILSCALE_AUTHKEY configured on this host -- so treat those two steps
specifically as still "believed correct but unverified."
Test run 1 (before the two fixes): 2/13 08_test.sh steps failed
(permission denied on both init calls). Test run 2 (after chmod +x,
before the resize fix): 12/13 passed (1 unrelated reboot/stop flake, see
above). Test run 3 (final, all fixes applied): 13/13 passed. All test VMs
(both from 08_test.sh and the manually-created one used for resize/
configure coverage) were destroyed at the end of each run; host left with
no leftover libvirt domains, disks, or state files, confirmed via
virsh list --all and directory listing after each run.
Implemented the wishlist item on unifying automated/interactive scripts, plus
--help everywhere:
- Merged
-automated/-interactivepairs:00_init_vm-automated.sh+00_init_vm-interactive.sh->00_init_vm.sh; same for11_configure_vm-*->11_configure_vm.shand12_resize_vm-*->12_resize_vm.sh. Each now takes-i/--interactive: without it, any field not passed as a flag resolves silently from its default (old-automatedbehavior); with it, unset fields are prompted for instead and mutating steps confirm first (old-interactivebehavior).<vmname>is now a required positional arg in every mode --00_init_vm-interactive.shused to prompt for it, which was the odd one out vs. the other two scripts; that inconsistency is gone. Promotedprompt_default/prompt_int/prompt_boolintoscripts/lib/common.sh. See DECISIONS.md ("Decision : Unify automated/interactive scripts...") for full rationale. --helpon every script: added ashow_help_if_requestedhelper tocommon.sh(checked beforerequire_env, so--helpworks even with a broken/unconfigured environment) and a full NAME/USAGE/REQUIRED/OPTIONS/ EXAMPLES block to every script inscripts/.lifecycle.mdtrimmed to stop restating full flag lists (that's now--help's job) and instead focuses on cross-script rationale/ordering, to cut the number of places a flag's documentation can drift.- Updated
08_test.sh's two init calls (previously00_init_vm-automated.sh/00_init_vm-interactive.shwith blank stdin) to point at00_init_vm.sh(flags) and00_init_vm.sh -i(blank stdin, now 6 blank lines instead of 7 since vmname is no longer prompted for). Also fixed two pre-existing stale references inenv.sample(05_destroy_vm.sh->04_destroy_vm.sh,11_configure-automated_vm.sh->11_configure_vm.sh) noticed while updating it.
Not verified end-to-end against a real host in this session -- syntax-checked
(bash -n) every touched/new script, and exercised --help output and the
promoted prompt helpers directly, but did not run 08_test.sh or otherwise
create real VMs (would have real side effects on the host). Same "believed
correct but unverified" caveat as prior sessions' unverified items.
Implemented three wishlist items:
- qemu-guest-agent: added to
setup_config/user-data.tmpl's packages list (+ explicitsystemctl enable --now), and added the required virtio-serial channel device (--channel unix,target_type=virtio, name=org.qemu.guest_agent.0) to thevirt-installcall in00_init_vm-automated.sh. New VMs only -- see DECISIONS.md. - Docker off cloud-init: removed the Docker
runcmdblock fromuser-data.tmpl, added an idempotentinstall_dockerremote step toscripts/lib/configure_steps.sh, wired into both11_configure_vm-automated.sh/-interactive.shbehind a new--skip-dockerflag, recorded as.dockerin state.yaml. - Resize script: new
scripts/12_resize_vm-automated.sh/12_resize_vm-interactive.sh, sharingscripts/lib/resize_steps.sh. Edits RAM/vCPUs/disk/autostart on an existing VM; RAM/vCPU/disk changes always apply while stopped (--configonly, no live hotplug -- see DECISIONS.md) and restart the VM if it was running; disk resize is grow-only. Also addedstate_set_rawtoscripts/lib/common.sh(numeric state fields,state_set's own doc comment referenced this but it didn't exist yet).
Not verified end-to-end against a real host in this session (no VM was
started/stopped) -- syntax-checked (bash -n) all touched/new scripts
only. Treat as "believed correct but unverified," same caveat as the
existing 11_configure_vm-* note above.