--- /dev/null
+<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.argeo.commons.osgi</groupId>
+ <version>0.3.4-SNAPSHOT</version>
+ <artifactId>dist</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>osgi-boot</artifactId>
+ <packaging>pom</packaging>
+ <name>Commons OSGi Boot Distribution</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <includeTypes>jar</includeTypes>
+ <stripVersion>true</stripVersion>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rpm-maven-plugin</artifactId>
+ <version>2.1-alpha-1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <version>${project.version}</version>
+ <release>r${buildNumber}.argeo</release>
+ <copyright>2011 Argeo</copyright>
+ <distribution>argeo</distribution>
+ <packager>mbaudier@argeo.org</packager>
+ <group>Applications/System</group>
+ <prefix>/usr</prefix>
+ </configuration>
+ <executions>
+ <execution>
+ <id>rpm-sdk</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached-rpm</goal>
+ </goals>
+ <configuration>
+ <mappings>
+ <mapping>
+ <directory>/etc/osgiboot</directory>
+ <username>root</username>
+ <groupname>root</groupname>
+ <filemode>644</filemode>
+ <configuration>true</configuration>
+ <sources>
+ <source>
+ <location>src/main/rpm/etc/osgiboot</location>
+ <includes>
+ <include>*</include>
+ </includes>
+ </source>
+ </sources>
+ </mapping>
+ <mapping>
+ <directory>/usr/sbin</directory>
+ <username>root</username>
+ <groupname>root</groupname>
+ <filemode>755</filemode>
+ <sources>
+ <source>
+ <location>src/main/rpm/usr/sbin</location>
+ <includes>
+ <include>*</include>
+ </includes>
+ </source>
+ </sources>
+ </mapping>
+ <mapping>
+ <directory>/usr/share/osgiboot/lib</directory>
+ <username>root</username>
+ <groupname>root</groupname>
+ <filemode>644</filemode>
+ <directoryIncluded>false</directoryIncluded>
+ <sources>
+ <source>
+ <location>${project.build.directory}/lib</location>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </source>
+ </sources>
+ </mapping>
+ </mappings>
+ <!--
+ <postinstallScriptlet>
+ <scriptFile>src/main/scripts/postinstall</scriptFile>
+ </postinstallScriptlet>
+ <preremoveScriptlet>
+ <scriptFile>src/main/scripts/preremove</scriptFile>
+ </preremoveScriptlet>
+ <postremoveScriptlet>
+ <scriptFile>src/main/scripts/postremove</scriptFile>
+ </postremoveScriptlet>
+ -->
+ <requires>
+ <require>java</require>
+ <!-- For the start/stop scripts
+ <require>telnet</require>
+ <require>expect</require>-->
+ </requires>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.argeo.commons.osgi</groupId>
+ <artifactId>org.argeo.osgi.boot</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+#JAVA_OPTS=-Xmx256m
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+
+JVM=java
+. /etc/osgiboot/osgi-service-settings.sh
+
+APP=$1
+
+CONF_DIR=/etc/$APP
+if [ -f $CONF_DIR/settings.sh ];then
+ . $CONF_DIR/settings.sh
+fi
+
+LIB_DIR=/usr/share/$APP/lib
+
+# read/write
+EXEC_DIR=/var/lib/$APP
+DATA_DIR=$EXEC_DIR/data
+CONF_RW=$EXEC_DIR/conf
+LOG_FILE=/var/log/$APP.log
+
+RUN_DIR=/var/run
+PID_FILE=$RUN_DIR/$APP.pid
+SHUTDOWN_FILE=$RUN_DIR/$APP.shutdown
+
+OSGI_INSTALL_AREA=/usr/share/osgiboot/lib
+OSGI_FRAMEWORK=$OSGI_INSTALL_AREA/org.eclipse.osgi.jar
+
+RETVAL=0
+
+start() {
+ cp $CONF_DIR/config.ini $CONF_RW/config.ini
+ touch $SHUTDOWN_FILE
+ cd $EXEC_DIR && $JVM \
+ -Dosgi.bundles="org.argeo.osgi.boot.jar@start" \
+ -Dargeo.osgi.bundles="$CONF_DIR/modules;in=*,$LIB_DIR;in=*" \
+ -Dlog4j.configuration="file:$CONF_DIR/log4j.properties" \
+ $JAVA_OPTS -jar $OSGI_FRAMEWORK \
+ -configuration "$CONF_RW" \
+ -data "$DATA_DIR" \
+ &> $LOG_FILE &
+ PID=$!
+ echo $PID > $PID_FILE
+ echo Started $APP with pid $PID
+ return $RETVAL
+}
+
+stop() {
+ PID=`cat $PID_FILE`
+ rm -f $SHUTDOWN_FILE
+ # TODO wait for process to finish until timeout, then kill
+ echo Stopped $APP with pid $PID
+ return $RETVAL
+}
+
+# See how we were called.
+case "$2" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|reload)
+ stop
+ sleep 10
+ start
+ RETVAL=$?
+ ;;
+ condrestart)
+ echo Not implemented
+ exit 1
+ ;;
+ status)
+ echo Not implemented
+ exit 1
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart}"
+ exit 1
+esac
--- /dev/null
+#rm -f /usr/share/osgiboot/lib/org.eclipse.osgi.jar
+#ln -vs `ls /usr/share/osgiboot/lib/org.eclipse.osgi-*.jar` /usr/share/osgiboot/lib/org.eclipse.osgi.jar
+
+#rm -f /usr/share/osgiboot/lib/org.argeo.osgi.boot.jar
+#ln -vs `ls /usr/share/osgiboot/lib/org.argeo.osgi.boot-*.jar` /usr/share/osgiboot/lib/org.argeo.osgi.boot.jar
--- /dev/null
+if [ $1 = "0" ];then
+
+fi
--- /dev/null
+if [ $1 = "0" ];then
+
+fi
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<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.argeo.commons</groupId>
+ <version>0.3.4-SNAPSHOT</version>
+ <artifactId>osgi</artifactId>
+ <relativePath>..</relativePath>
+ </parent>
+ <groupId>org.argeo.commons.osgi</groupId>
+ <artifactId>dist</artifactId>
+ <name>Commons OSGi Distributions</name>
+ <packaging>pom</packaging>
+ <modules>
+ <module>osgi-boot</module>
+ </modules>
+</project>
\ No newline at end of file
<module>runtime</module>
<module>plugins</module>
<module>dep</module>
+ <module>dist</module>
</modules>
</project>
\ No newline at end of file
*/
public class Activator implements BundleActivator {
- public void start(BundleContext bundleContext) throws Exception {
+ public void start(final BundleContext bundleContext) throws Exception {
+ // admin thread
+ Thread adminThread = new AdminThread(bundleContext);
+ adminThread.start();
+
+ // bootstrap
OsgiBoot osgiBoot = new OsgiBoot(bundleContext);
osgiBoot.bootstrap();
}
--- /dev/null
+package org.argeo.osgi.boot;
+
+import java.io.File;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.launch.Framework;
+
+/** Monitors the runtime and can shut it down. */
+public class AdminThread extends Thread {
+ public final static String PROP_ARGEO_OSGI_SHUTDOWN_FILE = "argeo.osgi.shutdownFile";
+ private File shutdownFile;
+ private final BundleContext bundleContext;
+
+ public AdminThread(BundleContext bundleContext) {
+ super("OSGi Boot Admin");
+ this.bundleContext = bundleContext;
+ if (System.getProperty(PROP_ARGEO_OSGI_SHUTDOWN_FILE) != null) {
+ shutdownFile = new File(
+ System.getProperty(PROP_ARGEO_OSGI_SHUTDOWN_FILE));
+ if (!shutdownFile.exists()) {
+ shutdownFile = null;
+ OsgiBootUtils.warn("Shutdown file " + shutdownFile
+ + " not found, feature deactivated");
+ }
+ }
+ }
+
+ public void run() {
+ if (shutdownFile != null) {
+ // wait for file to be removed
+ while (shutdownFile.exists()) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ Framework framework = (Framework) bundleContext.getBundle(0);
+ try {
+ // shutdown framework
+ framework.stop();
+ // wait 10 mins for shutdown
+ framework.waitForStop(10 * 60 * 1000);
+ // close VM
+ System.exit(0);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+ }
+}