You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:25:57 UTC

[sling-launchpad-debian] 01/15: SLING-4151 - Sling Launchpad debian/.ubuntu package, contributed by Bruce Edge, thanks!

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-launchpad-debian.git

commit 7f8ceddd4c3ae171da92b28f8ceda8bcc0ebc156
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Nov 13 13:00:09 2014 +0000

    SLING-4151 - Sling Launchpad debian/.ubuntu package, contributed by Bruce Edge, thanks!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1639317 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt                           |  11 +++
 pom.xml                              | 126 +++++++++++++++++++++++++++++++++++
 src/deb/control/control              |   9 +++
 src/deb/control/postinst             |  57 ++++++++++++++++
 src/deb/control/prerm                |  32 +++++++++
 src/root_fs/etc/default/sling.sample |  58 ++++++++++++++++
 src/root_fs/etc/init.d/sling         | 119 +++++++++++++++++++++++++++++++++
 src/root_fs/etc/logrotate.d/sling    |   9 +++
 8 files changed, 421 insertions(+)

diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..80233e4
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,11 @@
+Apache Sling debian/ubuntu packageing
+==========================================
+
+This is a work in progress .deb packaging for Sling.
+
+It provides basic init.d start/stop logrotate & sample sling config.
+
+To run this, and install using dpkg/apt commands, review /etc/default.sling
+config and run
+	"service sling start"
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..d727947
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+    <!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+    -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>22</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>sling-lauchpad</artifactId>
+    <packaging>jar</packaging>
+    <version>8-SNAPSHOT</version>
+
+    <name>Apache Sling Launchpad Debian Package Builder</name>
+    <description>
+        Simple packaged installation for sling launchpad standalone jar
+        as a system daemon.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/launchpad/builder/debian</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/launchpad/builder/debian</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/debian</url>
+    </scm>
+
+    <properties>
+        <!--
+            jdeb plugin version for debian package
+        -->
+        <jdeb.version>1.0.1</jdeb.version>
+        <!--
+            builder artifact identifier
+        -->
+        <builder.artifact>org.apache.sling.launchpad</builder.artifact>
+
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>jdeb</artifactId>
+                <groupId>org.vafer</groupId>
+                <version>${jdeb.version}</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jdeb</goal>
+                        </goals>
+                        <configuration>
+                            <dataSet>
+                                <data>
+                                    <src>../../../launchpad/builder/target/${builder.artifact}-${project.version}-standalone.jar</src>
+                                    <type>file</type>
+                                    <mapper>
+                                        <type>perm</type>
+                                        <prefix>/opt/sling/${project.parent.artifactId}</prefix>
+                                    </mapper>
+                                </data>
+                                <data>
+                                        <src>${project.basedir}/src/root_fs/</src>
+                                        <type>directory</type>
+                                        <excludes>**/.svn/</excludes>
+                                        <mapper>
+                                                <type>perm</type>
+                                                <prefix>/</prefix>
+                                        </mapper>
+                                </data>
+                            </dataSet>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <!-- No javadocs -->
+                    <excludePackageNames>
+                        org.apache.sling
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+
+    <repositories>
+        <repository>
+            <id>OPS4J</id>
+            <name>OPS4J Repository</name>
+            <url>http://repository.ops4j.org/maven2</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+</project>
+
diff --git a/src/deb/control/control b/src/deb/control/control
new file mode 100644
index 0000000..70d8b25
--- /dev/null
+++ b/src/deb/control/control
@@ -0,0 +1,9 @@
+Package: [[artifactId]]
+Version: [[version]]
+Section: misc
+Priority: optional
+Architecture: all
+Maintainer: Bruce Edge <br...@nextissuemedia.com>
+Depends: oracle-java7-installer
+Description: [[description]]
+Distribution: development
diff --git a/src/deb/control/postinst b/src/deb/control/postinst
new file mode 100644
index 0000000..effaaa0
--- /dev/null
+++ b/src/deb/control/postinst
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+echo $0 $*
+[ "$DEBUG" ] && set -x
+
+
+
+SLING_DEFAULTS=/etc/default/sling
+if [ ! -e $SLING_DEFAULTS ] ; then
+	cp $SLING_DEFAULTS.sample $SLING_DEFAULTS
+fi
+. $SLING_DEFAULTS
+
+chmod +x /etc/init.d/sling
+
+# Check for sling user
+if ! getent passwd | grep -q sling ; then
+	useradd --home-dir $SLING_HOME --gid adm $SLING_USER
+fi
+
+# Make data dir
+SLING_DATA=/var/lib/sling
+if [ ! -d $SLING_DATA ] ; then
+	echo Create $SLING_DATA
+	mkdir -p $SLING_DATA
+	chown -R $SLING_USER:adm $SLING_DATA
+fi
+
+# Make log dir
+if [ ! -d $SLING_LOG_DIR ] ; then
+	echo Create $SLING_LOG_DIR
+	mkdir -p $SLING_LOG_DIR
+	chown -R $SLING_USER:adm $SLING_LOG_DIR
+fi
+
+update-rc.d sling defaults
+
+if service sling status; then
+	service sling restart
+fi
+
diff --git a/src/deb/control/prerm b/src/deb/control/prerm
new file mode 100644
index 0000000..82b15e1
--- /dev/null
+++ b/src/deb/control/prerm
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+echo $0 $*
+[ "$DEBUG" ] && set -x
+. /etc/default/sling || true
+
+if [ remove = "$1" ]; then
+	if service sling status; then
+    	service sling stop
+    fi
+    rm -f $SLING_DEFAULTS
+    if [ "$SLING_DATA" ] && [ -d $SLING_DATA ] ; then
+    	echo Not Purging $SLING_DATA
+    	# rm -rf $SLING_DATA
+    fi
+fi
diff --git a/src/root_fs/etc/default/sling.sample b/src/root_fs/etc/default/sling.sample
new file mode 100644
index 0000000..2875e28
--- /dev/null
+++ b/src/root_fs/etc/default/sling.sample
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+# sling defaults
+
+set -a
+SLING_DATA=/var/lib/sling
+set +a
+
+# usage: org.apache.sling.launchpad.app.Main [ start | stop | status ] [ -j adr ] [ -l loglevel ] [ -f logfile ] [ -c slinghome ] [ -i launchpadhome ] [ -a address ] [ -p port ] { -Dn=v } [ -h ]
+#     start         listen for control connection (uses -j)
+#     stop          terminate running Apache Sling (uses -j)
+#     status        check whether Apache Sling is running (uses -j)
+#     -j adr        host and port to use for control connection in the format '[host:]port' (default 127.0.0.1:0)
+#     -l loglevel   the initial loglevel (0..4, FATAL, ERROR, WARN, INFO, DEBUG)
+#     -f logfile    the log file, "-" for stdout (default logs/error.log)
+#     -c slinghome  the sling context directory (default sling)
+#     -i launchpadhome  the launchpad directory (default slinghome)
+#     -a address    the interfact to bind to (use 0.0.0.0 for any)
+#     -p port       the port to listen to (default 8080)
+#     -r path       the root servlet context path for the http service (default is /)
+#     -n            don't install the shutdown hook
+#     -Dn=v         sets property n to value v. Make sure to use this option *after* the jar filename. The JVM also has a -D option which has a different meaning
+#     -h            prints this usage message
+
+JAVA_ARGS="-Xmx384M "
+# Uncomment for debugging:
+#JAVA_DEBUG_ARGS="-agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n"
+
+SLING_DEFAULT_ARGS="-c $SLING_DATA -p 8090 -a 0.0.0.0 $DEBUG_ARGS"
+
+
+# Don't change anything below this line unless you want to break something
+# ========================================================================
+
+set -a
+SLING_HOME=/opt/sling
+SLING_LOG_DIR=/var/log/sling
+LOG_FILE=$SLING_LOG_DIR/${NAME}-start.log
+SLING_USER=sling
+SLING_DATA=/var/lib/sling
+SLING_DEFAULTS=/etc/default/sling
+set +a
diff --git a/src/root_fs/etc/init.d/sling b/src/root_fs/etc/init.d/sling
new file mode 100644
index 0000000..7905374
--- /dev/null
+++ b/src/root_fs/etc/init.d/sling
@@ -0,0 +1,119 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+#
+# Usage
+#
+function usage () {
+   echo "Purpose: Stop/Start sling"
+   echo "Usage  : $0 { stop | start }"
+}
+
+NAME=sling
+
+PID=/var/run/${NAME}.pid
+
+[ "$DEBUG" ] && set -x
+
+. /etc/profile
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
+
+SLING_DEFAULTS=/etc/default/sling
+[ -r $SLING_DEFAULTS ] && . $SLING_DEFAULTS
+
+SLING_JAR=$(find $SLING_HOME -name \*-standalone.jar)
+
+running()
+{
+  local PID=$(cat "$1" 2>/dev/null) || return 1
+  kill -0 "$PID" 2>/dev/null
+}
+
+status() 
+{
+	if running "$PID"
+	then
+	  echo "OK"
+	else
+	  echo "FAILED"
+	fi
+}
+
+#
+# Stop current sling instance
+#
+function stop () {
+	start-stop-daemon --stop --pidfile $PID --chdir $SLING_HOME --startas "./$NAME" --signal TERM
+}
+
+#
+# Start batch job scheduler
+#
+function start () {
+
+  if start-stop-daemon --start \
+	  --chdir "$SLING_HOME" \
+	  --chuid $SLING_USER \
+	  --pidfile "$PID" \
+	  --make-pidfile \
+	  --startas $(which java) \
+	  -- \
+	  $JAVA_ARGS $JAVA_DEBUG_ARGS \
+	  -jar $SLING_JAR $SLING_DEFAULT_ARGS \
+	  >>$LOG_FILE 2>&1 &
+  then
+	sleep 3s
+	status
+  fi
+
+}
+
+if test -z "$1"; then
+   usage
+   exit
+fi
+case $1 in 
+	start)
+		start
+		;;
+	stop)
+		stop
+		;;
+	restart)
+		stop
+		while ps --pid $(cat $PID) >/dev/null ; do
+			sleep 1
+		done
+		start
+		;;
+	status)
+		if [ $(status) == "OK" ] ; then
+			exit 0
+		else
+			exit 1
+		fi
+		;;
+	*)
+		echo "Unknown parameter: $1"
+		usage
+		;;
+	esac
+
+
+# end_of_file
diff --git a/src/root_fs/etc/logrotate.d/sling b/src/root_fs/etc/logrotate.d/sling
new file mode 100644
index 0000000..cf06eb5
--- /dev/null
+++ b/src/root_fs/etc/logrotate.d/sling
@@ -0,0 +1,9 @@
+/var/log/sling/sling-start.log {
+  rotate 5
+  size 4M
+  copytruncate
+  daily
+  compress
+  missingok
+  notifempty
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.