Add --purge to reset.sh
This commit is contained in:
parent
9e7d9d3a90
commit
1fdf96bfa2
@ -10,7 +10,7 @@ if lxc remote get-default | grep -q "local"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "WARNING: This will DESTROY any existing VMs!"
|
||||
echo "WARNING: This will DESTROY any existing VMs! Use the --purge flag to delete ALL Sovereign Stack LXD resources."
|
||||
|
||||
RESPONSE=
|
||||
read -r -p "Are you sure you want to continue (y/n): ": RESPONSE
|
||||
|
@ -4,6 +4,23 @@
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
|
||||
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
|
||||
|
||||
source ../defaults.sh
|
||||
|
||||
./destroy.sh
|
||||
@ -27,39 +44,43 @@ if ! lxc info | grep -q "project: default"; then
|
||||
lxc project delete "$CURRENT_PROJECT"
|
||||
fi
|
||||
|
||||
if lxc profile show default | grep -q "root:"; then
|
||||
lxc profile device remove default root
|
||||
fi
|
||||
|
||||
if lxc profile show default| grep -q "eth0:"; then
|
||||
lxc profile device remove default eth0
|
||||
fi
|
||||
if [ "$PURGE_LXD" = true ]; then
|
||||
|
||||
if lxc network list --format csv | grep -q lxdbr0; then
|
||||
lxc network delete lxdbr0
|
||||
fi
|
||||
if lxc profile show default | grep -q "root:"; then
|
||||
lxc profile device remove default root
|
||||
fi
|
||||
|
||||
if lxc network list --format csv | grep -q lxdbr1; then
|
||||
lxc network delete lxdbr1
|
||||
fi
|
||||
if lxc profile show default| grep -q "eth0:"; then
|
||||
lxc profile device remove default eth0
|
||||
fi
|
||||
|
||||
# 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
|
||||
if lxc network list --format csv | grep -q lxdbr0; then
|
||||
lxc network delete lxdbr0
|
||||
fi
|
||||
|
||||
if lxc network list --format csv | grep -q lxdbr1; then
|
||||
lxc network delete lxdbr1
|
||||
fi
|
||||
|
||||
# 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
|
||||
done
|
||||
|
||||
if lxc storage list --format csv | grep -q ss-base; then
|
||||
lxc storage delete ss-base
|
||||
fi
|
||||
if lxc storage list --format csv | grep -q ss-base; then
|
||||
lxc storage delete ss-base
|
||||
fi
|
||||
|
||||
CURRENT_REMOTE="$(lxc remote get-default)"
|
||||
if ! lxc remote get-default | grep -q "local"; then
|
||||
lxc remote switch local
|
||||
lxc remote remove "$CURRENT_REMOTE"
|
||||
CURRENT_REMOTE="$(lxc remote get-default)"
|
||||
if ! lxc remote get-default | grep -q "local"; then
|
||||
lxc remote switch local
|
||||
lxc remote remove "$CURRENT_REMOTE"
|
||||
|
||||
echo "INFO: The remote '$CURRENT_REMOTE' has been removed! You are now controlling your local instance."
|
||||
echo "INFO: The remote '$CURRENT_REMOTE' has been removed! You are now controlling your local instance."
|
||||
fi
|
||||
fi
|
Loading…
Reference in New Issue
Block a user