diff --git a/.gitignore b/.gitignore
index 5bfa2ff9b5..a062922c58 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,6 @@ node_modules
# jrebel
rebel.xml
*.pyc
+
+# vagrant
+.vagrant
diff --git a/packaging/pom.xml b/packaging/pom.xml
new file mode 100644
index 0000000000..8b63c69e83
--- /dev/null
+++ b/packaging/pom.xml
@@ -0,0 +1,47 @@
+
+
+
+
+ 4.0.0
+
+
+ sonia.scm
+ scm
+ 2.0.0-SNAPSHOT
+
+
+ sonia.scm.packaging
+ packaging
+ pom
+ 2.0.0-SNAPSHOT
+ packaging
+
+
+ rpm
+
+
+
diff --git a/packaging/rpm/Vagrantfile b/packaging/rpm/Vagrantfile
new file mode 100644
index 0000000000..aa389c5307
--- /dev/null
+++ b/packaging/rpm/Vagrantfile
@@ -0,0 +1,16 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure("2") do |config|
+
+ config.vm.box = "bento/centos-8"
+ config.vm.network "forwarded_port", guest: 8080, host: 8080
+
+ config.vm.provider "virtualbox" do |vb|
+ vb.memory = "1024"
+ end
+
+ config.vm.provision "shell", inline: <<-SHELL
+ yum install -y /vagrant/target/scm-server-*.rpm
+ SHELL
+end
diff --git a/packaging/rpm/pom.xml b/packaging/rpm/pom.xml
new file mode 100644
index 0000000000..21d63cf667
--- /dev/null
+++ b/packaging/rpm/pom.xml
@@ -0,0 +1,334 @@
+
+
+
+
+ 4.0.0
+
+
+ sonia.scm.packaging
+ packaging
+ 2.0.0-SNAPSHOT
+
+
+ sonia.scm.packaging
+ rpm
+ rpm
+ 2.0.0-SNAPSHOT
+ Packaging for RedHat/Centos/Fedora
+ rpm
+
+
+
+
+ sonia.scm
+ scm-server
+ 2.0.0-SNAPSHOT
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.1.2
+
+
+ copy-server
+ process-resources
+
+ copy-dependencies
+
+
+ runtime
+ ${project.build.directory}/rpm/lib
+ false
+ false
+ true
+
+
+
+ copy-jsvc
+ process-resources
+
+ unpack
+
+
+
+
+ commons-daemon
+ commons-daemon-native
+ 1.1.0
+ tar.gz
+
+
+
+
+
+ **/jsvc-linux-*
+ ${project.build.directory}/rpm/libexec
+ false
+ true
+
+
+
+ copy-webapp
+ process-resources
+
+ copy
+
+
+
+
+ sonia.scm
+ scm-webapp
+ ${project.version}
+ war
+ ${project.build.directory}/rpm/var/webapp
+ scm-webapp.war
+
+
+
+
+
+
+
+
+ de.dentrassi.maven
+ rpm
+ 1.5.0
+ true
+
+
+
+ rpm
+
+
+
+
+ false
+ scm-server
+ Development/Tools
+ MIT
+
+
+ java-11-openjdk-headless
+
+
+
+ mercurial
+
+
+
+ src/main/scripts/before-installation.sh
+
+
+ src/main/scripts/after-installation.sh
+
+
+
+
+
+
+ default
+
+
+
+ file
+ /opt/scm-server/lib
+
+ root
+ scm
+ 0644
+
+
+
+ file
+ /opt/scm-server/libexec
+
+ root
+ scm
+ 0755
+
+
+
+
+
+
+
+
+ /opt/scm-server/bin/scm-server
+ src/main/fs/opt/scm-server/bin/scm-server
+ root
+ scm
+ 0750
+
+
+
+ /etc/default/scm-server
+ src/main/fs/etc/default/scm-server
+ root
+ scm
+ 0640
+ true
+
+
+
+ /etc/scm/logging.xml
+ src/main/fs/etc/scm/logging.xml
+ root
+ scm
+ 0640
+ true
+
+
+
+ /etc/scm/server-config.xml
+ src/main/fs/etc/scm/server-config.xml
+ root
+ scm
+ 0640
+ true
+
+
+
+ /etc/systemd/system/scm-server.service
+ src/main/fs/etc/systemd/system/scm-server.service
+ root
+ root
+ 0644
+
+
+
+ /opt/scm-server/lib
+
+ ${project.build.directory}/rpm/lib
+
+ default
+
+
+
+ /opt/scm-server/libexec
+
+ ${project.build.directory}/rpm/libexec
+
+ default
+
+
+
+ /opt/scm-server/var/webapp/docroot/index.html
+ src/main/fs/opt/scm-server/var/webapp/docroot/index.html
+ root
+ scm
+ 0644
+
+
+
+ /opt/scm-server/var/webapp/scm-webapp.war
+ ${project.build.directory}/rpm/var/webapp/scm-webapp.war
+ root
+ scm
+ 0644
+
+
+
+ /var/log/scm
+ true
+ scm
+ scm
+ 0750
+
+
+
+ /run/scm
+ true
+ scm
+ scm
+ 0750
+
+
+
+ /opt/scm-server/var/log
+ /var/log/scm
+ scm
+ scm
+
+
+
+ /opt/scm-server/conf
+ /etc/scm
+ root
+ root
+
+
+
+ /var/lib/scm
+ true
+ scm
+ scm
+ 0750
+
+
+
+ /var/cache/scm
+ true
+ scm
+ scm
+ 0750
+
+
+
+ /var/cache/scm/work
+ true
+ scm
+ scm
+ 0750
+
+
+
+ /opt/scm-server/work
+ /var/cache/scm/work
+ root
+ root
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+
diff --git a/packaging/rpm/src/main/fs/etc/default/scm-server b/packaging/rpm/src/main/fs/etc/default/scm-server
new file mode 100644
index 0000000000..6ea672b267
--- /dev/null
+++ b/packaging/rpm/src/main/fs/etc/default/scm-server
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# MIT License
+#
+# Copyright (c) 2020-present Cloudogu GmbH and Contributors
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+# scm-server host interface
+HOST=0.0.0.0
+
+# scm-server port
+PORT=8080
+
+# change user
+USER=scm
+
+# home of scm-manager
+export SCM_HOME=/var/lib/scm
+
+# force jvm path
+JAVA_HOME="/usr/lib/jvm/jre-11"
+
+# path to pid
+PIDFILE=/var/run/scm/scm.pid
+
+# path to log directory
+LOGDIR=/var/log/scm
+
+# increase memory
+# EXTRA_JVM_ARGUMENTS="$EXTRA_JVM_ARGUMENTS -Xms1g -Xmx1g"
+
+# pass extra jvm arguments
+EXTRA_JVM_ARGUMENTS="$EXTRA_JVM_ARGUMENTS -Djetty.host=$HOST -Djetty.port=$PORT"
diff --git a/packaging/rpm/src/main/fs/etc/scm/logging.xml b/packaging/rpm/src/main/fs/etc/scm/logging.xml
new file mode 100644
index 0000000000..b3f4014265
--- /dev/null
+++ b/packaging/rpm/src/main/fs/etc/scm/logging.xml
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+
+
+
+ /var/log/scm/scm-manager.log
+
+
+ /var/log/scm/scm-manager-%i.log
+ 1
+ 10
+
+
+
+ 10MB
+
+
+ true
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-10X{transaction_id}] %-5level %logger - %msg%n
+
+
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%-10X{transaction_id}] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packaging/rpm/src/main/fs/etc/scm/server-config.xml b/packaging/rpm/src/main/fs/etc/scm/server-config.xml
new file mode 100644
index 0000000000..b7a5a7efef
--- /dev/null
+++ b/packaging/rpm/src/main/fs/etc/scm/server-config.xml
@@ -0,0 +1,193 @@
+
+
+
+
+
+
+
+ 16384
+ 16384
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ /scm
+
+ /var/webapp/scm-webapp.war
+
+
+ org.eclipse.jetty.servlet.Default.dirAllowed
+ false
+
+ /var/cache/scm/work/webapp
+
+
+
+ /
+
+
+
+
+ -
+ /var/webapp/docroot
+
+
+
+
+ /var/cache/scm/work/work/docroot
+
+
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packaging/rpm/src/main/fs/etc/systemd/system/scm-server.service b/packaging/rpm/src/main/fs/etc/systemd/system/scm-server.service
new file mode 100644
index 0000000000..58ef9de558
--- /dev/null
+++ b/packaging/rpm/src/main/fs/etc/systemd/system/scm-server.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=SCM-Manager Server
+After=syslog.target network.target
+
+[Service]
+Type=forking
+
+User=scm
+Group=scm
+
+WorkingDirectory=/opt/scm-server
+ExecStart=/opt/scm-server/bin/scm-server start
+ExecStop=/opt/scm-server/bin/scm-server stop
+
+[Install]
+WantedBy=multi-user.target
diff --git a/packaging/rpm/src/main/fs/opt/scm-server/bin/scm-server b/packaging/rpm/src/main/fs/opt/scm-server/bin/scm-server
new file mode 100644
index 0000000000..9ccaafb188
--- /dev/null
+++ b/packaging/rpm/src/main/fs/opt/scm-server/bin/scm-server
@@ -0,0 +1,192 @@
+#!/bin/bash
+# ----------------------------------------------------------------------------
+# Copyright 2001-2006 The Apache Software Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ----------------------------------------------------------------------------
+
+# Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+# reserved.
+
+# user used to run the daemon (defaults to current user)
+USER="scm"
+
+# extra jvm arguments
+EXTRA_JVM_ARGUMENTS="-Djava.awt.headless=true -Dlogback.configurationFile=logging.xml"
+
+BASEDIR="/opt/scm-server"
+
+# set pid path for jsvc
+PIDFILE="/var/run/scm-server.pid"
+
+# set log dir for jsvc
+LOGDIR="/var/log/scm"
+
+# load settings from defaults directory
+[ -r /etc/default/scm-server ] && . /etc/default/scm-server
+
+OS=`uname | tr '[:upper:]' '[:lower:]'`
+ARCH=`uname -m`
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+case "$OS" in
+ sunos*) OS="solaris"
+ ARCH=`uname -p`
+ ;;
+ cygwin*) cygwin=true ;;
+ darwin*) darwin=true
+ if [ -z "$JAVA_VERSION" ] ; then
+ JAVA_VERSION="CurrentJDK"
+ else
+ echo "Using Java version: $JAVA_VERSION"
+ fi
+ if [ -z "$JAVA_HOME" ] ; then
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# If a specific java binary isn't specified search for the standard 'java' binary
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD=`which java`
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly."
+ echo " We cannot execute $JAVACMD"
+ exit 1
+fi
+
+if [ -z "$REPO" ]
+then
+ REPO="$BASEDIR"/lib
+fi
+
+CLASSPATH=$CLASSPATH_PREFIX:"$BASEDIR"/conf:"$REPO"/scm-server-2.0.0-SNAPSHOT.jar:"$REPO"/commons-daemon-1.2.2.jar:"$REPO"/jetty-server-9.4.27.v20200227.jar:"$REPO"/javax.servlet-api-3.1.0.jar:"$REPO"/jetty-http-9.4.27.v20200227.jar:"$REPO"/jetty-io-9.4.27.v20200227.jar:"$REPO"/jetty-webapp-9.4.27.v20200227.jar:"$REPO"/jetty-xml-9.4.27.v20200227.jar:"$REPO"/jetty-servlet-9.4.27.v20200227.jar:"$REPO"/jetty-security-9.4.27.v20200227.jar:"$REPO"/jetty-jmx-9.4.27.v20200227.jar:"$REPO"/jetty-util-9.4.27.v20200227.jar
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
+ [ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
+ [ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
+fi
+
+jsvc=false;
+stop="";
+
+if [ "$1" == "start" ]
+then
+ jsvc=true;
+else
+ if [ "$1" == "stop" ]
+ then
+ jsvc=true;
+ stop='-stop';
+ fi
+fi
+
+USER_ARGUMENT=""
+
+if [ "x$USER" != "x" ]
+then
+ USER_ARGUMENT="-user $USER"
+fi
+
+DARWIN_USE_ARCH="false"
+
+if $jsvc; then
+
+ JSVCCMD=""
+ if [ "$OS" == "darwin" ]; then
+ if [ "$DARWIN_USE_ARCH" == "true" ]; then
+ JSVCCMD="/usr/bin/arch -arch $ARCH $BASEDIR/libexec/jsvc-$OS"
+ else
+ JSVCCMD="exec $BASEDIR/libexec/jsvc-$OS"
+ fi
+ else
+ JSVCCMD="exec $BASEDIR/libexec/jsvc-$OS-$ARCH"
+ fi
+
+ # try to extract JAVA_HOME from JAVACMD
+ if [ -z "$JAVA_HOME" ] ; then
+ PRG="$JAVACMD"
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+ DIR="$(dirname "$PRG")"
+ DIR="$(dirname "$DIR")"
+ if [ -d "$DIR" ] ; then
+ JAVA_HOME="$DIR"
+ fi
+ fi
+
+ # TODO JVM Arguments
+
+ $JSVCCMD -cp "$CLASSPATH" $JAVA_OPTS \
+ $EXTRA_JVM_ARGUMENTS $USER_ARGUMENT \
+ -outfile "$LOGDIR/scm-server.out" \
+ -errfile "$LOGDIR/scm-server.err" \
+ -pidfile "$PIDFILE" \
+ -jvm server \
+ -home "$JAVA_HOME" \
+ -Dapp.name="scm-server" \
+ -Dapp.pid="$$" \
+ -Dapp.repo="$REPO" \
+ -Dbasedir="$BASEDIR" \
+ $stop sonia.scm.server.ScmServerDaemon \
+ "$@"
+
+else
+
+ exec "$JAVACMD" $JAVA_OPTS \
+ $EXTRA_JVM_ARGUMENTS \
+ -classpath "$CLASSPATH" \
+ -Dapp.name="scm-server" \
+ -Dapp.pid="$$" \
+ -Dapp.repo="$REPO" \
+ -Dbasedir="$BASEDIR" \
+ sonia.scm.server.ScmServerDaemon \
+ "$@"
+
+fi
diff --git a/packaging/rpm/src/main/fs/opt/scm-server/var/webapp/docroot/index.html b/packaging/rpm/src/main/fs/opt/scm-server/var/webapp/docroot/index.html
new file mode 100644
index 0000000000..a3bff3f8b3
--- /dev/null
+++ b/packaging/rpm/src/main/fs/opt/scm-server/var/webapp/docroot/index.html
@@ -0,0 +1,35 @@
+
+
+
+
+ SCM-Server
+
+
+
+
+
+
diff --git a/packaging/rpm/src/main/scripts/after-installation.sh b/packaging/rpm/src/main/scripts/after-installation.sh
new file mode 100644
index 0000000000..474eae5df9
--- /dev/null
+++ b/packaging/rpm/src/main/scripts/after-installation.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# MIT License
+#
+# Copyright (c) 2020-present Cloudogu GmbH and Contributors
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+# clear workdir after upgrade
+# https://bitbucket.org/sdorra/scm-manager/issues/923/scmmanager-installed-from-debian-package
+
+WORKDIR="/var/cache/scm/work/webapp"
+if [ -d "${WORKDIR}" ]; then
+ rm -rf "${WORKDIR}"
+fi
+
+# reload systemd and make service available
+systemctl daemon-reload
+
+# enable and start the service
+sudo systemctl enable scm-server
+sudo systemctl start scm-server
diff --git a/packaging/rpm/src/main/scripts/before-installation.sh b/packaging/rpm/src/main/scripts/before-installation.sh
new file mode 100644
index 0000000000..55ce22c06b
--- /dev/null
+++ b/packaging/rpm/src/main/scripts/before-installation.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# MIT License
+#
+# Copyright (c) 2020-present Cloudogu GmbH and Contributors
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+getent group scm >/dev/null || groupadd -r scm
+getent passwd scm >/dev/null || \
+ useradd -r -g scm -M \
+ -s /sbin/nologin -d /var/lib/scm \
+ -c "user for the scm-server process" scm
+exit 0
diff --git a/pom.xml b/pom.xml
index cbbb7656f6..cd4b492c9c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,6 +99,7 @@
scm-dao-xml
scm-webapp
scm-server
+ packaging
scm-it
@@ -658,6 +659,7 @@
.editorconfig
.git/**
+ .*/**
.mvn/wrapper/**
docs/**
node_modules/**