accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From medi...@apache.org
Subject svn commit: r1378380 - /accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
Date Tue, 28 Aug 2012 23:28:15 GMT
Author: medined
Date: Tue Aug 28 23:28:15 2012
New Revision: 1378380

URL: http://svn.apache.org/viewvc?rev=1378380&view=rev
Log:
ACCUMULO-744: Allow instance-name and password as parameters to init.

Modified:
    accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/Initialize.java

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/Initialize.java?rev=1378380&r1=1378379&r2=1378380&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/Initialize.java (original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/util/Initialize.java Tue
Aug 28 23:28:15 2012
@@ -71,6 +71,8 @@ public class Initialize {
   private static final Logger log = Logger.getLogger(Initialize.class);
   private static final String ROOT_USER = "root";
   private static boolean clearInstanceName = false;
+  private static String cliInstanceName = null;
+  private static String cliPassword = null;
   
   private static ConsoleReader reader = null;
   
@@ -371,7 +373,11 @@ public class Initialize {
     String instanceName, instanceNamePath = null;
     boolean exists = true;
     do {
-      instanceName = getConsoleReader().readLine("Instance name : ");
+      if (cliInstanceName == null) {
+        instanceName = getConsoleReader().readLine("Instance name : ");
+      } else {
+        instanceName = cliInstanceName;
+      }
       if (instanceName == null)
         System.exit(0);
       instanceName = instanceName.trim();
@@ -395,6 +401,9 @@ public class Initialize {
   }
   
   private static byte[] getRootPassword() throws IOException {
+    if (cliPassword != null) {
+      return cliPassword.getBytes();
+    }
     String rootpass;
     String confirmpass;
     do {
@@ -452,16 +461,23 @@ public class Initialize {
   public static void main(String[] args) {
     boolean justSecurity = false;
     
-    for (String arg : args) {
-      if (arg.equals("--reset-security")) {
-        justSecurity = true;
-      } else if (arg.equals("--clear-instance-name")) {
-        clearInstanceName = true;
-      } else {
-        RuntimeException e = new RuntimeException();
-        log.fatal("Bad argument " + arg, e);
-        throw e;
-      }
+    for (int i = 0; i < args.length; i++) {
+      if (args[i].equals("--reset-security")) {
+          justSecurity = true;
+        } else if (args[i].equals("--clear-instance-name")) {
+          clearInstanceName = true;
+        } else if (args[i].equals("--instance-name")) {
+            cliInstanceName = args[i+1];
+            i++;
+        } else if (args[i].equals("--password")) {
+            cliPassword = args[i+1];
+            i++;
+        } else {
+          RuntimeException e = new RuntimeException();
+          log.fatal("Usage: [--reset-security] [--clear-instance-name] [--instance-name {name}]
[--password {password}]");
+          log.fatal("Bad argument " + args[i], e);
+          throw e;
+        }
     }
     
     try {



Mime
View raw message