Allow default value for CONF_FOLDER to be set at build time
Closes gh-6549
This commit is contained in:
parent
1d58247ecc
commit
8c106af384
|
@ -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 {
|
||||||
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 {
|
||||||
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
|
||||||
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 {
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue