From 1985110fa3452e63c6014adca491eaedb6233289 Mon Sep 17 00:00:00 2001 From: Tsvetomir Hristov Date: Fri, 11 Oct 2024 11:26:08 +0200 Subject: [PATCH] Trying to export variables --- ct/elasticsearch.sh | 10 ++++++++-- install/elasticsearch-install.sh | 16 +++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ct/elasticsearch.sh b/ct/elasticsearch.sh index 0647b1c5..eb920d3f 100644 --- a/ct/elasticsearch.sh +++ b/ct/elasticsearch.sh @@ -81,5 +81,11 @@ build_container description msg_ok "Completed Successfully!\n" -echo -e "${APP} should be reachable on port 9200 - ${BL}http://${IP}:9200${CL} \n" +echo -e "${APP} is installed, you can check it's health by running: + ${BL}curl -XGET --insecure --fail --user $ELASTIC_USER:$ELASTIC_PASSWORD https://localhost:$ELASTIC_PORT/_cluster/health?pretty${CL} + Elasticsearch credentials are: + User: ${BL}${ELASTIC_USER}${CL} + Password: ${BL}${ELASTIC_PASSWORD}${CL} + Enrollment and Kibana tokens were also generated for you: + Kibana Token: ${BL}${KIBANA_TOKEN}${CL} + Enrollment Token: ${BL}${ENROLLMENT_TOKEN}${CL} \n" diff --git a/install/elasticsearch-install.sh b/install/elasticsearch-install.sh index ba338306..ff4908e2 100644 --- a/install/elasticsearch-install.sh +++ b/install/elasticsearch-install.sh @@ -34,6 +34,13 @@ $STD apt-get update $STD apt-get install elasticsearch msg_ok "Installed Elastcisearch" +msg_info "Configuring User" +ELASTIC_USER=elastic +ELASTIC_PASSWORD=$(/usr/share/elasticsearch/bin/elasticsearch-reset-password -sbf -u $ELASTIC_USER) +KIBANA_TOKEN=$(/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana) +ENROLLMENT_TOKEN=$(/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node) +msg_ok "Installed Elastcisearch" + msg_info "Configuring Elasticsearch Memory" $STD sed -i -E 's/## -Xms[0-9]+[Ggm]/-Xms3g/' /etc/elasticsearch/jvm.options $STD sed -i -E 's/## -Xmx[0-9]+[Ggm]/-Xmx3g/' /etc/elasticsearch/jvm.options @@ -46,12 +53,9 @@ $STD /bin/systemctl start elasticsearch.service msg_ok "Created Service" msg_info "Checking Health" -ELASTIC_USER=elastic -ELASTIC_PASSWORD=$(/usr/share/elasticsearch/bin/elasticsearch-reset-password -u $ELASTIC_USER -b -s -f) ELASTIC_PORT=9200 -echo $ELASTIC_USER -echo $ELASTIC_PASSWORD -echo $ELASTIC_IP +echo "User: $ELASTIC_USER" +echo "Password: $ELASTIC_PASSWORD" curl -XGET --insecure --fail --user $ELASTIC_USER:$ELASTIC_PASSWORD https://localhost:$ELASTIC_PORT/_cluster/health?pretty msg_ok "Checked Health" @@ -62,3 +66,5 @@ msg_info "Cleaning up" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned" + +export ELASTIC_USER ELASTIC_PASSWORD KIBANA_TOKEN ENROLLMENT_TOKEN