summaryrefslogtreecommitdiffstats
path: root/gerrit-launcher
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2012-05-09 15:09:21 -0700
committerShawn O. Pearce <sop@google.com>2012-05-10 15:17:07 -0700
commit450f0cc2625bfb4c4e382295d7b669e61c978b2a (patch)
tree9e9ed0f9fcb53a1f4a4c434e6abc6eae6202ffe0 /gerrit-launcher
parent0ad46d4d12630f6b3e8a2fc1de7f755f7bab6ea1 (diff)
Unpack JARs for running servers in $site_path/tmp
Instead of unpacking a running server into ~/.gerritcodereview/tmp only use that location for commands like init where there is no active site. From gerrit.sh always use $site_path/tmp for the JARs to isolate servers that run on the same host under the same UNIX user account. Change-Id: I688490ffbbf70312767bb766dc7ccbea52401ad1
Diffstat (limited to 'gerrit-launcher')
-rw-r--r--gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java56
1 files changed, 31 insertions, 25 deletions
diff --git a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
index 7f2007ef56..61bb52f709 100644
--- a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
+++ b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
@@ -423,36 +423,42 @@ public final class GerritLauncher {
}
private static File tmproot() {
- // Try to find the user's home directory. If we can't find it
- // return null so the JVM's default temporary directory is used
- // instead. This is probably /tmp or /var/tmp.
- //
- String userHome = System.getProperty("user.home");
- if (userHome == null || "".equals(userHome)) {
- userHome = System.getenv("HOME");
+ File tmp;
+ String gerritTemp = System.getenv("GERRIT_TMP");
+ if (gerritTemp != null && gerritTemp.length() > 0) {
+ tmp = new File(gerritTemp);
+ } else {
+ // Try to find the user's home directory. If we can't find it
+ // return null so the JVM's default temporary directory is used
+ // instead. This is probably /tmp or /var/tmp.
+ //
+ String userHome = System.getProperty("user.home");
if (userHome == null || "".equals(userHome)) {
- System.err.println("warning: cannot determine home directory");
- System.err.println("warning: using system temporary directory instead");
- return null;
+ userHome = System.getenv("HOME");
+ if (userHome == null || "".equals(userHome)) {
+ System.err.println("warning: cannot determine home directory");
+ System.err.println("warning: using system temporary directory instead");
+ return null;
+ }
}
- }
- // Ensure the home directory exists. If it doesn't, try to make it.
- //
- final File home = new File(userHome);
- if (!home.exists()) {
- if (home.mkdirs()) {
- System.err.println("warning: created " + home.getAbsolutePath());
- } else {
- System.err.println("warning: " + home.getAbsolutePath() + " not found");
- System.err.println("warning: using system temporary directory instead");
- return null;
+ // Ensure the home directory exists. If it doesn't, try to make it.
+ //
+ final File home = new File(userHome);
+ if (!home.exists()) {
+ if (home.mkdirs()) {
+ System.err.println("warning: created " + home.getAbsolutePath());
+ } else {
+ System.err.println("warning: " + home.getAbsolutePath() + " not found");
+ System.err.println("warning: using system temporary directory instead");
+ return null;
+ }
}
- }
- // Use $HOME/.gerritcodereview/tmp for our temporary file area.
- //
- final File tmp = new File(new File(home, ".gerritcodereview"), "tmp");
+ // Use $HOME/.gerritcodereview/tmp for our temporary file area.
+ //
+ tmp = new File(new File(home, ".gerritcodereview"), "tmp");
+ }
if (!tmp.exists() && !tmp.mkdirs()) {
System.err.println("warning: cannot create " + tmp.getAbsolutePath());
System.err.println("warning: using system temporary directory instead");