Skip to content

Commit

Permalink
fix java home (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmberCharitos authored Nov 12, 2024
1 parent a5f63eb commit 8cacada
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/relations/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,18 @@ def update_certificates(self, relation_broken=False) -> None:

certificate = self.charm.state.opensearch_certificate

out, _ = container.exec(
["/bin/sh", "-c", "echo $JAVA_HOME"]
).wait_output()
java_home = out.strip()

if certificate and not relation_broken:
container.push("/opensearch.crt", certificate)
command = [
"keytool",
"-importcert",
"-keystore",
"$JAVA_HOME/lib/security/cacerts",
f"{java_home}/lib/security/cacerts",
"-file",
"/opensearch.crt",
"-alias",
Expand All @@ -117,7 +122,7 @@ def update_certificates(self, relation_broken=False) -> None:
"keytool",
"-delete",
"-keystore",
"$JAVA_HOME/lib/security/cacerts",
f"{java_home}/lib/security/cacerts",
"-alias",
CERTIFICATE_NAME,
"-storepass",
Expand Down

0 comments on commit 8cacada

Please sign in to comment.