From 8d21047740b547edec292158726097b02cd9868a Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 19 Sep 2020 04:13:58 -0400 Subject: [PATCH] add full reset script and instructions --- bin/reset_bubble_full | 49 +++++++++++++++++++ .../src/main/java/bubble/ApiConstants.java | 1 + .../dao/account/AccountOwnedEntityDAO.java | 3 +- docs/dev.md | 9 ++++ docs/local-launcher.md | 11 ++++- 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100755 bin/reset_bubble_full diff --git a/bin/reset_bubble_full b/bin/reset_bubble_full new file mode 100755 index 00000000..4e95a13a --- /dev/null +++ b/bin/reset_bubble_full @@ -0,0 +1,49 @@ +#!/bin/bash +# +# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/ +# +# +# Perform a full reset of Bubble. Removes the database and all locally stored files +# +# Usage: reset_bubble_full +# +SCRIPT="${0}" +SCRIPT_DIR=$(cd $(dirname ${SCRIPT}) && pwd) +. ${SCRIPT_DIR}/bubble_common + +SELF_NODE_JSON="${HOME}/self_node.json" +BUBBLE_VERSIONS_FILE="${HOME}/bubble_versions.properties" + +BUBBLE_LOCAL_STORAGE_DIR_DEFAULT=".bubble_local_storage" +BUBBLE_LOCAL_STORAGE_DIR=$(${SCRIPT_DIR}/bin/bconst bubble.cloud.storage.local.LocalStorageDriver.BUBBLE_LOCAL_STORAGE_DIR) +if [[ -z ${BUBBLE_LOCAL_STORAGE_DIR} ]] ; then + echo "Error determining Bubble LocalStorage directory, using default: ${BUBBLE_LOCAL_STORAGE_DIR_DEFAULT}" + BUBBLE_LOCAL_STORAGE_DIR=${BUBBLE_LOCAL_STORAGE_DIR_DEFAULT} +fi +BUBBLE_LOCAL_STORAGE_DIR="${HOME}/${BUBBLE_LOCAL_STORAGE_DIR}" + +BUBBLE_CLOUD_DATA_DIR_DEFAULT="bubble_cloudServiceData" +BUBBLE_CLOUD_DATA_DIR=$(${SCRIPT_DIR}/bin/bconst bubble.ApiConstants.BUBBLE_CLOUD_SERVICE_DATA) +if [[ -z ${BUBBLE_CLOUD_DATA_DIR} ]] ; then + echo "Error determining Bubble Cloud Service Data directory, using default: " + BUBBLE_CLOUD_DATA_DIR=${BUBBLE_CLOUD_DATA_DIR_DEFAULT} +fi +BUBBLE_CLOUD_DATA_DIR="${HOME}/${BUBBLE_CLOUD_DATA_DIR}" + + +rm -f ${SELF_NODE_JSON} || die "Error removing ${SELF_NODE_JSON}" +echo "> removed: ${SELF_NODE_JSON}" + +rm -f ${BUBBLE_VERSIONS_FILE} || die "Error removing ${BUBBLE_VERSIONS_FILE}" +echo "> removed: ${BUBBLE_VERSIONS_FILE}" + +rm -rf ${BUBBLE_LOCAL_STORAGE_DIR} || die "Error removing ${BUBBLE_LOCAL_STORAGE_DIR}" +echo "> removed: ${BUBBLE_LOCAL_STORAGE_DIR}" + +rm -rf ${BUBBLE_CLOUD_DATA_DIR} || die "Error removing ${BUBBLE_CLOUD_DATA_DIR}" +echo "> removed: ${BUBBLE_CLOUD_DATA_DIR}" + +dropdb bubble || die "Error dropping bubble database" +echo "> dropped database: bubble" + +echo "+++ Bubble Reset Complete" diff --git a/bubble-server/src/main/java/bubble/ApiConstants.java b/bubble-server/src/main/java/bubble/ApiConstants.java index 379f2d14..99e95f70 100644 --- a/bubble-server/src/main/java/bubble/ApiConstants.java +++ b/bubble-server/src/main/java/bubble/ApiConstants.java @@ -127,6 +127,7 @@ public class ApiConstants { } } + public static final String BUBBLE_CLOUD_SERVICE_DATA = "bubble_cloudServiceData"; public static final File CACERTS_DIR = new File(HOME_DIR, "cacerts"); public static final File MITMPROXY_CERT_DIR = new File(HOME_DIR, "mitm_certs"); diff --git a/bubble-server/src/main/java/bubble/dao/account/AccountOwnedEntityDAO.java b/bubble-server/src/main/java/bubble/dao/account/AccountOwnedEntityDAO.java index 84d69d1e..d85b8042 100644 --- a/bubble-server/src/main/java/bubble/dao/account/AccountOwnedEntityDAO.java +++ b/bubble-server/src/main/java/bubble/dao/account/AccountOwnedEntityDAO.java @@ -20,6 +20,7 @@ import java.io.File; import java.util.Collection; import java.util.List; +import static bubble.ApiConstants.BUBBLE_CLOUD_SERVICE_DATA; import static bubble.ApiConstants.HOME_DIR; import static org.cobbzilla.util.reflect.ReflectionUtil.getFirstTypeParam; import static org.cobbzilla.util.security.ShaUtil.sha256_hex; @@ -79,7 +80,7 @@ public abstract class AccountOwnedEntityDAO pathMiddle = cloudServiceUuid; } return new File(HOME_DIR + File.separator - + "bubble_cloudServiceData" + File.separator + + BUBBLE_CLOUD_SERVICE_DATA + File.separator + pathMiddle + File.separator + sha.substring(0, 2) + File.separator + sha.substring(2, 4) + File.separator diff --git a/docs/dev.md b/docs/dev.md index 8af03df0..76890579 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -59,3 +59,12 @@ This will update and rebuild all submodules, and the main bubble jar file. ## Running in development Run the `bin/run.sh` script to start the Bubble server. + +## Resetting everything +If you want to "start over", run: + + ./bin/reset_bubble_full + +This will remove local files stored by Bubble, and drop the bubble database. + +If you run `./bin/run.sh` again, it will be like running it for the first time. diff --git a/docs/local-launcher.md b/docs/local-launcher.md index 53035e89..8f1aa0dc 100644 --- a/docs/local-launcher.md +++ b/docs/local-launcher.md @@ -24,12 +24,21 @@ Make a copy of the file `config/activation.json` and edit the copy. There are co To activate your Local Launcher Bubble, run this command: - `./bin/bactivate /path/to/activation.json` + ./bin/bactivate /path/to/activation.json After running the above, refresh the web page that opened when the server started. You should see a login page. You can now login as the admin user using the email address `root@local.local` and the password from your `activation.json` file. +### Resetting everything +If you want to "start over", run: + + ./bin/reset_bubble_full + +This will remove local files stored by Bubble, and drop the bubble database. + +If you run `./bin/run.sh` again, it will be like running it for the first time. + ## Next Steps You are now read to launch a new Bubble in [Bubble Mode](launch-node.md), or a Remote Launcher via [Remote Launcher Mode](remote-launcher.md)