init: Add --no-auto-start to prevent starting the daemon

I'm going to change the recommended upgrade path from 2.0 to 2.1
to initialize a new site path and move everything over.  This may
require avoiding the auto-start of the daemon near the end.

Change-Id: Id9d5b5b94d40b4c95c7b3a31796c943a8f684f76
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/Documentation/pgm-init.txt b/Documentation/pgm-init.txt
index b1e2ec8..9644e92 100644
--- a/Documentation/pgm-init.txt
+++ b/Documentation/pgm-init.txt
@@ -12,6 +12,7 @@
 	-d <SITE_PATH>
 	[\--batch]
 	[\--import-projects]
+	[\--no-auto-start]
 
 DESCRIPTION
 -----------
@@ -35,6 +36,12 @@
 	for any Git repositories not yet registered as a project,
 	and initializes a new project for them.
 
+\--no-auto-start::
+	Don't automatically start the daemon after initializing a
+	newly created site path.  This permits the administartor
+	to inspect and modify the configuration before the daemon
+	is started.
+
 -d::
 \--site-path::
 	Location of the gerrit.config file, and all other per-site
diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/Init.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/Init.java
index 33918bd..c215cf1 100644
--- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/Init.java
+++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/Init.java
@@ -77,6 +77,9 @@
   @Option(name = "--import-projects", usage = "Import git repositories as projects")
   private boolean importProjects;
 
+  @Option(name = "--no-auto-start", usage = "Don't automatically start daemon after init")
+  private boolean noAutoStart;
+
   @Inject
   private GitRepositoryManager repositoryManager;
 
@@ -130,7 +133,7 @@
 
     System.err.println("Initialized " + getSitePath().getCanonicalPath());
 
-    if (isNew) {
+    if (isNew && !noAutoStart) {
       if (IoUtil.isWin32()) {
         System.err.println("Automatic startup not supported on this platform.");