Contribute the reindexer Groovy script to reindex on-line

The current Gerrit command to triggering the on-line reindexer
would not recreate the current version of the indexes.
The reindexer Groovy script will allow to force the reindexing
on-line and thus being able to fix the running index without
having to shutdown Gerrit.

Change-Id: Ic85e7f0ec7fb1537517b0c3c7911ac65681ba7bd
diff --git a/README.md b/README.md
index ded0496..ec4eb15 100644
--- a/README.md
+++ b/README.md
@@ -5,3 +5,18 @@
 --------
 This repository contains a collection of Gerrit scripting plugins
 that are intended to provide simple and useful extensions.
+
+How to run the scripting plugins
+--------------------------------
+Gerrit needs to be able to recognise the scripts syntax and being able to load them as plugins.
+
+In order to be able to run Groovy scripts, you need to install first the 
+[Groovy scripting provider](https://gerrit.googlesource.com/plugins/scripting/groovy-provider/)
+and then copy the Groovy scripts under your Gerrit /plugins directory.
+
+Similarly for Scala scripts, you need to install the 
+[Scala scripting provider](https://gerrit.googlesource.com/plugins/scripting/scala-provider/)
+and then copy the Scala scripts under your Gerrit /plugins directory.
+
+[Administration Scripts](/admin/)
+------------------------
diff --git a/admin/README.md b/admin/README.md
new file mode 100644
index 0000000..8674119
--- /dev/null
+++ b/admin/README.md
@@ -0,0 +1,10 @@
+Gerrit administration scripts
+=============================
+
+Overview
+--------
+Scripts for the daily administration of Gerrit.
+
+Index
+-----
+[reindexer-1.0.groovy](/admin/reindexer-1.0.groovy) - Allows to recreate the Lucene index using the on-line reindex
diff --git a/admin/reindexer-1.0.groovy b/admin/reindexer-1.0.groovy
new file mode 100644
index 0000000..00cd0be
--- /dev/null
+++ b/admin/reindexer-1.0.groovy
@@ -0,0 +1,21 @@
+import com.google.gerrit.sshd.*
+import com.google.gerrit.extensions.annotations.*
+import com.google.gerrit.lucene.*
+import com.google.inject.*
+import org.kohsuke.args4j.*
+
+@Export("start")
+@CommandMetaData(name = "start", description = "Start a new on-line re-indexing for a target Lucene index version")
+class StartReindex extends SshCommand {
+
+  @Inject OnlineReindexer.Factory reindexerFactory
+
+  @Argument(index = 0, usage = "Index version", metaVar = "VERSION")
+  int indexVersion
+
+  public void run() {
+    def indexer = reindexerFactory.create(indexVersion)
+    indexer.start()
+    stdout.println "On-line reindexing scheduled for version " + indexVersion
+  }
+}