Files
coreapp-dev/uninstall.sh
T
davidandClaude Opus 5.5 fdb57d260d Add the coreapp skill; fix /data ownership; deploy --recreate, shell <cmd>
skills/coreapp/SKILL.md teaches a Claude Code agent to make or port an
app for Federated Core: coreapp.toml, the needs, porting an existing app,
the deploy and test loop, troubleshooting, what isn't supported yet and
how to report back. update.sh links it into ~/.claude/skills/coreapp;
uninstall.sh removes the link. Rehearsed with a small app (memo-board)
ported by a fresh agent using only the skill.

The installer now gives /data to the image's user before starting the
container: Docker created it as root, so non-root apps couldn't write.
coreapp deploy --recreate always starts a new container (to test that
data survives); coreapp shell '<command>' runs one command without a
terminal.

PLAN.md: what would change on the Core to put the installer in
/federated/bin/coreapps/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 13:50:10 -07:00

96 lines
3.5 KiB
Bash

#!/bin/bash
#
# Purpose : Remove what coreapp-dev set up. CoreDesktop's `sibling remove`
# only deletes the clone, so run this first:
# bash ~/.local/share/siblings/coreapp-dev/uninstall.sh
# Asks before deleting VMs, the downloaded image or keys. Keeps
# libvirt, QEMU and libvirt's default network, which other VMs may
# use. Safe to re-run.
set -e
URI="qemu:///system"
NETWORK=coreapp
BRIDGE=virbr-coreapp
HOOK=/etc/libvirt/hooks/network.d/coreapp-dev
DATA="$HOME/.local/share/coreapp-dev"
CONFIG="$HOME/.config/coreapp-dev"
ask() {
# $1: question. Yes only if answered y; no when not run in a terminal.
local answer=n
[ -t 0 ] && read -r -p "$1 [y/N] " answer
[[ "$answer" =~ ^[Yy] ]]
}
v() { sudo virsh -c "$URI" "$@"; }
# VMs attached to the coreapp network
vms=()
if command -v virsh > /dev/null && v net-info "$NETWORK" &> /dev/null; then
while read -r name; do
[ -n "$name" ] || continue
if v domiflist "$name" 2> /dev/null | awk '{print $3}' | grep -qx "$NETWORK"; then
vms+=("$name")
fi
done < <(v list --all --name)
fi
if [ ${#vms[@]} -gt 0 ]; then
echo "These VMs use coreapp-dev's network: ${vms[*]}"
echo "If a Federated Core was provisioned on one, delete that Core in the"
echo "dashboard before you put another machine behind the same public IP."
if ask "Delete these VMs and their disks?"; then
for name in "${vms[@]}"; do
if [ "$(v domstate "$name")" = running ]; then v destroy "$name" > /dev/null; fi
disks=$(v domblklist "$name" --details | awk '$2 == "disk" {print $4}')
v undefine "$name" --nvram > /dev/null 2>&1 || v undefine "$name" > /dev/null
for disk in $disks; do v vol-delete "$disk" > /dev/null 2>&1 || true; done
echo "Deleted VM $name."
done
else
echo "Kept them, so the network stays too. Delete them with coreapp-vm delete"
echo "<name> and run this again."
exit 1
fi
fi
rm -f "$HOME/.local/bin/coreapp-vm" "$HOME/.local/bin/coreapp"
# The skill's link, if it's ours
if [[ "$(readlink "$HOME/.claude/skills/coreapp" 2> /dev/null)" == */skills/coreapp ]]; then
rm -f "$HOME/.claude/skills/coreapp"
fi
if command -v virsh > /dev/null && v net-info "$NETWORK" &> /dev/null; then
echo "Removing coreapp-dev's VM network..."
# Stopping it runs the hook, which removes its NAT and firewall rules
v net-destroy "$NETWORK" > /dev/null 2>&1 || true
v net-undefine "$NETWORK" > /dev/null
fi
if sudo test -e "$HOOK"; then
echo "Removing coreapp-dev's libvirt network hook..."
sudo rm -f "$HOOK"
fi
# The ufw rules update.sh added for the coreapp bridge (virbr0's stay, for
# libvirt's default network)
if command -v ufw > /dev/null && grep -qs "in_$BRIDGE" /etc/ufw/user.rules; then
echo "Removing coreapp-dev's ufw rules for $BRIDGE..."
sudo ufw delete allow in on "$BRIDGE" to any port 67 proto udp > /dev/null || true
sudo ufw delete allow in on "$BRIDGE" to any port 53 > /dev/null || true
sudo ufw route delete allow in on "$BRIDGE" > /dev/null || true
fi
if [ -d "$DATA" ] && ask "Delete the CoreServer image and coreapp-dev's SSH key in $DATA?"; then
rm -rf "$DATA"
elif [ -d "$DATA" ]; then
echo "Kept $DATA"
fi
if [ -d "$CONFIG" ] && ask "Delete coreapp-dev's settings (the dashboard's SSH key) in $CONFIG?"; then
rm -rf "$CONFIG"
elif [ -d "$CONFIG" ]; then
echo "Kept $CONFIG"
fi
echo "coreapp-dev removed. libvirt and QEMU are still installed; remove them"
echo "with pacman if nothing else uses them. Then: sibling remove coreapp-dev"