2023-02-01 19:44:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-04-02 13:43:55 +00:00
|
|
|
set -eu
|
2023-03-15 23:19:32 +00:00
|
|
|
|
|
|
|
PURGE_LXD=false
|
|
|
|
|
|
|
|
# grab any modifications from the command line.
|
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
|
|
|
--purge)
|
|
|
|
PURGE_LXD=true
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unexpected option: $1"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
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
|
|
|
|
2023-04-14 17:16:41 +00:00
|
|
|
|
|
|
|
if ! lxc remote get-default | grep -q "local"; then
|
|
|
|
echo "ERROR: You MUST be on the local remote when uninstalling the SSME."
|
|
|
|
echo "INFO: You can use 'lxc remote switch local' to do this."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if ! lxc project list | grep -q "default (current)"; then
|
|
|
|
echo "ERROR: You MUST be on the default project when uninstalling the SSME."
|
|
|
|
echo "INFO: You can use 'lxc project switch default' to do this."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2023-03-15 23:19:32 +00:00
|
|
|
if lxc list --format csv | grep -q "ss-mgmt"; then
|
2023-02-01 19:44:05 +00:00
|
|
|
|
2023-03-15 23:19:32 +00:00
|
|
|
if lxc list --format csv -q | grep -q "ss-mgmt,RUNNING"; then
|
2023-02-01 19:44:05 +00:00
|
|
|
lxc stop ss-mgmt
|
|
|
|
fi
|
|
|
|
|
2023-03-19 17:49:00 +00:00
|
|
|
if lxc config device list ss-mgmt -q | grep -q "ss-code"; then
|
|
|
|
lxc config device remove ss-mgmt ss-code
|
|
|
|
fi
|
2023-03-02 14:46:17 +00:00
|
|
|
|
2023-03-19 17:49:00 +00:00
|
|
|
if lxc config device list ss-mgmt -q | grep -q "ss-root"; then
|
|
|
|
lxc config device remove ss-mgmt ss-root
|
2023-03-15 23:19:32 +00:00
|
|
|
fi
|
2023-03-02 14:46:17 +00:00
|
|
|
|
2023-03-19 17:49:00 +00:00
|
|
|
if lxc config device list ss-mgmt -q | grep -q "ss-ssh"; then
|
2023-03-18 15:12:14 +00:00
|
|
|
lxc config device remove ss-mgmt ss-ssh
|
|
|
|
fi
|
|
|
|
|
2023-03-15 23:19:32 +00:00
|
|
|
lxc delete ss-mgmt
|
2023-03-02 14:46:17 +00:00
|
|
|
fi
|
|
|
|
|
2023-03-15 23:19:32 +00:00
|
|
|
if [ "$PURGE_LXD" = true ]; then
|
2023-02-01 19:44:05 +00:00
|
|
|
|
2023-03-15 23:19:32 +00:00
|
|
|
if lxc profile device list default | grep -q root; then
|
|
|
|
lxc profile device remove default root
|
|
|
|
fi
|
2023-02-01 19:44:05 +00:00
|
|
|
|
2023-03-15 23:19:32 +00:00
|
|
|
if lxc profile device list default | grep -q enp5s0; then
|
|
|
|
lxc profile device remove default enp5s0
|
|
|
|
fi
|
2023-02-01 19:44:05 +00:00
|
|
|
|
2023-04-02 13:43:55 +00:00
|
|
|
if lxc network list --project default | grep -q lxdbr0; then
|
2023-03-15 23:19:32 +00:00
|
|
|
lxc network delete lxdbr0
|
|
|
|
fi
|
2023-02-01 19:44:05 +00:00
|
|
|
|
2023-04-07 14:23:04 +00:00
|
|
|
# this file contains the BASE_IMAGE_NAME
|
|
|
|
. ./deployment/base.sh
|
2023-03-15 23:19:32 +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-15 23:19:32 +00:00
|
|
|
if lxc storage list --format csv | grep -q sovereign-stack; then
|
|
|
|
lxc storage delete sovereign-stack
|
|
|
|
fi
|
|
|
|
|
|
|
|
if snap list | grep -q lxd; then
|
|
|
|
sudo snap remove lxd
|
|
|
|
fi
|
|
|
|
fi
|