1
1
Fork 1
sovereign-stack/uninstall.sh

55 lines
1.2 KiB
Bash
Raw Normal View History

2023-02-01 19:44:05 +00:00
#!/bin/bash
2023-03-06 20:42:17 +00:00
set -eu
2023-02-01 19:44:05 +00:00
# this script undoes install.sh
2023-03-02 14:46:17 +00:00
if ! command -v lxc >/dev/null 2>&1; then
echo "This script requires 'lxc' to be installed. Please run 'install.sh'."
exit 1
fi
2023-02-01 19:44:05 +00:00
. ./defaults.sh
if lxc list --format csv | grep -q ss-mgmt; then
2023-03-02 14:46:17 +00:00
if ! lxc list --format csv | grep ss-mgmt | grep -q "RUNNING"; then
2023-02-01 19:44:05 +00:00
lxc stop ss-mgmt
fi
lxc config device remove ss-mgmt sscode
2023-03-02 14:46:17 +00:00
lxc delete ss-mgmt -f
fi
if lxc profile device list default | grep -q root; then
lxc profile device remove default root
fi
if lxc profile device list default | grep -q enp5s0; then
lxc profile device remove default enp5s0
fi
if lxc network list | grep -q lxdbr0; then
lxc network delete lxdbr0
2023-02-01 19:44:05 +00:00
fi
2023-03-02 14:46:17 +00:00
if lxc image list | grep -q "$UBUNTU_BASE_IMAGE_NAME"; then
lxc image delete "$UBUNTU_BASE_IMAGE_NAME"
fi
2023-02-01 19:44:05 +00:00
2023-03-02 14:46:17 +00:00
if lxc storage list --format csv | grep -q sovereign-stack; then
lxc storage delete sovereign-stack
fi
2023-02-01 19:44:05 +00:00
2023-03-02 14:46:17 +00:00
if snap list | grep -q lxd; then
sudo snap remove lxd
sleep 2
fi
2023-02-01 19:44:05 +00:00
2023-03-02 14:46:17 +00:00
if zfs list | grep -q sovereign-stack; then
sudo zfs destroy -r sovereign-stack
fi
2023-02-01 19:44:05 +00:00
2023-03-02 14:46:17 +00:00
if zfs list | grep -q "sovereign-stack"; then
sudo zfs destroy -r "rpool/lxd"
fi