From 46da7074640d6ae1922ed88a4b98940e7aeef10d Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 22 Aug 2020 14:57:57 -0400 Subject: [PATCH 1/3] testing --- bin/jenkins/test-redis | 31 +++++++++++++++++++++++-------- utils/cobbzilla-wizard | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/bin/jenkins/test-redis b/bin/jenkins/test-redis index 331c1a2c..0cfd439a 100755 --- a/bin/jenkins/test-redis +++ b/bin/jenkins/test-redis @@ -31,12 +31,10 @@ function start_redis() { echo "Starting redis..." redis-server ${REDIS_CONF} || die "Error starting redis" - echo "Redis successfully started on port ${port}" } -function stop_redis() { - port=$(redis_port) - REDIS_DIR=/tmp/redis-${port} +function stop_redis_by_dir() { + REDIS_DIR=${1} PID_FILE=${REDIS_DIR}/redis.pid if [[ ! -f ${PID_FILE} ]] ; then echo "Redis pid file not found: ${PID_FILE}" @@ -45,26 +43,43 @@ function stop_redis() { kill $(cat ${PID_FILE}) || die "Error killing redis using pid file: ${PID_FILE}" fi - echo "Removing redis dir: ${REDIS_DIR}" - rm -rf ${REDIS_DIR} || die "Error removing redis dir: ${REDIS_DIR}" + if [[ -d ${REDIS_DIR} ]] ; then + echo "Removing redis dir: ${REDIS_DIR}" + rm -rf ${REDIS_DIR} || die "Error removing redis dir: ${REDIS_DIR}" + fi +} - echo "Redis stopped and cleaned up" +function stop_redis() { + port=$(redis_port) + REDIS_DIR=/tmp/redis-${port} + stop_redis_by_dir ${REDIS_DIR} +} + +function redis_clean() { + for REDIS_DIR in $(find /tmp -maxdepth 1 -type d -name "redis-*") ; do + stop_redis_by_dir ${REDIS_DIR} + done } if [[ -z ${1} ]] ; then - die "expected one of: start stop port" + die "expected one of: start stop clean port" fi case ${1} in "start") start_redis + echo "Redis successfully started" ;; "stop") stop_redis + echo "Redis stopped and cleaned up" ;; "port") redis_port ;; + "clean") + redis_clean + ;; *) die "invalid argument: ${1}" ;; diff --git a/utils/cobbzilla-wizard b/utils/cobbzilla-wizard index 13fd0bc4..6d0900b9 160000 --- a/utils/cobbzilla-wizard +++ b/utils/cobbzilla-wizard @@ -1 +1 @@ -Subproject commit 13fd0bc476779b7c1d7c28fd7bf1171ea11703f0 +Subproject commit 6d0900b9cdf1f47824ea6c50642fd0dfc664cb58 From 308b0006d452919c1bfd39d23f6a1e760073f595 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 22 Aug 2020 15:07:49 -0400 Subject: [PATCH 2/3] prefer env.HOME --- bin/jenkins/test-redis | 1 + bubble-server/src/main/java/bubble/ApiConstants.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/jenkins/test-redis b/bin/jenkins/test-redis index 0cfd439a..95577658 100755 --- a/bin/jenkins/test-redis +++ b/bin/jenkins/test-redis @@ -67,6 +67,7 @@ fi case ${1} in "start") + stop_redis start_redis echo "Redis successfully started" ;; diff --git a/bubble-server/src/main/java/bubble/ApiConstants.java b/bubble-server/src/main/java/bubble/ApiConstants.java index 2dd17322..3ec73ac1 100644 --- a/bubble-server/src/main/java/bubble/ApiConstants.java +++ b/bubble-server/src/main/java/bubble/ApiConstants.java @@ -76,7 +76,17 @@ public class ApiConstants { public static final GoogleAuthenticator G_AUTH = new GoogleAuthenticator(); public static final Predicate ALWAYS_TRUE = m -> true; - public static final String HOME_DIR = System.getProperty("user.home"); + public static final String HOME_DIR; + static { + final String userHome = System.getProperty("user.home"); + final String envHome = System.getenv("HOME"); + if (!userHome.equals(envHome)) { + log.warn("System.getProperty(\"user.home\") == "+userHome+" differs from System.getenv(\"HOME\") == "+envHome+", using HOME from environment: "+envHome); + HOME_DIR = envHome; + } else { + HOME_DIR = userHome; + } + } public static final File CACERTS_DIR = new File(HOME_DIR, "cacerts"); public static final File MITMPROXY_CERT_DIR = new File(HOME_DIR, "mitm_certs"); From 61b40a8bbfce51ebbdd1ece0ad440eb8238f4bf9 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 22 Aug 2020 15:18:29 -0400 Subject: [PATCH 3/3] use HOME_DIR almost everywhere --- .../java/bubble/cloud/storage/local/LocalStorageDriver.java | 5 +++-- bubble-server/src/main/java/bubble/server/BubbleServer.java | 2 +- utils/cobbzilla-utils | 2 +- utils/cobbzilla-wizard | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bubble-server/src/main/java/bubble/cloud/storage/local/LocalStorageDriver.java b/bubble-server/src/main/java/bubble/cloud/storage/local/LocalStorageDriver.java index 205f2f5a..4ce80c64 100644 --- a/bubble-server/src/main/java/bubble/cloud/storage/local/LocalStorageDriver.java +++ b/bubble-server/src/main/java/bubble/cloud/storage/local/LocalStorageDriver.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static bubble.ApiConstants.HOME_DIR; import static bubble.ApiConstants.ROOT_NETWORK_UUID; import static org.cobbzilla.util.daemon.ZillaRuntime.*; import static org.cobbzilla.util.io.FileUtil.*; @@ -53,7 +54,7 @@ public class LocalStorageDriver extends CloudServiceDriverBase { System.getProperty("user.dir") + "/bubble.env" }; - private static AtomicReference restoreKey = new AtomicReference<>(); + private static final AtomicReference restoreKey = new AtomicReference<>(); public static boolean isRestoreMode () { return restoreKey.get() != null; } public static void disableRestoreMode () { final BubbleNode selfNode = nodeFromFile(THIS_NODE_FILE); diff --git a/utils/cobbzilla-utils b/utils/cobbzilla-utils index 60856285..74230fcc 160000 --- a/utils/cobbzilla-utils +++ b/utils/cobbzilla-utils @@ -1 +1 @@ -Subproject commit 60856285c4f37967fd1effc438f08878607c11a9 +Subproject commit 74230fcc51ee1177a898de135a30b5b70a760e12 diff --git a/utils/cobbzilla-wizard b/utils/cobbzilla-wizard index 6d0900b9..4dcca7b4 160000 --- a/utils/cobbzilla-wizard +++ b/utils/cobbzilla-wizard @@ -1 +1 @@ -Subproject commit 6d0900b9cdf1f47824ea6c50642fd0dfc664cb58 +Subproject commit 4dcca7b4ca0240ad7f2cc1d60909c0ff5830339a