- 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>
142 lines
6.4 KiB
Markdown
142 lines
6.4 KiB
Markdown
# Testing
|
|
|
|
Manual checks for coreapp-dev. The scripts call `sudo`, `pacman`/`yay`,
|
|
`systemctl` and `virsh`, so they change the real system even when `HOME` is
|
|
a temporary folder. Run these on a machine or VM you don't mind changing.
|
|
|
|
## Static checks
|
|
|
|
```bash
|
|
cd ~/Projects/coreapp-dev
|
|
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. 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
|
|
- enable and start `libvirtd.service`
|
|
- add you to the `libvirt` group
|
|
- define the `default` network if it's missing, set it to start at boot,
|
|
and start it
|
|
- print "coreapp-dev installed.", and the log-out note if your group
|
|
membership is new
|
|
3. Log out and back in, then check:
|
|
```bash
|
|
id -nG | grep -w libvirt
|
|
systemctl is-active libvirtd
|
|
virsh -c qemu:///system net-info default # Active: yes, Autostart: yes
|
|
ls ~/.local/share/coreapp-dev/images
|
|
```
|
|
4. Run `bash install.sh` again. It must succeed, print "already enabled" and
|
|
change nothing.
|
|
5. Error paths:
|
|
- With CoreDesktop missing: `HOME=$(mktemp -d) bash install.sh` should say
|
|
it needs CoreDesktop and exit 1.
|
|
|
|
## update.sh
|
|
|
|
1. `bash update.sh` with everything already installed: no package installs,
|
|
no prompts apart from sudo, exits 0.
|
|
2. Stop the network (`virsh -c qemu:///system net-destroy default`) and run
|
|
`bash update.sh`: it should start the network again.
|
|
|
|
## Through CoreDesktop's sibling command
|
|
|
|
Once the repo is in git:
|
|
|
|
```bash
|
|
export HOME="$(mktemp -d)"
|
|
mkdir -p "$HOME/.local/share"
|
|
ln -s ~/.local/share/coredesktop "$HOME/.local/share/coredesktop"
|
|
bash "$HOME/.local/share/coredesktop/sibling" add ~/Projects/coreapp-dev
|
|
bash "$HOME/.local/share/coredesktop/sibling" update
|
|
bash "$HOME/.local/share/coredesktop/sibling" add ~/Projects/coreapp-dev # re-run is safe
|
|
```
|
|
|
|
## The coreapp network
|
|
|
|
After `bash update.sh`:
|
|
|
|
```bash
|
|
virsh -c qemu:///system net-info coreapp # Active: yes, Autostart: yes
|
|
sudo ls -l /etc/libvirt/hooks/network.d/coreapp-dev
|
|
sudo nft list table ip coreapp-dev # masquerade for 10.123.0.0/24
|
|
sudo iptables -S | grep coreapp-dev # 3 INPUT and 2 FORWARD accepts
|
|
grep virbr-coreapp /etc/ufw/user.rules # DHCP, DNS, route rules
|
|
```
|
|
|
|
- Run `bash update.sh` again: no changes, and no ufw rules added twice. (This
|
|
also checks that the `grep` patterns match how ufw writes its rules; if one
|
|
doesn't, `update` asks for sudo every time.)
|
|
- `virsh -c qemu:///system net-destroy coreapp`: the nft table and iptables
|
|
rules are gone. `net-start coreapp`: they're back.
|
|
- The hook on its own, in a throwaway namespace (no host changes):
|
|
```bash
|
|
docker run --rm --cap-add NET_ADMIN -v "$PWD/libvirt/network-hook.sh:/hook:ro" \
|
|
--entrypoint bash corerelay:local -c \
|
|
'/hook coreapp started; /hook coreapp started; iptables -S | grep -c coreapp-dev; /hook coreapp stopped; iptables -S | grep -c coreapp-dev'
|
|
```
|
|
prints 5, then 0 (the `sysctl` error is expected inside a container).
|
|
|
|
- Moving from the old network (192.168.123.0/24): with a VM running,
|
|
`bash update.sh` redefines `coreapp` but doesn't restart it, and says how.
|
|
With no VM running, it restarts it: `net-dumpxml coreapp` shows
|
|
`10.123.0.1` and the `dhcp-host=52:54:00:c0:4e:10,...` option, and
|
|
`sudo iptables -S | grep -c 192.168.123` prints 0.
|
|
- The reservation works: `virsh -c qemu:///system net-dhcp-leases coreapp`
|
|
lists `coreserver` at `10.123.0.10`. (dnsmasq still logs "cannot read
|
|
.../coreapp.hostsfile": that file is libvirt's, root-only and now empty.)
|
|
- From the workstation, the Core's own services answer directly (its
|
|
containers are on 192.168.0.0/16, so this fails if the VM network is in
|
|
192.168.x.x):
|
|
`curl -sk -o /dev/null -w '%{http_code}\n' --resolve nextcloud.<domain>:443:10.123.0.10 https://nextcloud.<domain>/`
|
|
prints 302.
|
|
|
|
## CoreServer VM
|
|
|
|
1. Put Federated's dashboard key in `~/.config/coreapp-dev/authorized_keys`.
|
|
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)
|
|
- `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).
|
|
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.
|