You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2014/01/07 18:20:27 UTC

[1/2] git commit: MARMOTTA-318: added startup/shutdown scripts to the INSTALL_DIR for the installer

Updated Branches:
  refs/heads/develop 86d1a4004 -> 5f1c39cd8


MARMOTTA-318: added startup/shutdown scripts to the INSTALL_DIR for the installer


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/31420377
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/31420377
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/31420377

Branch: refs/heads/develop
Commit: 3142037703b6a8ae8b7b11ff9658b21c3154aa95
Parents: 86d1a40
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Jan 7 17:03:32 2014 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Tue Jan 7 18:16:09 2014 +0100

----------------------------------------------------------------------
 launchers/marmotta-installer/assembly.xml       |  8 +------
 launchers/marmotta-installer/pom.xml            |  4 ++++
 .../src/main/resources/installer/standalone.xml |  8 +++++++
 .../src/main/resources/unix/shutdown.sh         | 24 ++++++++++++++++++++
 .../src/main/resources/unix/startup.sh          | 24 ++++++++++++++++++++
 5 files changed, 61 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/31420377/launchers/marmotta-installer/assembly.xml
----------------------------------------------------------------------
diff --git a/launchers/marmotta-installer/assembly.xml b/launchers/marmotta-installer/assembly.xml
index 0e8fa6e..d097f07 100644
--- a/launchers/marmotta-installer/assembly.xml
+++ b/launchers/marmotta-installer/assembly.xml
@@ -48,15 +48,9 @@
             <fileMode>0644</fileMode>
         </file>
         <file>
-            <source>${project.basedir}/../../DISCLAIMER.txt</source>
-            <outputDirectory>/</outputDirectory>
-            <fileMode>0644</fileMode>
-            <filtered>true</filtered>
-        </file>
-        <file>
             <source>${project.build.directory}/marmotta-installer-${project.version}.jar</source>
             <outputDirectory>/</outputDirectory>
             <fileMode>0644</fileMode>
         </file>
     </files>
-</assembly>
\ No newline at end of file
+</assembly>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/31420377/launchers/marmotta-installer/pom.xml
----------------------------------------------------------------------
diff --git a/launchers/marmotta-installer/pom.xml b/launchers/marmotta-installer/pom.xml
index 037e0aa..1840233 100644
--- a/launchers/marmotta-installer/pom.xml
+++ b/launchers/marmotta-installer/pom.xml
@@ -129,6 +129,10 @@
                                             <targetPath>macos</targetPath>
                                         </resource>
                                         <resource>
+                                            <directory>src/main/resources/unix</directory>
+                                            <targetPath>unix</targetPath>
+                                        </resource>
+                                        <resource>
                                             <directory>src/main/resources/log</directory>
                                             <targetPath>log</targetPath>
                                         </resource>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/31420377/launchers/marmotta-installer/src/main/resources/installer/standalone.xml
----------------------------------------------------------------------
diff --git a/launchers/marmotta-installer/src/main/resources/installer/standalone.xml b/launchers/marmotta-installer/src/main/resources/installer/standalone.xml
index 6b8c004..804163f 100644
--- a/launchers/marmotta-installer/src/main/resources/installer/standalone.xml
+++ b/launchers/marmotta-installer/src/main/resources/installer/standalone.xml
@@ -89,20 +89,28 @@
             <file src="tomcat/index.jsp" targetdir="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/webapps/ROOT" override="true" />
             <file src="log/catalina.out" targetdir="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/logs" />
             <file src="lib/marmotta-splash-${MARMOTTA_VERSION}.jar" targetdir="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/lib" />
+            <!-- macos specific -->
             <file src="macos/Start Apache Marmotta.app" targetdir="\$INSTALL_PATH" os="mac" />
             <file src="images/icon_start.icns" targetdir="\$INSTALL_PATH/Start Apache Marmotta.app/Contents/Resources" os="mac" />
             <file src="macos/Stop Apache Marmotta.app" targetdir="\$INSTALL_PATH" os="mac" />
             <file src="images/icon_stop.icns" targetdir="\$INSTALL_PATH/Stop Apache Marmotta.app/Contents/Resources" os="mac" />
+            <!-- linux specific -->
+            <file src="unix/startup.sh" targetdir="\$INSTALL_PATH/" os="unix" />
+            <file src="unix/shutdown.sh" targetdir="\$INSTALL_PATH/" os="unix" />
             <parsable type="shell" targetfile="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/bin/setenv.sh" parse="yes" />
             <parsable type="shell" targetfile="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/bin/setenv.bat" parse="yes" />
             <parsable type="shell" targetfile="\$INSTALL_PATH/Start Apache Marmotta.app/Contents/MacOS/run.sh" parse="yes" os="mac" />
             <parsable type="shell" targetfile="\$INSTALL_PATH/Stop Apache Marmotta.app/Contents/MacOS/run.sh" parse="yes" os="mac" />
+            <parsable type="shell" targetfile="\$INSTALL_PATH/startup.sh" parse="yes" os="unix" />
+            <parsable type="shell" targetfile="\$INSTALL_PATH/shutdown.sh" parse="yes" os="unix" />
             <executable targetfile="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/bin/setenv.sh" stage="never" />
             <executable targetfile="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/bin/catalina.sh" stage="never" />
             <executable targetfile="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/bin/startup.sh" stage="never" />
             <executable targetfile="\$INSTALL_PATH/apache-tomcat-${TOMCAT_VERSION}/bin/shutdown.sh" stage="never" />
             <executable targetfile="\$INSTALL_PATH/Start Apache Marmotta.app/Contents/MacOS/run.sh" stage="never" os="mac" />
             <executable targetfile="\$INSTALL_PATH/Stop Apache Marmotta.app/Contents/MacOS/run.sh" stage="never" os="mac" />
+            <executable targetfile="\$INSTALL_PATH/startup.sh" stage="never" os="unix" />
+            <executable targetfile="\$INSTALL_PATH/shutdown.sh" stage="never" os="unix" />
         </pack>
         <refpack file="refpacks/marmotta-webapp.xml" />
         <refpack file="refpacks/marmotta-core.xml" />

http://git-wip-us.apache.org/repos/asf/marmotta/blob/31420377/launchers/marmotta-installer/src/main/resources/unix/shutdown.sh
----------------------------------------------------------------------
diff --git a/launchers/marmotta-installer/src/main/resources/unix/shutdown.sh b/launchers/marmotta-installer/src/main/resources/unix/shutdown.sh
new file mode 100644
index 0000000..e207c81
--- /dev/null
+++ b/launchers/marmotta-installer/src/main/resources/unix/shutdown.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# 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.
+#
+# -----------------------------------------------------------------------------
+# Stop script for the Apache Marmotta Platform
+# -----------------------------------------------------------------------------
+
+# just stop tomcat...
+%{INSTALL_PATH}/apache-tomcat-%{TOMCAT_VERSION}/bin/shutdown.sh "$@"
+

http://git-wip-us.apache.org/repos/asf/marmotta/blob/31420377/launchers/marmotta-installer/src/main/resources/unix/startup.sh
----------------------------------------------------------------------
diff --git a/launchers/marmotta-installer/src/main/resources/unix/startup.sh b/launchers/marmotta-installer/src/main/resources/unix/startup.sh
new file mode 100644
index 0000000..d3df807
--- /dev/null
+++ b/launchers/marmotta-installer/src/main/resources/unix/startup.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# 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.
+#
+# -----------------------------------------------------------------------------
+# Start script for the Apache Marmotta Platform
+# -----------------------------------------------------------------------------
+
+# just launch tomcat...
+%{INSTALL_PATH}/apache-tomcat-%{TOMCAT_VERSION}/bin/startup.sh "$@"
+


[2/2] git commit: MARMOTTA-257: Keep the file-attributes.

Posted by ja...@apache.org.
MARMOTTA-257: Keep the file-attributes.


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/5f1c39cd
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/5f1c39cd
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/5f1c39cd

Branch: refs/heads/develop
Commit: 5f1c39cd86eab05f3940afa062856f25a7883e4f
Parents: 3142037
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Jan 7 18:15:11 2014 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Tue Jan 7 18:19:25 2014 +0100

----------------------------------------------------------------------
 .../config/ConfigurationServiceImpl.java        | 91 +++++++++++++++-----
 1 file changed, 68 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/5f1c39cd/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
index 50a52af..5de47db 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/config/ConfigurationServiceImpl.java
@@ -19,7 +19,12 @@ package org.apache.marmotta.platform.core.services.config;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-import org.apache.commons.configuration.*;
+import org.apache.commons.configuration.AbstractConfiguration;
+import org.apache.commons.configuration.CompositeConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.MapConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.marmotta.platform.core.api.config.ConfigurationService;
@@ -44,10 +49,6 @@ import java.io.IOException;
 import java.lang.reflect.Array;
 import java.net.URL;
 import java.net.UnknownHostException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
 import java.util.*;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -352,9 +353,9 @@ public class ConfigurationServiceImpl implements ConfigurationService {
         if (!config.getBoolean("kiwi.setup.database")) {
             log.info("SETUP: Setting up initial Apache Marmotta database configuration ...");
             String db_type = config.getString("database.type", "h2");
-            config.setProperty("database.h2.url", "jdbc:h2:" + getWorkDir() + "/db/marmotta;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10");
+            config.setProperty("database.h2.url", "jdbc:h2:" + getHome() + "/db/marmotta;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10");
             if (db_type.equals("h2")) {
-                config.setProperty("database.url", "jdbc:h2:" + getWorkDir() + "/db/marmotta;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10");
+                config.setProperty("database.url", "jdbc:h2:" + getHome() + "/db/marmotta;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10");
                 config.setProperty("database.user", "sa");
                 config.setProperty("database.password", "sa");
                 config.setProperty("database.mode", "create");
@@ -1126,6 +1127,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
 
     /**
      * The work directory for marmotta, where all applications will create their own subdirectories
+     * @deprecated This name is misleading, use {@link #getHome()} instead.
      */
 
     @Override
@@ -1137,27 +1139,72 @@ public class ConfigurationServiceImpl implements ConfigurationService {
     protected void save() {
         if(saveConfiguration instanceof PropertiesConfiguration) {
             try {
-                Path tmpFile = Files.createTempFile(FileSystems.getDefault().getPath(getHome()),"system-config",".properties");
-
-                ((PropertiesConfiguration) saveConfiguration).save(tmpFile.toFile());
-
-                Files.move(tmpFile, FileSystems.getDefault().getPath(configFileName), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
-            } catch (ConfigurationException | IOException e) {
-                log.error("could not save system configuration: #0", e.getMessage());
+                log.debug("Saving configuration values");
+                final PropertiesConfiguration conf = (PropertiesConfiguration)saveConfiguration;
+                saveSecure(conf);
+            } catch (ConfigurationException e) {
+                log.error("could not save system configuration: {}", e.getMessage());
             }
         }
 
         if(saveMetadata instanceof PropertiesConfiguration) {
             try {
-                Path tmpFile = Files.createTempFile(FileSystems.getDefault().getPath(getHome()),"system-meta",".properties");
+                log.debug("Saving configuration description");
+                final PropertiesConfiguration conf = (PropertiesConfiguration)saveMetadata;
+                saveSecure(conf);
+            } catch (ConfigurationException e) {
+                log.error("could not save system metadata: {}", e.getMessage());
+            }
+        }
+    }
 
-                ((PropertiesConfiguration)saveMetadata).save(tmpFile.toFile());
+    protected void saveSecure(final PropertiesConfiguration conf) throws ConfigurationException {
+        final File file = conf.getFile();
+        try {
+            if (file == null) {
+                throw new ConfigurationException("No file name has been set!");
+            } else if ((file.createNewFile() || true) && !file.canWrite()) {
+                throw new IOException("Cannot write to file " + file.getAbsolutePath() + ". Is it read-only?");
+            }
+        } catch (IOException e) {
+            throw new ConfigurationException(e.getMessage(), e);
+        }
+        log.debug("Saving {}", file.getAbsolutePath());
+        
+        final String fName = file.getName();
+        try {
+            int lastDot = fName.lastIndexOf('.');
+            lastDot = lastDot > 0 ? lastDot : fName.length();
 
+            final Path configPath = file.toPath();
+            // Create a tmp file next to the original
+            final Path tmp = Files.createTempFile(configPath.getParent(), fName.substring(0, lastDot)+".", fName.substring(lastDot));
+            try {
+                Files.copy(configPath, tmp, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
+            } catch (IOException iox) {
+                log.error("Could not create temp-file {}: {}", tmp, iox.getMessage());
+                throw iox;
+            }
+            log.trace("using temporary file: {}", tmp);
+            // Save the config to the tmp file
+            conf.save(tmp.toFile());
 
-                Files.move(tmpFile, FileSystems.getDefault().getPath(metaFileName), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
-            } catch (ConfigurationException | IOException e) {
-                log.error("could not save system metadata: #0", e.getMessage());
+            log.trace("tmp saved, now replacing the original file: {}", configPath);
+            // Replace the original with the tmp file
+            try {
+                try {
+                    Files.move(tmp, configPath, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
+                } catch (AtomicMoveNotSupportedException amnx) {
+                    log.trace("atomic move not available: {}, trying without", amnx.getMessage());
+                    Files.move(tmp, configPath, StandardCopyOption.REPLACE_EXISTING);
+                }
+            } catch (IOException iox) {
+                log.error("Could not write to {}, a backup was created in {}", configPath, tmp);
+                throw iox;
             }
+            log.info("configuration successfully saved to {}", configPath);
+        } catch (final Throwable t) {
+            throw new ConfigurationException("Unable to save the configuration to the file " + fName, t);
         }
     }
 
@@ -1189,8 +1236,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
 
     /**
      * Set the LMF_HOME value to the correct path. Used during the initialization process.
-     *
-     * @param home
+     * @deprecated LMF_HOME is deprecated, use {@link #setHome(String)} instead!
      */
     @Override
     @Deprecated
@@ -1211,8 +1257,7 @@ public class ConfigurationServiceImpl implements ConfigurationService {
 
     /**
      * Return the value of the LMF_HOME setting. Used during the initialization process.
-     *
-     * @return
+     * @deprecated use {@link #getHome()} instead
      */
     @Override
     @Deprecated