Index: SRUAggregator/trunk/pom.xml
===================================================================
--- SRUAggregator/trunk/pom.xml	(revision 6129)
+++ SRUAggregator/trunk/pom.xml	(revision 6130)
@@ -7,5 +7,5 @@
 
 	<groupId>eu.clarin.sru.fcs</groupId>
-	<artifactId>Aggregator2</artifactId>
+	<artifactId>aggregator</artifactId>
 	<version>2.0.0-beta-32</version>
 	<name>FCS Aggregator</name>
@@ -14,4 +14,6 @@
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <serviceUser>aggregator</serviceUser>
+        <serviceGroup>aggregator</serviceGroup>
 	</properties>
 
@@ -190,4 +192,162 @@
 				</executions>
 			</plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>rpm-maven-plugin</artifactId>
+                <version>2.1-alpha-4</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <group>Applications/System</group>
+                    <name>${project.artifactId}</name>
+                    <release>${buildNumber}</release>
+                    <mappings>
+                        <mapping>
+                            <directory>/usr/share/${project.artifactId}/</directory>
+                            <sources>
+                                <source>
+                                    <location>${project.build.directory}/${project.artifactId}-${project.version}.jar</location>
+                                    <destination>${project.artifactId}.jar</destination>
+                                </source>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/var/lib/${project.artifactId}/</directory>
+                            <filemode>700</filemode>
+                            <username>${serviceUser}</username>
+                            <groupname>${serviceGroup}</groupname>
+                        </mapping>
+                        <mapping>
+                            <directory>/var/log/${project.artifactId}/</directory>
+                            <filemode>700</filemode>
+                            <username>${serviceUser}</username>
+                            <groupname>${serviceGroup}</groupname>
+                        </mapping>
+                        <mapping>
+                            <directory>/usr/bin</directory>
+                            <directoryIncluded>false</directoryIncluded>
+                            <filemode>755</filemode>
+                            <sources>
+                                <source>
+                                    <location>src/assembly/bin/service.sh</location>
+                                    <destination>${project.artifactId}</destination>
+                                </source>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/etc/init.d</directory>
+                            <directoryIncluded>false</directoryIncluded>
+                            <filemode>755</filemode>
+                            <sources>
+                                <source>
+                                    <location>src/assembly/init-scripts/redhat</location>
+                                    <destination>${project.artifactId}</destination>
+                                </source>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/etc/default</directory>
+                            <directoryIncluded>false</directoryIncluded>
+                            <configuration>true</configuration>
+                            <sources>
+                                <source>
+                                    <location>src/assembly/conf/etc.default</location>
+                                    <destination>${project.artifactId}</destination>
+                                </source>
+                            </sources>
+                        </mapping>
+                        <mapping>
+                            <directory>/etc/clarind</directory>
+                            <directoryIncluded>false</directoryIncluded>
+                            <configuration>true</configuration>
+                            <sources>
+                                <source>
+                                    <location>src/assembly/conf/${project.artifactId}.yaml</location>
+                                    <destination>${project.artifactId}.yaml</destination>
+                                </source>
+                            </sources>
+                        </mapping>
+                    </mappings>
+                    <preinstallScriptlet>
+                        <script>
+                            /usr/bin/getent group ${serviceGroup} &gt; /dev/null || /usr/sbin/groupadd ${project.artifactId}
+                            /usr/bin/getent passwd ${serviceUser} &gt; /dev/null || /usr/sbin/useradd -r -d /var/lib/${project.artifactId} -m -g ${serviceGroup} ${serviceUser}
+                        </script>
+                    </preinstallScriptlet>
+                    <postinstallScriptlet>
+                        <script>
+                            chkconfig --add ${project.artifactId};
+                            chkconfig ${project.artifactId} on;
+                            if [ $1 -eq 0 ]; then
+                                /sbin/service ${project.artifactId} start
+                            elif [ $1 -ge 1 ]; then
+                                /sbin/service ${project.artifactId} restart
+                            fi
+                        </script>
+                    </postinstallScriptlet>
+                    <preremoveScriptlet>
+                        <script>
+                            if [ $1 -eq 0 ] ; then
+                            /sbin/service ${project.artifactId} stop;chkconfig --del ${project.artifactId}
+                            fi
+                        </script>
+                    </preremoveScriptlet>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>jdeb</artifactId>
+                <groupId>org.vafer</groupId>
+                <version>1.3</version>
+                    <configuration>
+                        <dataSet>
+                            <data>
+                              <src>${project.build.directory}/${project.artifactId}-${project.version}.jar</src>
+                              <type>file</type>
+                              <dst>/usr/share/${project.artifactId}/${project.artifactId}.jar</dst>
+                            </data>
+                            <data>
+                                <src>${project.basedir}/src/assembly/bin/service.sh</src>
+                              <dst>/usr/bin/${project.artifactId}</dst>
+                              <type>file</type>
+                              <mapper>
+                                    <type>perm</type>
+                                    <filemode>755</filemode>
+                              </mapper>
+                            </data>
+                            <data>
+                              <src>${project.basedir}/src/assembly/init-scripts/ubuntu</src>
+                              <dst>/etc/init.d/${project.artifactId}</dst>
+                              <type>file</type>
+                              <mapper>
+                                    <type>perm</type>
+                                    <filemode>755</filemode>
+                              </mapper>
+                            </data>
+                            <data>
+                                <src>${project.basedir}/src/assembly/conf/${project.artifactId}.yaml</src>
+                              <dst>/etc/clarind/${project.artifactId}.yaml</dst>
+                              <type>file</type>
+                              <conffile>true</conffile>
+                            </data>
+                            <data>
+                              <src>${project.basedir}/src/assembly/conf/etc.default</src>
+                              <dst>/etc/default/${project.artifactId}</dst>
+                              <type>file</type>
+                              <conffile>true</conffile>
+                            </data>
+                            <data>
+                                <type>template</type>
+                                <paths>
+                                    <path>var/lib/${project.artifactId}</path>
+                                    <path>var/log/${project.artifactId}</path>
+                                </paths>
+                                <mapper>
+                                    <type>perm</type>
+                                    <user>${project.artifactId}</user>
+                                    <group>${project.artifactId}</group>
+                                </mapper>
+                            </data>
+                        </dataSet>
+                    </configuration>
+            </plugin>
 		</plugins>
 	</build>
Index: SRUAggregator/trunk/src/assembly/bin/service.sh
===================================================================
--- SRUAggregator/trunk/src/assembly/bin/service.sh	(revision 6130)
+++ SRUAggregator/trunk/src/assembly/bin/service.sh	(revision 6130)
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# This is a simple startup script that should work for the
+# dropwizard based web services.
+#
+
+APPNAME=$(basename $0)
+BASEDIR=${BASEDIR:-.}
+CONFFILE=${CONFFILE:-${BASEDIR}/${APPNAME}.yaml}
+HEAPSIZE=${HEAPSIZE:-2048m}
+JARFILE=${JARFILE:-${BASEDIR}/${APPNAME}.jar}
+
+while getopts ":c:h:" opt; do
+    case $opt in
+        c) CONFFILE=${OPTARG}
+        ;;
+        h) HEAPSIZE=${OPTARG}
+        ;;
+    esac
+done
+
+cd ${BASEDIR}
+exec java -Xmx${HEAPSIZE} -jar ${JARFILE} server ${CONFFILE}
Index: SRUAggregator/trunk/src/assembly/conf/aggregator.yaml
===================================================================
--- SRUAggregator/trunk/src/assembly/conf/aggregator.yaml	(revision 6130)
+++ SRUAggregator/trunk/src/assembly/conf/aggregator.yaml	(revision 6130)
@@ -0,0 +1,62 @@
+aggregatorParams:
+  CENTER_REGISTRY_URL: http://centres.clarin.eu/restxml/
+#  additionalCQLEndpoints:
+#    # - https://clarin.ids-mannheim.de/digibibsru-new
+#    # - https://lux17.mpi.nl/ds/cqlsearch
+#    # - http://cqlservlet.mpi.nl/
+#    # - http://dspin.dwds.de:8088/ddc-sru/dingler/
+#    # - http://www.meertens.knaw.nl/mimore/srucql/
+#    # - http://gysseling.corpus.taalbanknederlands.inl.nl/gyssru/
+#    # - http://brievenalsbuit.inl.nl/zbsru/
+#    # - http://corpus3.aac.ac.at/ddconsru/
+#    #  - http://dspin.dwds.de:8088/ddc-sru/dta/
+
+  AGGREGATOR_FILE_PATH: /var/lib/aggregator/fcsAggregatorCorpora.json
+  AGGREGATOR_FILE_PATH_BACKUP: /var/lib/aggregator/fcsAggregatorCorpora.backup.json
+  # AGGREGATOR_FILE_PATH: /Users/edima/fcsAggregatorCorpora.json
+  # AGGREGATOR_FILE_PATH_BACKUP: /Users/edima/fcsAggregatorCorpora.backup.json
+  SCAN_MAX_DEPTH: 3 # recommended 3
+  SCAN_TASK_INITIAL_DELAY: 0
+  SCAN_TASK_INTERVAL: 12
+  SCAN_TASK_TIME_UNIT: HOURS
+
+  SCAN_MAX_CONCURRENT_REQUESTS_PER_ENDPOINT: 4  # @depth2: 1=361s; 2=225s; 4=207s
+  SEARCH_MAX_CONCURRENT_REQUESTS_PER_ENDPOINT: 4
+
+  ENDPOINTS_SCAN_TIMEOUT_MS: 60000
+  ENDPOINTS_SEARCH_TIMEOUT_MS: 30000
+  EXECUTOR_SHUTDOWN_TIMEOUT_MS: 1000
+
+  weblichtConfig:
+    url: https://weblicht.sfs.uni-tuebingen.de/webLicht/?input=
+    acceptedTcfLanguages:
+      - en
+      - de
+      - nl
+      - fr
+      - it
+      - es
+      - pl
+
+# use the simple server factory, run on a single port
+server:
+  applicationContextPath: /Aggregator
+  type: simple
+  connector:
+    type: http
+    port: 4019
+
+# Logging settings.
+logging:
+  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
+  level: WARN
+  # Logger-specific levels.
+  loggers:
+    eu.clarin.sru.fcs.aggregator: INFO
+    eu.clarin.sru.client: WARN
+
+  appenders:
+    - type: file
+      currentLogFilename: /var/log/aggregator/access.log
+      archivedLogFilenamePattern: /var/log/aggregator/access-%d.log.gz
+      archivedFileCount: 5
Index: SRUAggregator/trunk/src/assembly/conf/etc.default
===================================================================
--- SRUAggregator/trunk/src/assembly/conf/etc.default	(revision 6130)
+++ SRUAggregator/trunk/src/assembly/conf/etc.default	(revision 6130)
@@ -0,0 +1,5 @@
+BASEDIR=/var/lib/aggregator
+HEAPSIZE=2048m
+CONFFILE=/etc/clarind/aggregator.yaml
+JARFILE=/usr/share/aggregator/aggregator.jar
+export BASEDIR HEAPSIZE CONFFILE JARFILE
Index: SRUAggregator/trunk/src/assembly/init-scripts/redhat
===================================================================
--- SRUAggregator/trunk/src/assembly/init-scripts/redhat	(revision 6130)
+++ SRUAggregator/trunk/src/assembly/init-scripts/redhat	(revision 6130)
@@ -0,0 +1,87 @@
+#!/bin/bash
+#
+# WebLicht init script for redhat derivatives (mainly for Scientific Linux)
+#
+# start late, stop early
+# chkconfig: 2345 95 05
+# description: WebLicht
+#
+
+
+PATH=/usr/java/jdk1.7.0_67/bin:/sbin:/bin:/usr/bin:/usr/sbin
+export PATH
+START_SCRIPT=/usr/bin/aggregator
+
+test -x $START_SCRIPT || exit 0
+set -e
+. /lib/lsb/init-functions
+
+SERVICE_NAME=$(basename $0|sed 's/^S[0-9]*//')
+
+test -r /etc/default/$SERVICE_NAME && . /etc/default/$SERVICE_NAME
+
+APPUSER=${FCSUSER:-aggregator}
+APPGROUP=${FCSGROUP:-aggregator}
+
+PIDFILE=/var/run/${SERVICE_NAME}.pid
+
+# Redhat/SL does not provice start-stop-deamon
+# these are the replacemnt functions
+app_start() {
+    local pids=$(pgrep -f "java.*${JARFILE}.*${CONFFILE}")
+    if [ -n "$pids" ]; then
+        echo "$SERVICE_NAME (pid $pids) is already running"
+        return 0
+    fi
+    printf "%-50s%s" "Starting $SERVICE_NAME: " ''
+    /sbin/runuser -g $APPGROUP $APPUSER \
+                  -c "$START_SCRIPT $OPTIONS" \
+                  >/dev/null 2>&1 &
+    pid=$!
+    sleep 2
+    
+    if ps -p $pid >/dev/null 2>&1; then
+        echo $pid > $PIDFILE
+        echo '[  OK  ]'
+    else
+        echo '[FAILED]'
+    fi
+}
+
+app_stop() {
+    local pid=$(cat $PIDFILE)
+
+    if [ -z "$pid" ] || ! ps -p $pid >/dev/null 2>&1; then
+        echo "$SERVICE_NAME not running"
+        return 0
+    fi
+    printf "%-50s%s" "Stopping $SERVICE_NAME: " ''
+    kill $pid
+    sleep 2
+    if ps -p $pid >/dev/null 2>&1; then
+        echo '[FAILED]'
+    else
+        rm -f $PIDFILE
+        echo '[  OK  ]'
+    fi
+}
+
+
+case "$1" in
+    start)
+        app_start
+        ;;
+    stop)
+        app_stop
+        ;;
+    restart)
+        app_stop
+        sleep 2
+        app_start
+	;;
+    *)
+        echo "Usage: $NAME {start|stop|restart}" >&2
+        exit 1
+        ;;
+esac
+exit 0
Index: SRUAggregator/trunk/src/assembly/init-scripts/ubuntu
===================================================================
--- SRUAggregator/trunk/src/assembly/init-scripts/ubuntu	(revision 6130)
+++ SRUAggregator/trunk/src/assembly/init-scripts/ubuntu	(revision 6130)
@@ -0,0 +1,61 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          aggregator
+# Required-Start:    $local_fs $remote_fs $network $syslog
+# Required-Stop:     $local_fs $remote_fs $network $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: WaaS
+# Description:       WaaS - WebLicht as a service
+### END INIT INFO
+
+#. /lib/lsb/init-functions
+
+SERVICE_NAME=$(basename $0)
+
+test -r /etc/default/$SERVICE_NAME && . /etc/default/$SERVICE_NAME
+
+JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-oracle}
+PATH=${JAVA_HOME}/bin:/bin:/sbin:/usr/bin:/usr/sbin
+START_SCRIPT=${START_SCRIPT:-/usr/bin/aggregator}
+PIDFILE=/var/run/${SERVICE_NAME}.pid
+
+APPUSER=${FCSUSER:-aggregator}
+APPGROUP=${FCSGROUP:-aggregator}
+
+
+test -x $START_SCRIPT || exit 0
+
+case "$1" in
+    start)
+        echo -n "Starting $DESC: "
+        start-stop-daemon -b --start --quiet \
+            -c $APPUSER \
+            -g $APPGROUP \
+            -d ${BASEDIR} \
+            -m --pidfile ${PIDFILE} \
+            --exec ${START_SCRIPT} \
+            -- $DAEMON_OPTS 
+        echo "$NAME."
+        ;;
+    stop)
+        echo -n "Stopping $DESC: "
+        start-stop-daemon --stop --quiet --pidfile $PIDFILE
+        echo "$NAME."
+        ;;
+    restart)
+        $0 stop
+        sleep 2
+        $0 start
+    ;;
+    force-reload)
+        $0 stop
+        sleep 2
+        $0 start
+    ;;
+    *)
+        echo "Usage: $NAME {start|stop|restart|force-reload}" >&2
+        exit 1
+        ;;
+esac
+exit 0
Index: SRUAggregator/trunk/src/deb/control/control
===================================================================
--- SRUAggregator/trunk/src/deb/control/control	(revision 6130)
+++ SRUAggregator/trunk/src/deb/control/control	(revision 6130)
@@ -0,0 +1,8 @@
+Package: [[artifactId]]
+Version: [[version]]
+Section: misc
+Priority: optional
+Architecture: all
+Depends: java-runtime
+Maintainer: Cagri Coltekin <ccoltekin@sfs.uni-tuebingen.de>
+Description:  Aggregator - FCS aggregator service
Index: SRUAggregator/trunk/src/deb/control/postinst
===================================================================
--- SRUAggregator/trunk/src/deb/control/postinst	(revision 6130)
+++ SRUAggregator/trunk/src/deb/control/postinst	(revision 6130)
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+action=$1
+version=$2
+
+update-rc.d aggregator defaults
+
+# Restart the service if this is not the first installation.
+if [ -n "$version" -o  "$action" == "upgrade" ]; then
+    invoke-rc.d aggregator restart || true
+else # or try to start it
+    invoke-rc.d aggregator start || true
+fi
+
+
+exit 0
Index: SRUAggregator/trunk/src/deb/control/postrm
===================================================================
--- SRUAggregator/trunk/src/deb/control/postrm	(revision 6130)
+++ SRUAggregator/trunk/src/deb/control/postrm	(revision 6130)
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+action=$1
+version=$2
+
+if [ "$action" != upgrade ];then
+    update-rc.d aggregator remove
+fi
+
+exit 0
Index: SRUAggregator/trunk/src/deb/control/preinst
===================================================================
--- SRUAggregator/trunk/src/deb/control/preinst	(revision 6130)
+++ SRUAggregator/trunk/src/deb/control/preinst	(revision 6130)
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+action=$1
+version=$2
+
+# add group and the user if they do not exit
+if ! getent group aggregator >/dev/null; then
+    addgroup --quiet \
+             --system aggregator
+fi
+
+if ! getent passwd aggregator >/dev/null; then
+    adduser --quiet \
+            --system \
+            --ingroup aggregator \
+            --no-create-home \
+            --home /var/lib/aggregator \
+            --shell /usr/sbin/nologin aggregator
+fi
+
+exit 0
Index: SRUAggregator/trunk/src/deb/control/prerm
===================================================================
--- SRUAggregator/trunk/src/deb/control/prerm	(revision 6130)
+++ SRUAggregator/trunk/src/deb/control/prerm	(revision 6130)
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+action=$1
+version=$2
+
+if [ "$action" != "upgrade" ]; then
+    invoke-rc.d aggregator stop || true
+fi
+
+exit 0
