Commit 8c106af3 authored by Andy Wilkinson's avatar Andy Wilkinson

Allow default value for CONF_FOLDER to be set at build time

Closes gh-6549
parent 1d58247e
...@@ -608,6 +608,9 @@ for Gradle and to `${project.name}` for Maven. ...@@ -608,6 +608,9 @@ for Gradle and to `${project.name}` for Maven.
|`initInfoChkconfig` |`initInfoChkconfig`
|The `chkconfig` section of "`INIT INFO`". Defaults to `2345 99 01`. |The `chkconfig` section of "`INIT INFO`". Defaults to `2345 99 01`.
|`confFolder`
|The default value for `CONF_FOLDER`. Defaults to the folder containing the jar.
|`logFolder` |`logFolder`
|The default value for `LOG_FOLDER`. Only valid for an `init.d` service. |The default value for `LOG_FOLDER`. Only valid for an `init.d` service.
......
...@@ -42,7 +42,7 @@ public class DefaultLaunchScript implements LaunchScript { ...@@ -42,7 +42,7 @@ public class DefaultLaunchScript implements LaunchScript {
private static final int BUFFER_SIZE = 4096; private static final int BUFFER_SIZE = 4096;
private static final Pattern PLACEHOLDER_PATTERN = Pattern private static final Pattern PLACEHOLDER_PATTERN = Pattern
.compile("\\{\\{(\\w+)(:.*?)?\\}\\}"); .compile("\\{\\{(\\w+)(:.*?)?\\}\\}(?!\\})");
private final String content; private final String content;
...@@ -97,7 +97,7 @@ public class DefaultLaunchScript implements LaunchScript { ...@@ -97,7 +97,7 @@ public class DefaultLaunchScript implements LaunchScript {
else { else {
value = (value == null ? matcher.group(0) : value.substring(1)); value = (value == null ? matcher.group(0) : value.substring(1));
} }
matcher.appendReplacement(expanded, value); matcher.appendReplacement(expanded, value.replace("$", "\\$"));
} }
matcher.appendTail(expanded); matcher.appendTail(expanded);
return expanded.toString(); return expanded.toString();
......
...@@ -44,7 +44,7 @@ cd "$WORKING_DIR" || exit 1 ...@@ -44,7 +44,7 @@ cd "$WORKING_DIR" || exit 1
configfile="$(basename "${jarfile%.*}.conf")" configfile="$(basename "${jarfile%.*}.conf")"
# Initialize CONF_FOLDER location defaulting to jarfolder # Initialize CONF_FOLDER location defaulting to jarfolder
[[ -z "$CONF_FOLDER" ]] && CONF_FOLDER="${jarfolder}" [[ -z "$CONF_FOLDER" ]] && CONF_FOLDER="{{confFolder:${jarfolder}}}"
# shellcheck source=/dev/null # shellcheck source=/dev/null
[[ -r "${CONF_FOLDER}/${configfile}" ]] && source "${CONF_FOLDER}/${configfile}" [[ -r "${CONF_FOLDER}/${configfile}" ]] && source "${CONF_FOLDER}/${configfile}"
......
...@@ -86,6 +86,11 @@ public class DefaultLaunchScriptTests { ...@@ -86,6 +86,11 @@ public class DefaultLaunchScriptTests {
assertThatPlaceholderCanBeReplaced("pidFolder"); assertThatPlaceholderCanBeReplaced("pidFolder");
} }
@Test
public void confFolderCanBeReplaced() throws Exception {
assertThatPlaceholderCanBeReplaced("confFolder");
}
@Test @Test
public void defaultForUseStartStopDaemonIsTrue() throws Exception { public void defaultForUseStartStopDaemonIsTrue() throws Exception {
DefaultLaunchScript script = new DefaultLaunchScript(null, null); DefaultLaunchScript script = new DefaultLaunchScript(null, null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment