init: Create a command to setup a new Gerrit installation

The init command uses an interactive prompting process to help the
user get a basic website configured.

The --import-projects option will automatically search for and import
any Git repositories which are discovered within gerrit.basePath.

Bug: issue 323
Bug: issue 330
Change-Id: I3d6e8f9f5fea8bfc78f6dfb1fc8f284bebfba670
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/Documentation/pgm-index.txt b/Documentation/pgm-index.txt
index 00246bb..069ec59 100644
--- a/Documentation/pgm-index.txt
+++ b/Documentation/pgm-index.txt
@@ -9,8 +9,8 @@
 [[programs]]Programs
 --------------------
 
-CreateSchema::
-  Initialize a new database schema.
+link:pgm-init.html[init]::
+  Initialize a new Gerrit server installation
 
 link:pgm-daemon.html[daemon]::
   Gerrit HTTP, SSH network server.
@@ -18,6 +18,9 @@
 version::
   Display the release version of Gerrit Code Review.
 
+CreateSchema::
+  Initialize a new database schema.
+
 GERRIT
 ------
 Part of link:index.html[Gerrit Code Review]
diff --git a/Documentation/pgm-init.txt b/Documentation/pgm-init.txt
new file mode 100644
index 0000000..b1e2ec8
--- /dev/null
+++ b/Documentation/pgm-init.txt
@@ -0,0 +1,51 @@
+init
+====
+
+NAME
+----
+init - Initialize a new Gerrit server installation
+
+SYNOPSIS
+--------
+[verse]
+'java' -jar gerrit.war 'init'
+	-d <SITE_PATH>
+	[\--batch]
+	[\--import-projects]
+
+DESCRIPTION
+-----------
+Creates a new Gerrit server installation, interactively prompting
+for some basic setup prior to writing default configuration files
+into a newly created `$site_path`.
+
+If run an an existing `$site_path`, init will upgrade some resources
+as necessary.  This can be useful to import newly created projects.
+
+OPTIONS
+-------
+\--batch::
+	Run in batch mode, skipping interactive prompts.  Reasonable
+	configuration defaults are chosen based on the whims of
+	the Gerrit developers.
+
+\--import-projects::
+	Recursively search
+	link:config-gerrit.html#gerrit.basePath[gerrit.basePath]
+	for any Git repositories not yet registered as a project,
+	and initializes a new project for them.
+
+-d::
+\--site-path::
+	Location of the gerrit.config file, and all other per-site
+	configuration data, supporting libaries and log files.
+
+CONTEXT
+-------
+This command can only be run on a server which has direct
+connectivity to the metadata database, and local access to the
+managed Git repositories.
+
+GERRIT
+------
+Part of link:index.html[Gerrit Code Review]