Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 77D78D255 for ; Tue, 28 Aug 2012 23:29:00 +0000 (UTC) Received: (qmail 43567 invoked by uid 500); 28 Aug 2012 23:29:00 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 43519 invoked by uid 500); 28 Aug 2012 23:28:59 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 43510 invoked by uid 99); 28 Aug 2012 23:28:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Aug 2012 23:28:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Aug 2012 23:28:58 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7CDE4238897F for ; Tue, 28 Aug 2012 23:28:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@accumulo.apache.org From: medined@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120828232815.7CDE4238897F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 {