1
1
sovereign-stack/deployment/reset.sh

86 lines
2.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 -e
2023-02-01 19:44:05 +00:00
cd "$(dirname "$0")"
2023-03-19 17:49:37 +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
source ../defaults.sh
2023-04-04 15:34:48 +00:00
./down.sh
2023-03-02 14:46:17 +00:00
# these only get initialzed upon creation, so we MUST delete here so they get recreated.
if lxc profile list | grep -q "$BASE_IMAGE_VM_NAME"; then
lxc profile delete "$BASE_IMAGE_VM_NAME"
fi
if lxc image list | grep -q "$BASE_IMAGE_VM_NAME"; then
lxc image rm "$BASE_IMAGE_VM_NAME"
fi
2023-03-09 14:58:16 +00:00
if lxc image list | grep -q "$DOCKER_BASE_IMAGE_NAME"; then
lxc image rm "$DOCKER_BASE_IMAGE_NAME"
2023-03-02 14:46:17 +00:00
fi
CURRENT_PROJECT="$(lxc info | grep "project:" | awk '{print $2}')"
if ! lxc info | grep -q "project: default"; then
lxc project switch default
lxc project delete "$CURRENT_PROJECT"
fi
2023-03-19 17:49:37 +00:00
if [ "$PURGE_LXD" = true ]; then
2023-03-02 14:46:17 +00:00
2023-03-19 17:49:37 +00:00
if lxc profile show default | grep -q "root:"; then
lxc profile device remove default root
fi
2023-03-02 14:46:17 +00:00
2023-03-19 17:49:37 +00:00
if lxc profile show default| grep -q "eth0:"; then
lxc profile device remove default eth0
fi
2023-04-04 15:32:54 +00:00
if lxc network list --format csv -q --project default | grep -q lxdbr0; then
lxc network delete lxdbr0 --project default
2023-03-19 17:49:37 +00:00
fi
2023-04-04 15:32:54 +00:00
if lxc network list --format csv -q --project default | grep -q lxdbr1; then
lxc network delete lxdbr1 --project default
2023-03-19 17:49:37 +00:00
fi
2023-03-09 14:58:16 +00:00
# # create the testnet/mainnet blocks/chainstate subvolumes.
# for CHAIN in mainnet testnet; do
# for DATA in blocks chainstate; do
# if lxc storage volume list ss-base | grep -q "$CHAIN-$DATA"; then
# lxc storage volume delete ss-base "$CHAIN-$DATA"
# fi
# done
# done
2023-03-16 19:50:02 +00:00
2023-03-19 17:49:37 +00:00
if lxc storage list --format csv | grep -q ss-base; then
lxc storage delete ss-base
fi
2023-03-02 14:46:17 +00:00
2023-03-19 17:49:37 +00:00
CURRENT_REMOTE="$(lxc remote get-default)"
if ! lxc remote get-default | grep -q "local"; then
lxc remote switch local
lxc remote remove "$CURRENT_REMOTE"
2023-03-17 15:19:35 +00:00
2023-03-19 17:49:37 +00:00
echo "INFO: The remote '$CURRENT_REMOTE' has been removed! You are now controlling your local instance."
fi
2023-03-09 20:36:30 +00:00
fi