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:26:00 UTC
[sling-launchpad-debian] 04/15: SLING-4517 Update debian packaging
to use crankstart.
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 c887f9fbd8b218742987a7e19521b5b3c8d5ef97
Author: tomekr <to...@unknown>
AuthorDate: Thu Mar 26 07:21:30 2015 +0000
SLING-4517 Update debian packaging to use crankstart.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1669279 13f79535-47bb-0310-9956-ffa450edef68
---
README.md | 33 ++++++
README.txt | 11 --
pom.xml | 150 ++++++++++++++++++++++----
src/deb/control/control | 2 +-
src/deb/control/postinst | 40 +++----
src/deb/control/{prerm => postrm} | 14 +--
src/deb/control/prerm | 18 +++-
src/root_fs/etc/default/sling | 89 +++++++++++++++
src/root_fs/etc/default/sling.sample | 58 ----------
src/root_fs/etc/init.d/sling | 145 +++++++++++++------------
src/root_fs/etc/logrotate.d/sling | 6 +-
src/root_fs/opt/sling/scripts/sling-common.sh | 62 +++++++++++
12 files changed, 431 insertions(+), 197 deletions(-)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1b334ae
--- /dev/null
+++ b/README.md
@@ -0,0 +1,33 @@
+Apache Sling debian/ubuntu packaging
+====================================
+
+This is a work in progress .deb packaging for Sling.
+It provides basic init.d start/stop logrotate & sample sling config. The goal is to provide a generic yet configurable sling package to eliminate the need to build sling for in-house deployments.
+
+To run this, and install using dpkg/apt commands, review /etc/default.sling
+config and run
+ "service sling start"
+
+Components used are:
+* [Sling crankstart](https://github.com/apache/sling/tree/trunk/contrib/crankstart)
+* [Sling-s3](https://github.com/apache/sling/tree/trunk/contrib/sling-s3)
+
+Supported run modes are:
+
+ crank - tar files for nodes and data
+ crank-s3 - tar files for nodes, s3 for data
+ crank-mongo - mongo for nodes and data
+ crank-s3-mongo - mongo for nodes, s3 for data
+
+Each of these are supported by building crank files using the sling-s3 module to aggregate configuration templates into usable configurations.
+
+* SLING_EXEC=/opt/sling - Location for all binaries & scripts.
+* SLING_CFG=/etc/sling - Tree of config file templates from which final.crantstart files are built. Editing any of these config templates triggers a rebuild of the target/crank* files.
+* SLING_DEFAULTS=/etc/default/sling - Defaults file for location & path setup and to override any of the crank settings.
+* SLING_DATA=/var/lib/sling - Local sling data dir.
+* SLING_LOG_DIR=/var/log/sling - Sling log data.
+
+TODO:
+* Support clustered configurations.
+
+
diff --git a/README.txt b/README.txt
deleted file mode 100644
index 80233e4..0000000
--- a/README.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-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
index 21207cf..aae864a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,9 +17,9 @@ 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"
+<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>
@@ -28,7 +28,7 @@ under the License.
<version>22</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
- <artifactId>sling-lauchpad</artifactId>
+ <artifactId>sling-server</artifactId>
<packaging>jar</packaging>
<version>8-SNAPSHOT</version>
<name>Apache Sling Launchpad Debian Package Builder</name>
@@ -45,14 +45,87 @@ under the License.
<!--
jdeb plugin version for debian package
-->
- <jdeb.version>1.0.1</jdeb.version>
+ <jdeb.version>1.4</jdeb.version>
<launchpad.artifact>org.apache.sling.launchpad</launchpad.artifact>
<launchpad.version>8-SNAPSHOT</launchpad.version>
<launchpad.classifier>standalone</launchpad.classifier>
+ <slingInstallDir>/opt/sling</slingInstallDir>
+ <slingConfigDir>/etc/sling</slingConfigDir>
+ <slingS3Dir>${basedir/../../sling-s3}</slingS3Dir>
</properties>
<build>
<plugins>
<plugin>
+ <!-- Copy sling-s3 info local workdir -->
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-sling-s3</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/${slingConfigDir}</outputDirectory>
+ <overwrite>true</overwrite>
+ <resources>
+ <resource>
+ <directory>${slingS3Dir}</directory>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!-- Use exec plugin to call make sling-s3 targets -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.2.1</version>
+ <executions>
+ <execution>
+ <!-- make all in the Maven compile phase -->
+ <id>fix-exec-permissions</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ <workingDirectory>${project.build.directory}/${slingConfigDir}</workingDirectory>
+ <executable>chmod</executable>
+ <arguments>
+ <argument>-R</argument>
+ <argument>775</argument>
+ <argument>scripts</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <!-- make all in the Maven compile phase -->
+ <id>build-config</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ <configuration>
+ > <environmentVariables>
+ <OUTPUT>
+ ${project.build.directory}/contrib
+ </OUTPUT>
+ </environmentVariables>
+ <workingDirectory>${project.build.directory}/${slingConfigDir}</workingDirectory>
+ <executable>make</executable>
+ <arguments>
+ <argument>update-bundles</argument>
+ <argument>install-deps</argument>
+ <argument>all</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>${jdeb.version}</version>
@@ -63,24 +136,72 @@ under the License.
<goal>jdeb</goal>
</goals>
<configuration>
+ <classifier>all</classifier>
<dataSet>
+ <!-- etc/{default,logrotate.d}/sling - conf files -->
<data>
- <src>${project.build.directory}/${launchpad.artifact}-${project.version}-${launchpad.classifier}.jar</src>
- <type>file</type>
+ <src>${project.basedir}/src/root_fs/etc</src>
+ <type>directory</type>
+ <excludes>**/.svn/,**/init.d/</excludes>
+ <conffile>true</conffile>
<mapper>
<type>perm</type>
- <prefix>/opt/sling/${project.parent.artifactId}</prefix>
+ <prefix>/etc</prefix>
</mapper>
</data>
+ <!-- all other root_fs -->
<data>
<src>${project.basedir}/src/root_fs/</src>
<type>directory</type>
- <excludes>**/.svn/</excludes>
+ <excludes>**/.svn/,**/etc/default/,**/etc/logrotate.d/</excludes>
<mapper>
+ <filemode>775</filemode>
<type>perm</type>
<prefix>/</prefix>
</mapper>
</data>
+ <!-- etc/sling/crank-*.d/ conf files -->
+ <data>
+ <src>${project.build.directory}/${slingConfigDir}</src>
+ <type>directory</type>
+ <conffile>true</conffile>
+ <excludes>**/.svn/,**/contrib/,**/scripts/,**/target/</excludes>
+ <mapper>
+ <type>perm</type>
+ <prefix>${slingConfigDir}</prefix>
+ </mapper>
+ </data>
+ <!-- crank target files, etc - non-conf files, as they are generated -->
+ <data>
+ <src>${project.build.directory}/${slingConfigDir}</src>
+ <type>directory</type>
+ <includes>**/target/*</includes>
+ <mapper>
+ <filemode>775</filemode>
+ <type>perm</type>
+ <prefix>${slingConfigDir}</prefix>
+ </mapper>
+ </data>
+ <!-- sling-s3 scripts & other binaries -->
+ <data>
+ <src>${project.build.directory}/${slingConfigDir}</src>
+ <type>directory</type>
+ <includes>**/contrib/*,**/scripts/*</includes>
+ <mapper>
+ <filemode>775</filemode>
+ <type>perm</type>
+ <prefix>${slingInstallDir}</prefix>
+ </mapper>
+ </data>
+ <!-- dependencies -->
+ <data>
+ <src>${project.build.directory}/contrib</src>
+ <type>directory</type>
+ <mapper>
+ <type>perm</type>
+ <prefix>${slingInstallDir}/contrib</prefix>
+ </mapper>
+ </data>
</dataSet>
</configuration>
</execution>
@@ -98,7 +219,6 @@ under the License.
<phase>process-resources</phase>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
- <includeArtifactIds>${launchpad.artifact}</includeArtifactIds>
<excludeTransitive>true</excludeTransitive>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
@@ -108,14 +228,6 @@ under the License.
</plugin>
</plugins>
</build>
- <dependencies>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>${launchpad.artifact}</artifactId>
- <version>${launchpad.version}</version>
- <classifier>${launchpad.classifier}</classifier>
- </dependency>
- </dependencies>
<reporting>
<plugins>
<plugin>
@@ -143,4 +255,4 @@ under the License.
</snapshots>
</repository>
</repositories>
-</project>
\ No newline at end of file
+</project>
diff --git a/src/deb/control/control b/src/deb/control/control
index 70d8b25..058b5ed 100644
--- a/src/deb/control/control
+++ b/src/deb/control/control
@@ -4,6 +4,6 @@ Section: misc
Priority: optional
Architecture: all
Maintainer: Bruce Edge <br...@nextissuemedia.com>
-Depends: oracle-java7-installer
+Depends: oracle-java7-installer, make
Description: [[description]]
Distribution: development
diff --git a/src/deb/control/postinst b/src/deb/control/postinst
index effaaa0..5d74d99 100644
--- a/src/deb/control/postinst
+++ b/src/deb/control/postinst
@@ -19,39 +19,31 @@
echo $0 $*
[ "$DEBUG" ] && set -x
-
-
-SLING_DEFAULTS=/etc/default/sling
-if [ ! -e $SLING_DEFAULTS ] ; then
- cp $SLING_DEFAULTS.sample $SLING_DEFAULTS
+SLING_COMMON=/opt/sling/scripts/sling-common.sh
+if [ -r $SLING_COMMON ] ; then
+ . $SLING_COMMON
+else
+ log_failure_msg "Missing $SLING_COMMON file, cannot read env settings."
+ exit -1
fi
-. $SLING_DEFAULTS
-chmod +x /etc/init.d/sling
+SLING_USER=${SLING_USER:-sling}
+SLING_GROUP=${SLING_GROUP:-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
+# Check for sling user and group
+if ! getent group | grep -q $SLING_USER ; then
+ groupadd --system $SLING_GROUP
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
+if ! getent passwd | grep -q $SLING_GROUP ; then
+ useradd --home-dir $SLING_EXEC --gid $SLING_GROUP $SLING_USER
fi
+check_sling_permissions force
+
update-rc.d sling defaults
+# Only restart if already running
if service sling status; then
service sling restart
fi
-
diff --git a/src/deb/control/prerm b/src/deb/control/postrm
similarity index 78%
copy from src/deb/control/prerm
copy to src/deb/control/postrm
index 82b15e1..c1d5548 100644
--- a/src/deb/control/prerm
+++ b/src/deb/control/postrm
@@ -18,15 +18,11 @@
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
+ update-rc.d -f sling remove
+
+ # Run cleanup script created by prerm
+ CLEANUP=/tmp/sling-cleanup.sh
+ [ -e ${CLEANUP} ] && sh ${CLEANUP} $@
fi
diff --git a/src/deb/control/prerm b/src/deb/control/prerm
index 82b15e1..e6be54d 100644
--- a/src/deb/control/prerm
+++ b/src/deb/control/prerm
@@ -25,8 +25,18 @@ if [ remove = "$1" ]; 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
+
+ # Generate a cleanup script to purge all generated files
+ # Note: validate all deletions!
+ cat >/tmp/sling-cleanup.sh <<-EOT
+ #!/bin/bash
+ echo Purging sling generated files
+ [ "$DEBUG" ] && set -x
+ [ "${SLING_EXEC}" ] && [ -d ${SLING_EXEC} ] && rm -rf ${SLING_EXEC}
+ [ -d ${SLING_CFG}/target ] && rm -rf ${SLING_CFG}/target
+ [ "${SLING_LOG_DIR}" ] && [ -d ${SLING_LOG_DIR} ] && rm -rf ${SLING_LOG_DIR}
+ # Purge deletes data as well
+ rm -f $0
+EOT
+
fi
diff --git a/src/root_fs/etc/default/sling b/src/root_fs/etc/default/sling
new file mode 100644
index 0000000..b8de262
--- /dev/null
+++ b/src/root_fs/etc/default/sling
@@ -0,0 +1,89 @@
+#!/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.
+set -a
+
+# Identification
+SLING_USER=sling
+SLING_GROUP=sling
+
+# sling defaults
+# Note, init script uses :
+# $JAVA_ARGS $JAVA_DEBUG_ARGS -jar $SLING_JAR $SLING_DEFAULT_ARGS
+
+#
+# All configuration items are setup in /etc/sling/*
+# The files are processed aggregated using /etc/sling/Makefile to generate
+# the configuration specific start modes.
+# The final mode of execution is determined by the RUNMODE setting below.
+#
+
+##########################################################################
+#
+# SET RUNMODE HERE
+#
+# This must be set before sling will run as one needs to make the choice
+# of storage configurations before running for the first time
+#
+# Runtime startup mode options:
+# crank - tar files for nodes and data
+# crank-s3 - tar files for nodes, s3 for data
+# crank-mongo - mongo for nodes and data
+# crank-s3-mongo - mongo for nodes, s3 for data
+#
+# key:
+# node store - for node properties and tree structure
+# data store - for binaries
+#
+RUNMODE=""
+#
+##########################################################################
+
+#
+# Base locations - override default settings in crankfiles.
+#
+SLING_EXEC=/opt/sling
+SLING_CFG=/etc/sling
+SLING_DEFAULTS=/etc/default/sling
+SLING_DATA=/var/lib/sling
+SLING_LOG_DIR=/var/log/sling
+
+START_LOG_FILE=$SLING_LOG_DIR/startup.log
+
+# Define where to load dependencies from
+M2REPO="${SLING_EXEC}/contrib"
+SLING_SCRIPTS=${SLING_EXEC}/scripts
+CRANKSTART_ENV=${SLING_SCRIPTS}/crankstart.sh
+
+# Bump RAM allowance
+JAVA_ARGS="-Xmx384M "
+
+# Uncomment for debugging:
+JAVA_ARGS+=" -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n"
+
+#
+# crank file overrides
+#
+JAVA_ARGS+=" -Dport=8090"
+JAVA_ARGS+=" -Dsling.home=${SLING_DATA}"
+JAVA_ARGS+=" -Dlog.file=/var/log/sling/sling.log"
+
+# Allow gogo shell to run in noninteractive env:
+# From: http://apache-felix.18485.x6.nabble.com/Gogo-shell-on-standard-input-output-streams-td4845969.html#a4845970
+JAVA_ARGS+=" -Dgosh.args=--nointeractive"
+
+set +a
diff --git a/src/root_fs/etc/default/sling.sample b/src/root_fs/etc/default/sling.sample
deleted file mode 100644
index 2875e28..0000000
--- a/src/root_fs/etc/default/sling.sample
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/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
index 7905374..77f0c22 100644
--- a/src/root_fs/etc/init.d/sling
+++ b/src/root_fs/etc/init.d/sling
@@ -16,79 +16,93 @@
# 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
+### BEGIN INIT INFO
+# Provides: sling
+# Required-Start: $remote_fs $syslog $named
+# Required-Stop: $remote_fs $syslog $named
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start sling at boot time
+# Description: Enable service provided by sling.
+### END INIT INFO
. /etc/profile
-
+export FANCYTTY=true
+. /lib/lsb/init-functions
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
+SLING_COMMON=/opt/sling/scripts/sling-common.sh
+if [ -r $SLING_COMMON ] ; then
+ . $SLING_COMMON
+else
+ log_failure_msg "Missing $SLING_COMMON file, cannot read env settings."
+ exit -1
+fi
-SLING_DEFAULTS=/etc/default/sling
-[ -r $SLING_DEFAULTS ] && . $SLING_DEFAULTS
-
-SLING_JAR=$(find $SLING_HOME -name \*-standalone.jar)
+PID=/var/run/sling.pid
+DAEMON=$(which java)
-running()
-{
- local PID=$(cat "$1" 2>/dev/null) || return 1
- kill -0 "$PID" 2>/dev/null
+function usage () {
+ log_warning_msg "Purpose: Stop/Start sling"
+ log_warning_msg "Usage : $0 { stop | start | restart }"
}
-status()
-{
- if running "$PID"
- then
- echo "OK"
- else
- echo "FAILED"
- fi
+function rebuild_config () {
+ log_progress_msg "Rebuild configuration"
+ cd ${SLING_CFG}
+ make -e target/${RUNMODE}.txt
}
-#
-# Stop current sling instance
-#
function stop () {
- start-stop-daemon --stop --pidfile $PID --chdir $SLING_HOME --startas "./$NAME" --signal TERM
+ killproc -p $PID $DAEMON 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 [ ! "${RUNMODE}" ] ; then
+ log_warning_msg "RUNMODE is not set in ${SLING_DEFAULTS}"
+ fi
+
+ check_sling_permissions
+
+ # Get MVN_OPTS from crankstart env file.
+ [ -r $CRANKSTART_ENV ] && . $CRANKSTART_ENV
+ CRANKSTART_JAR=${M2REPO}/crankstart.jar
+
+ # Update crankstart file if needed
+ log_daemon_msg "Starting sling serices"
+ rebuild_config
+
+ log_progress_msg "Start sling daemon"
+ if start-stop-daemon --start \
+ --chdir "$SLING_EXEC" \
+ --chuid $SLING_USER \
+ --pidfile "$PID" \
+ --make-pidfile \
+ --background \
+ --verbose \
+ --no-close \
+ --exec $(which java) \
+ --start \
+ -- \
+ ${JAVA_ARGS} \
+ ${MVN_OPTS} \
+ -jar ${CRANKSTART_JAR} \
+ ${SLING_CFG}/target/${RUNMODE}.txt \
+ >$START_LOG_FILE 2>&1
+ then
+ sleep 3
+ status_of_proc -p $PID $DAEMON
+ fi
+ log_end_msg $?
}
if test -z "$1"; then
- usage
- exit
+ usage
+ exit
fi
-case $1 in
+
+case $1 in
start)
start
;;
@@ -96,24 +110,19 @@ case $1 in
stop
;;
restart)
- stop
- while ps --pid $(cat $PID) >/dev/null ; do
- sleep 1
- done
+ if [ -f $PID ] ; then
+ stop
+ while pidofproc -p $PID $DAEMON > /dev/null ; do
+ sleep 1
+ done
+ fi
start
- ;;
+ ;;
status)
- if [ $(status) == "OK" ] ; then
- exit 0
- else
- exit 1
- fi
+ status_of_proc -p $PID $DAEMON
;;
*)
echo "Unknown parameter: $1"
usage
;;
- esac
-
-
-# end_of_file
+esac
diff --git a/src/root_fs/etc/logrotate.d/sling b/src/root_fs/etc/logrotate.d/sling
index cf06eb5..09bbb5e 100644
--- a/src/root_fs/etc/logrotate.d/sling
+++ b/src/root_fs/etc/logrotate.d/sling
@@ -1,6 +1,6 @@
-/var/log/sling/sling-start.log {
- rotate 5
- size 4M
+/var/log/sling/startup.log {
+ rotate
+ size 10M
copytruncate
daily
compress
diff --git a/src/root_fs/opt/sling/scripts/sling-common.sh b/src/root_fs/opt/sling/scripts/sling-common.sh
new file mode 100644
index 0000000..ff4ccb9
--- /dev/null
+++ b/src/root_fs/opt/sling/scripts/sling-common.sh
@@ -0,0 +1,62 @@
+#
+#Copyright (c) 2002-08 Chris Lawrence
+#All rights reserved.
+#
+#Redistribution and use in source and binary forms, with or without
+#modification, are permitted provided that the following conditions
+#are met:
+#1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#3. Neither the name of the author nor the names of other contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+#IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+#BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+#WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+#EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+SLING_DEFAULTS=/etc/default/sling
+[ "$DEBUG" ] && set -x
+if [ -r $SLING_DEFAULTS ] ; then
+ . $SLING_DEFAULTS
+else
+ echo "Missing $SLING_DEFAULTS file, cannot read env settings." 1>&2
+ exit -1
+fi
+
+# Make sure premissions & directoreis are OK.
+# $1 = force sets all permissions
+function check_sling_permissions() {
+
+ chmod +x /etc/init.d/sling
+
+ for d in SLING_DATA SLING_EXEC SLING_CFG SLING_LOG_DIR ; do
+ eval n=\$$d
+ if [ ! "${n}" ] ; then
+ log_failure_msg "Missing $d"
+ exit -1
+ fi
+ if [ ! -d ${n} ] ; then
+ echo "Fix type of ${n}"
+ rm -rf ${n}
+ install --directory --owner=${SLING_USER} --group=${SLING_GROUP} ${n}
+ else
+ if [ "$(stat -c '%U' ${n})" != "${SLING_USER}" ] || [ "$1" = "force" ]; then
+ [ "$1" == "force" ] || echo "Update ownership of ${n}"
+ chown -R ${SLING_USER}:${SLING_GROUP} ${n}
+ fi
+ fi
+ done
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.