coreapp-vm command, uninstall.sh, stale-system check

- bin/coreapp-vm replaces scripts/create-coreserver-vm.sh: create (downloads
  and checks the CoreServer image when it's missing, resumes an interrupted
  download), list, ip, ssh (own known_hosts), start, stop, delete (asks for
  the name). update.sh symlinks it into ~/.local/bin.
- uninstall.sh removes coreapp-vm, the coreapp network, its hook and ufw
  rules; asks before deleting VMs, the image and keys.
- install.sh runs CoreDesktop's update first when the system wasn't
  upgraded in the last day, as `sibling add` does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 11:40:04 -07:00
co-authored by Claude Opus 5.5
parent b405e35ea8
commit 0654d4c712
9 changed files with 443 additions and 143 deletions
+37 -16
View File
@@ -8,14 +8,16 @@ a temporary folder. Run these on a machine or VM you don't mind changing.
```bash
cd ~/Projects/coreapp-dev
for f in install.sh update.sh scripts/*.sh; do bash -n "$f"; done
shellcheck -x install.sh update.sh scripts/*.sh
for f in install.sh update.sh uninstall.sh bin/coreapp-vm libvirt/network-hook.sh; do bash -n "$f"; done
shellcheck -x install.sh update.sh uninstall.sh bin/coreapp-vm libvirt/network-hook.sh
```
## install.sh
1. Bring the system up to date first: `update`. Otherwise pacman may ask for
package versions the mirrors have deleted, and the download fails with a 404.
1. If the system was last upgraded more than a day ago, `bash install.sh`
says so and runs `update` first (pacman's lists would otherwise name
versions the mirrors have deleted: 404s). Under `update` itself
(`COREDESKTOP_ALLOW_PACMAN=1`) it doesn't.
2. `bash install.sh`. It should:
- install whichever of `libvirt qemu-base virt-install dnsmasq edk2-ovmf
dmidecode` are missing
@@ -100,21 +102,40 @@ grep virbr-coreapp /etc/ufw/user.rules # DHCP, DNS, route rules
## CoreServer VM
1. Put Federated's dashboard key in `~/.config/coreapp-dev/authorized_keys`.
2. `scripts/create-coreserver-vm.sh`. It says how many root keys it's
installing (2: coreapp-dev's and the dashboard's) and prints
`IP: 10.123.0.10` within about two minutes.
3. `virsh -c qemu:///system list`: `coreserver` is running.
4. `ssh -i ~/.local/share/coreapp-dev/ssh/id_ed25519 root@10.123.0.10`
logs in. Inside the VM:
2. `coreapp-vm create`. Without the image, it downloads it first (1.3 GB;
interrupt it and run again: it resumes) and checks its SHA-256. It says
how many root keys it's installing (2: coreapp-dev's and the dashboard's)
and prints `IP: 10.123.0.10` within about two minutes.
3. `coreapp-vm list`: `coreserver` is running at 10.123.0.10.
4. `coreapp-vm ssh` logs in (after cloud-init, a minute later). Inside the VM:
- `cat /root/.ssh/authorized_keys` has both keys
- `df -h /federated` shows about 50 GB (the disk is 60 GB; `/` stays 10 GB)
- `ping -c3 1.1.1.1` and `getent hosts federated.computer` (internet and DNS)
5. To see the screen: `virt-viewer -c qemu:///system coreserver`, or
`virsh -c qemu:///system screenshot coreserver /tmp/s.png`.
6. Running the script again with the same name refuses with "already exists".
7. `systemctl is-enabled systemd-resolved` in the VM says `masked`.
- `systemctl is-enabled systemd-resolved` says `masked`
5. `coreapp-vm ssh hostname` prints `coreserver`; `coreapp-vm ip nope` says
there's no such VM.
6. `coreapp-vm create` again refuses with "already exists".
7. To see the screen: `virt-viewer -c qemu:///system coreserver`.
8. Once the Core is installed: `virsh -c qemu:///system reboot coreserver`.
Within a few minutes all its containers are up again, including `pdns`
(`dig +short A <domain> @10.123.0.10` answers).
7. To clean up:
`virsh -c qemu:///system destroy coreserver && virsh -c qemu:///system undefine coreserver --remove-all-storage`
9. `coreapp-vm stop`, then `coreapp-vm start`.
10. `coreapp-vm delete`: asks for the name; anything else keeps the VM. With
the name, the VM and `/var/lib/libvirt/images/coreserver.qcow2` are gone,
the image in `~/.local/share/coreapp-dev/images/` stays.
## Uninstall
On a machine you can rebuild (it removes the network every VM uses):
1. `bash uninstall.sh` with a VM on the `coreapp` network, answering no: it
stops, and nothing is removed.
2. Again, answering yes: the VMs and their disks are gone,
`virsh -c qemu:///system net-list --all` has no `coreapp`,
`/etc/libvirt/hooks/network.d/coreapp-dev` is gone,
`sudo iptables -S | grep -c coreapp-dev` prints 0,
`grep -c virbr-coreapp /etc/ufw/user.rules` prints 0 (virbr0's rules stay),
and `coreapp-vm` isn't on `PATH`.
3. Answering no to the data questions keeps `~/.local/share/coreapp-dev` and
`~/.config/coreapp-dev`.
4. `bash install.sh` puts everything back.