1
1
sovereign-stack/deployment/reset.sh

88 lines
2.3 KiB
Bash
Raw Normal View History

2023-02-01 19:44:05 +00:00
#!/bin/bash
2024-02-09 16:33:44 +00:00
set -exu
2023-02-01 19:44:05 +00:00
cd "$(dirname "$0")"
2024-02-09 16:33:44 +00:00
echo "WARNING: THIS SCRIPT NEEDS WORK"
exit 1
2023-09-22 23:46:07 +00:00
PURGE_INCUS=false
2023-03-19 17:49:37 +00:00
# grab any modifications from the command line.
for i in "$@"; do
case $i in
--purge)
2023-09-22 23:46:07 +00:00
PURGE_INCUS=true
2023-03-19 17:49:37 +00:00
shift
;;
*)
echo "Unexpected option: $1"
exit 1
;;
esac
done
2023-02-01 19:44:05 +00:00
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.
2023-09-22 23:46:07 +00:00
if incus profile list | grep -q "$BASE_IMAGE_VM_NAME"; then
incus profile delete "$BASE_IMAGE_VM_NAME"
2023-03-02 14:46:17 +00:00
fi
2023-09-22 23:46:07 +00:00
if incus image list | grep -q "$BASE_IMAGE_VM_NAME"; then
incus image rm "$BASE_IMAGE_VM_NAME"
2023-03-02 14:46:17 +00:00
fi
2023-09-22 23:46:07 +00:00
if incus image list | grep -q "$DOCKER_BASE_IMAGE_NAME"; then
incus image rm "$DOCKER_BASE_IMAGE_NAME"
2023-03-02 14:46:17 +00:00
fi
2023-09-22 23:46:07 +00:00
CURRENT_PROJECT="$(incus info | grep "project:" | awk '{print $2}')"
if ! incus info | grep -q "project: default"; then
incus project switch default
incus project delete "$CURRENT_PROJECT"
2023-03-02 14:46:17 +00:00
fi
2023-09-22 23:46:07 +00:00
if [ "$PURGE_INCUS" = true ]; then
2023-03-02 14:46:17 +00:00
2023-09-22 23:46:07 +00:00
if incus profile show default | grep -q "root:"; then
incus profile device remove default root
2023-03-19 17:49:37 +00:00
fi
2023-03-02 14:46:17 +00:00
2023-09-22 23:46:07 +00:00
if incus profile show default| grep -q "eth0:"; then
incus profile device remove default eth0
2023-03-19 17:49:37 +00:00
fi
2023-09-23 16:26:51 +00:00
if incus network list --format csv -q --project default | grep -q incusbr0; then
incus network delete incusbr0 --project default
2023-03-19 17:49:37 +00:00
fi
2023-11-30 02:33:45 +00:00
if incus network list --format csv -q --project default | grep -q incusbr1; then
incus network delete incusbr1 --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
2023-09-22 23:46:07 +00:00
# if incus storage volume list ss-base | grep -q "$CHAIN-$DATA"; then
# incus storage volume delete ss-base "$CHAIN-$DATA"
# fi
# done
# done
2023-03-16 19:50:02 +00:00
2023-08-21 00:47:27 +00:00
echo "WARNING: ss-basae NOT DELETED. NEED TO TEST THIS SCRIPT"
2023-09-22 23:46:07 +00:00
# if incus storage list --format csv | grep -q ss-base; then
# incus storage delete ss-base
2023-08-21 00:47:27 +00:00
# fi
2023-03-02 14:46:17 +00:00
2023-09-22 23:46:07 +00:00
CURRENT_REMOTE="$(incus remote get-default)"
if ! incus remote get-default | grep -q "local"; then
incus remote switch local
incus 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