Commit 56a58880 authored by Ali Shahbour's avatar Ali Shahbour Committed by Andy Wilkinson

Find .conf file next to symlink to jar that's using the launch script

See gh-8988
parent b59bc20f
...@@ -59,6 +59,7 @@ import static org.junit.Assume.assumeThat; ...@@ -59,6 +59,7 @@ import static org.junit.Assume.assumeThat;
* Integration tests for Spring Boot's launch script on OSs that use SysVinit. * Integration tests for Spring Boot's launch script on OSs that use SysVinit.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Ali Shahbour
*/ */
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
public class SysVinitLaunchScriptIT { public class SysVinitLaunchScriptIT {
...@@ -194,6 +195,12 @@ public class SysVinitLaunchScriptIT { ...@@ -194,6 +195,12 @@ public class SysVinitLaunchScriptIT {
doLaunch("launch-with-single-java-opt.sh"); doLaunch("launch-with-single-java-opt.sh");
} }
@Test
public void launchWithDoubleLinkSingleJavaOpt() throws Exception {
doLaunch("launch-with-double-link-single-java-opt.sh");
}
@Test @Test
public void launchWithMultipleJavaOpts() throws Exception { public void launchWithMultipleJavaOpts() throws Exception {
doLaunch("launch-with-multiple-java-opts.sh"); doLaunch("launch-with-multiple-java-opts.sh");
......
source ./test-functions.sh
install_double_link_service
echo 'JAVA_OPTS=-Dserver.port=8081' > /test-service/spring-boot-app.conf
start_service
await_app http://127.0.0.1:8081/
curl -s http://127.0.0.1:8081/
\ No newline at end of file
...@@ -5,6 +5,14 @@ install_service() { ...@@ -5,6 +5,14 @@ install_service() {
ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app
} }
install_double_link_service() {
mkdir /test-service
mv /spring-boot-launch-script-tests-*.jar /test-service/
chmod +x /test-service/spring-boot-launch-script-tests-*.jar
ln -s /test-service/spring-boot-launch-script-tests-*.jar /test-service/spring-boot-app.jar
ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app
}
start_service() { start_service() {
service spring-boot-app start $@ service spring-boot-app start $@
} }
......
...@@ -32,7 +32,13 @@ WORKING_DIR="$(pwd)" ...@@ -32,7 +32,13 @@ WORKING_DIR="$(pwd)"
cd "$(dirname "$0")" || exit 1 cd "$(dirname "$0")" || exit 1
[[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0") [[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0")
while [[ -L "$jarfile" ]]; do while [[ -L "$jarfile" ]]; do
[[ "$jarfile" =~ init\.d ]] && init_script=$(basename "$jarfile") if [[ "$jarfile" =~ init\.d ]]; then
init_script=$(basename "$jarfile")
else
# while looping check if their is any configuration file
configfile="${jarfile%.*}.conf"
[[ -r ${configfile} ]] && source "${configfile}"
fi
jarfile=$(readlink "$jarfile") jarfile=$(readlink "$jarfile")
cd "$(dirname "$jarfile")" || exit 1 cd "$(dirname "$jarfile")" || exit 1
jarfile=$(pwd)/$(basename "$jarfile") jarfile=$(pwd)/$(basename "$jarfile")
...@@ -45,7 +51,6 @@ configfile="$(basename "${jarfile%.*}.conf")" ...@@ -45,7 +51,6 @@ configfile="$(basename "${jarfile%.*}.conf")"
# Initialize CONF_FOLDER location defaulting to jarfolder # Initialize CONF_FOLDER location defaulting to jarfolder
[[ -z "$CONF_FOLDER" ]] && CONF_FOLDER="{{confFolder:${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}"
......
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