Repository: karaf Updated Branches: refs/heads/karaf-3.0.x 605e68026 -> 830251463
[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/83025146 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/83025146 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/83025146 Branch: refs/heads/karaf-3.0.x Commit: 830251463955740cac12fbf38d59b0459716829f Parents: 605e680 Author: Guillaume Nodet <gno...@gmail.com> Authored: Tue May 20 15:18:11 2014 +0200 Committer: Guillaume Nodet <gno...@gmail.com> Committed: Tue May 20 15:20:41 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/83025146/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) {