Skip to content

Commit c79b768

Browse files
committed
Merge pull request #8988 from Ali Shahbour
* gh-8988: Polish "Find .conf file next to symlink to jar that's using the launch script" Find .conf file next to symlink to jar that's using the launch script
2 parents b59bc20 + 3db5843 commit c79b768

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
* Integration tests for Spring Boot's launch script on OSs that use SysVinit.
6060
*
6161
* @author Andy Wilkinson
62+
* @author Ali Shahbour
6263
*/
6364
@RunWith(Parameterized.class)
6465
public class SysVinitLaunchScriptIT {
@@ -194,6 +195,11 @@ public void launchWithSingleJavaOpt() throws Exception {
194195
doLaunch("launch-with-single-java-opt.sh");
195196
}
196197

198+
@Test
199+
public void launchWithDoubleLinkSingleJavaOpt() throws Exception {
200+
doLaunch("launch-with-double-link-single-java-opt.sh");
201+
}
202+
197203
@Test
198204
public void launchWithMultipleJavaOpts() throws Exception {
199205
doLaunch("launch-with-multiple-java-opts.sh");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source ./test-functions.sh
2+
install_double_link_service
3+
echo 'JAVA_OPTS=-Dserver.port=8081' > /test-service/spring-boot-app.conf
4+
start_service
5+
await_app http://127.0.0.1:8081/
6+
curl -s http://127.0.0.1:8081/

spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ install_service() {
55
ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app
66
}
77

8+
install_double_link_service() {
9+
mkdir /test-service
10+
mv /spring-boot-launch-script-tests-*.jar /test-service/
11+
chmod +x /test-service/spring-boot-launch-script-tests-*.jar
12+
ln -s /test-service/spring-boot-launch-script-tests-*.jar /test-service/spring-boot-app.jar
13+
ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app
14+
}
15+
816
start_service() {
917
service spring-boot-app start $@
1018
}

spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ WORKING_DIR="$(pwd)"
3232
cd "$(dirname "$0")" || exit 1
3333
[[ -z "$jarfile" ]] && jarfile=$(pwd)/$(basename "$0")
3434
while [[ -L "$jarfile" ]]; do
35-
[[ "$jarfile" =~ init\.d ]] && init_script=$(basename "$jarfile")
35+
if [[ "$jarfile" =~ init\.d ]]; then
36+
init_script=$(basename "$jarfile")
37+
else
38+
configfile="${jarfile%.*}.conf"
39+
# shellcheck source=/dev/null
40+
[[ -r ${configfile} ]] && source "${configfile}"
41+
fi
3642
jarfile=$(readlink "$jarfile")
3743
cd "$(dirname "$jarfile")" || exit 1
3844
jarfile=$(pwd)/$(basename "$jarfile")
@@ -45,7 +51,6 @@ configfile="$(basename "${jarfile%.*}.conf")"
4551

4652
# Initialize CONF_FOLDER location defaulting to jarfolder
4753
[[ -z "$CONF_FOLDER" ]] && CONF_FOLDER="{{confFolder:${jarfolder}}}"
48-
4954
# shellcheck source=/dev/null
5055
[[ -r "${CONF_FOLDER}/${configfile}" ]] && source "${CONF_FOLDER}/${configfile}"
5156

0 commit comments

Comments
 (0)