Added teh 'repair' command

git-svn-id: https://svn.apache.org/repos/asf/directory/apacheds/trunk@1749725 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.bat b/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.bat
index 162f08f..4f183d8 100644
--- a/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.bat
+++ b/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.bat
@@ -19,10 +19,12 @@
 

 REM Getting the instance name from the first argument

 set INSTANCE_NAME=%1

+set ACTION=%2

 

 

 REM If there is no first argument, setting the instance name to 'default'

 IF [%1]==[] set INSTANCE_NAME=default

+if [%2]==[] set ACTION=start

 

 

 REM Printing instance information

@@ -38,4 +40,4 @@
 set ADS_EXTENDED_OPERATIONS="-Dapacheds.extendedOperations="

 

 REM Launching ApacheDS

-java %ADS_CONTROLS% %ADS_EXTENDED_OPERATIONS% -Dlog4j.configuration="file:../instances/%INSTANCE_NAME%/conf/log4j.properties" -Dapacheds.log.dir=../instances/%INSTANCE_NAME%/log -cp %ADS_CLASSPATH% org.apache.directory.server.UberjarMain ../instances/%INSTANCE_NAME%

+java %ADS_CONTROLS% %ADS_EXTENDED_OPERATIONS% -Dlog4j.configuration="file:../instances/%INSTANCE_NAME%/conf/log4j.properties" -Dapacheds.log.dir=../instances/%INSTANCE_NAME%/log -cp %ADS_CLASSPATH% org.apache.directory.server.UberjarMain ../instances/%INSTANCE_NAME% %ACTION%

diff --git a/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh b/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh
index 14c38eb..6cf32a2 100644
--- a/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh
+++ b/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh
@@ -157,6 +157,27 @@
         org.apache.directory.server.UberjarMain "\"$ADS_INSTANCE\"" \
         > "$ADS_OUT" 2>&1 "&"
     echo $! > "$ADS_PID"
+elif [ "$ADS_ACTION" = "repair" ]; then
+    # Printing instance information
+    [ $HAVE_TTY -eq 1 ] && echo "Repairing ApacheDS instance '$ADS_INSTANCE_NAME'..."
+
+    if [ -f $ADS_PID ]; then
+        PID=`cat $ADS_PID`
+        if kill -0 $PID > /dev/null 2>&1; then
+            echo "ApacheDS is already running as $PID"
+            exit 0
+        fi
+    fi
+
+    # Repairing ApacheDS
+    eval "\"$RUN_JAVA\"" $JAVA_OPTS $ADS_CONTROLS $ADS_EXTENDED_OPERATIONS \
+        -Dlog4j.configuration="\"file:$ADS_INSTANCE/conf/log4j.properties\"" \
+        -Dapacheds.shutdown.port="\"$ADS_SHUTDOWN_PORT\"" \
+        -Dapacheds.log.dir="\"$ADS_INSTANCE/log\"" \
+        -classpath "\"$CLASSPATH\"" \
+        org.apache.directory.server.UberjarMain "\"$ADS_INSTANCE\"" repair \
+        > "$ADS_OUT" 2>&1 "&"
+    echo $! > "$ADS_PID"
 elif [ "$ADS_ACTION" = "run" ]; then
     # Printing instance information
     [ $HAVE_TTY -eq 1 ] && echo "Running ApacheDS instance '$ADS_INSTANCE_NAME'..."
diff --git a/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf b/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf
index 9b61d73..f5db3c1 100644
--- a/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf
+++ b/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper-installation.conf
@@ -35,6 +35,7 @@
 wrapper.java.additional.3=-Dapacheds.log.dir=${double.quote}%INSTANCE_DIRECTORY%/log${double.quote}
 wrapper.java.additional.4=-Dapacheds.run.dir=${double.quote}%INSTANCE_DIRECTORY%/run${double.quote}
 wrapper.java.additional.5=-Dapacheds.instance=${double.quote}%INSTANCE%${double.quote}
+wrapper.java.additional.6=%REPAIR_COMMAND%
 
 # Initial Java Heap Size (in MB)
 #wrapper.java.initmemory=1024