@@ -415,6 +415,11 @@ public synchronized void start() {
415
415
} catch (IOException e ) {
416
416
throw new UncheckedIOException ("Failed to create working directory for " + this , e );
417
417
}
418
+
419
+ copyExtraJars ();
420
+
421
+ copyExtraConfigFiles ();
422
+
418
423
createConfiguration ();
419
424
420
425
if (plugins .isEmpty () == false ) {
@@ -438,7 +443,7 @@ public synchronized void start() {
438
443
runElaticsearchBinScript ("elasticsearch-keystore" , "create" );
439
444
440
445
keystoreSettings .forEach ((key , value ) ->
441
- runElaticsearchBinScriptWithInput (value .toString (), "elasticsearch-keystore" , "add" , "-x" , key )
446
+ runElasticsearchBinScriptWithInput (value .toString (), "elasticsearch-keystore" , "add" , "-x" , key )
442
447
);
443
448
444
449
for (Map .Entry <String , File > entry : keystoreFiles .entrySet ()) {
@@ -453,10 +458,6 @@ public synchronized void start() {
453
458
454
459
installModules ();
455
460
456
- copyExtraConfigFiles ();
457
-
458
- copyExtraJars ();
459
-
460
461
if (isSettingTrue ("xpack.security.enabled" )) {
461
462
if (credentials .isEmpty ()) {
462
463
user (Collections .emptyMap ());
@@ -622,7 +623,7 @@ public void user(Map<String, String> userSpec) {
622
623
credentials .add (cred );
623
624
}
624
625
625
- private void runElaticsearchBinScriptWithInput (String input , String tool , String ... args ) {
626
+ private void runElasticsearchBinScriptWithInput (String input , String tool , String ... args ) {
626
627
if (
627
628
Files .exists (getDistroDir ().resolve ("bin" ).resolve (tool )) == false &&
628
629
Files .exists (getDistroDir ().resolve ("bin" ).resolve (tool + ".bat" )) == false
@@ -663,7 +664,7 @@ private void runElaticsearchBinScriptWithInput(String input, String tool, String
663
664
}
664
665
665
666
private void runElaticsearchBinScript (String tool , String ... args ) {
666
- runElaticsearchBinScriptWithInput ("" , tool , args );
667
+ runElasticsearchBinScriptWithInput ("" , tool , args );
667
668
}
668
669
669
670
private Map <String , String > getESEnvironment () {
@@ -676,6 +677,10 @@ private Map<String, String> getESEnvironment() {
676
677
if (systemProperties .isEmpty () == false ) {
677
678
systemPropertiesString = " " + systemProperties .entrySet ().stream ()
678
679
.map (entry -> "-D" + entry .getKey () + "=" + entry .getValue ())
680
+ // ES_PATH_CONF is also set as an environment variable and for a reference to ${ES_PATH_CONF}
681
+ // to work ES_JAVA_OPTS, we need to make sure that ES_PATH_CONF before ES_JAVA_OPTS. Instead,
682
+ // we replace the reference with the actual value in other environment variables
683
+ .map (p -> p .replace ("${ES_PATH_CONF}" , configFile .getParent ().toString ()))
679
684
.collect (Collectors .joining (" " ));
680
685
}
681
686
String jvmArgsString = "" ;
0 commit comments