You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/05/20 15:18:21 UTC

git commit: [KARAF-2992] Generate the shutdown command at first boot

Repository: karaf
Updated Branches:
  refs/heads/master d68fba1da -> 78bf566d5


[KARAF-2992] Generate the shutdown command at first boot

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

Branch: refs/heads/master
Commit: 78bf566d5104aa5ed91754ba3dcdb88c9c498ed7
Parents: d68fba1
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Tue May 20 15:18:11 2014 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Tue May 20 15:18:11 2014 +0200

----------------------------------------------------------------------
 .../java/org/apache/karaf/main/ConfigProperties.java    | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/78bf566d/main/src/main/java/org/apache/karaf/main/ConfigProperties.java
----------------------------------------------------------------------
diff --git a/main/src/main/java/org/apache/karaf/main/ConfigProperties.java b/main/src/main/java/org/apache/karaf/main/ConfigProperties.java
index d30c9c1..32947d9 100644
--- a/main/src/main/java/org/apache/karaf/main/ConfigProperties.java
+++ b/main/src/main/java/org/apache/karaf/main/ConfigProperties.java
@@ -22,6 +22,9 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.UUID;
+
 import org.apache.felix.utils.properties.Properties;
 
 import org.apache.karaf.main.lock.SimpleFileLock;
@@ -231,10 +234,17 @@ public class ConfigProperties {
         this.shutdownPort = Integer.parseInt(props.getProperty(KARAF_SHUTDOWN_PORT, "0"));
         this.shutdownHost = props.getProperty(KARAF_SHUTDOWN_HOST, "localhost");
         this.portFile = props.getProperty(KARAF_SHUTDOWN_PORT_FILE);
-        this.shutdownCommand = props.getProperty(KARAF_SHUTDOWN_COMMAND, DEFAULT_SHUTDOWN_COMMAND);
+        this.shutdownCommand = props.getProperty(KARAF_SHUTDOWN_COMMAND);
         this.startupMessage = props.getProperty(KARAF_STARTUP_MESSAGE, "Apache Karaf starting up. Press Enter to open the shell now...");
         this.delayConsoleStart = Boolean.parseBoolean(props.getProperty(KARAF_DELAY_CONSOLE, "false"));
         System.setProperty(KARAF_DELAY_CONSOLE, new Boolean(this.delayConsoleStart).toString());
+
+        if (shutdownCommand == null || shutdownCommand.isEmpty()) {
+            shutdownCommand = UUID.randomUUID().toString();
+            Properties temp = new Properties(file);
+            temp.put(KARAF_SHUTDOWN_COMMAND, Arrays.asList("", "#", "# Generated command shutdown", "#"), shutdownCommand);
+            temp.save();
+        }
     }
     
     private String getPropertyOrFail(String propertyName) {