mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Merge pull request #10352 from Security-Onion-Solutions/2.4/taglogs
Refactor wrapper
This commit is contained in:
@@ -4,20 +4,17 @@
|
|||||||
# or more contributor license agreements. Licensed under the Elastic License 2.0; you may not use
|
# or more contributor license agreements. Licensed under the Elastic License 2.0; you may not use
|
||||||
# this file except in compliance with the Elastic License 2.0.
|
# this file except in compliance with the Elastic License 2.0.
|
||||||
|
|
||||||
#so-elastic-agent-gen-installers $FleetHost $EnrollmentToken
|
#so-elastic-agent-gen-installers $FleetHostURLs $EnrollmentToken
|
||||||
|
|
||||||
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
{% from 'vars/globals.map.jinja' import GLOBALS %}
|
||||||
|
|
||||||
. /usr/sbin/so-common
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
ENROLLMENTOKEN=$(curl -K /opt/so/conf/elasticsearch/curl.config -L "localhost:5601/api/fleet/enrollment_api_keys" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' | jq .list | jq -r -c '.[] | select(.policy_id | contains("endpoints")) | .api_key')
|
ENROLLMENTOKEN=$(curl -K /opt/so/conf/elasticsearch/curl.config -L "localhost:5601/api/fleet/enrollment_api_keys" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' | jq .list | jq -r -c '.[] | select(.policy_id | contains("endpoints")) | .api_key')
|
||||||
|
FLEETHOST=$(curl -K /opt/so/conf/elasticsearch/curl.config 'http://localhost:5601/api/fleet/fleet_server_hosts' | jq -r '.items[].host_urls[]' | paste -sd ',')
|
||||||
|
OSARCH=( "linux-x86_64" "windows-x86_64" "darwin-x86_64" "darwin-aarch64" )
|
||||||
|
|
||||||
#FLEETHOST=$(lookup_pillar "server:url" "elasticfleet")
|
if [[ -z $FLEETHOST ]] || [[ -z $ENROLLMENTOKEN ]]; then printf "\nFleet Host URL or Enrollment Token empty - exiting..." && exit; fi
|
||||||
FLEETHOST="{{ GLOBALS.manager_ip }}"
|
|
||||||
|
|
||||||
#FLEETHOST=$1
|
|
||||||
#ENROLLMENTOKEN=$2
|
|
||||||
TARGETOS=( "linux" "darwin" "windows" )
|
|
||||||
|
|
||||||
printf "\n### Creating a temp directory at /nsm/elastic-agent-workspace\n"
|
printf "\n### Creating a temp directory at /nsm/elastic-agent-workspace\n"
|
||||||
rm -rf /nsm/elastic-agent-workspace
|
rm -rf /nsm/elastic-agent-workspace
|
||||||
@@ -25,9 +22,10 @@ mkdir -p /nsm/elastic-agent-workspace
|
|||||||
|
|
||||||
printf "\n### Extracting outer tarball and then each individual tarball/zip\n"
|
printf "\n### Extracting outer tarball and then each individual tarball/zip\n"
|
||||||
tar -xf /nsm/elastic-fleet/artifacts/elastic-agent_SO-{{ GLOBALS.so_version }}.tar.gz -C /nsm/elastic-agent-workspace/
|
tar -xf /nsm/elastic-fleet/artifacts/elastic-agent_SO-{{ GLOBALS.so_version }}.tar.gz -C /nsm/elastic-agent-workspace/
|
||||||
unzip /nsm/elastic-agent-workspace/elastic-agent-*.zip -d /nsm/elastic-agent-workspace/
|
unzip -q /nsm/elastic-agent-workspace/elastic-agent-*.zip -d /nsm/elastic-agent-workspace/
|
||||||
for archive in /nsm/elastic-agent-workspace/*.tar.gz
|
for archive in /nsm/elastic-agent-workspace/*.tar.gz
|
||||||
do
|
do
|
||||||
|
printf "\nExtracting $archive..."
|
||||||
tar xf "$archive" -C /nsm/elastic-agent-workspace/
|
tar xf "$archive" -C /nsm/elastic-agent-workspace/
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -35,23 +33,28 @@ printf "\n### Stripping out unused components"
|
|||||||
find /nsm/elastic-agent-workspace/elastic-agent-*/data/elastic-agent-*/components -regex '.*fleet.*\|.*packet.*\|.*apm*.*\|.*audit.*\|.*heart.*\|.*cloud.*' -delete
|
find /nsm/elastic-agent-workspace/elastic-agent-*/data/elastic-agent-*/components -regex '.*fleet.*\|.*packet.*\|.*apm*.*\|.*audit.*\|.*heart.*\|.*cloud.*' -delete
|
||||||
|
|
||||||
printf "\n### Tarring everything up again"
|
printf "\n### Tarring everything up again"
|
||||||
for OS in "${TARGETOS[@]}"
|
|
||||||
|
for OS in "${OSARCH[@]}"
|
||||||
do
|
do
|
||||||
|
printf "\nCreating tarball for $OS..."
|
||||||
rm -rf /nsm/elastic-agent-workspace/elastic-agent
|
rm -rf /nsm/elastic-agent-workspace/elastic-agent
|
||||||
mv /nsm/elastic-agent-workspace/elastic-agent-*-$OS-x86_64 /nsm/elastic-agent-workspace/elastic-agent
|
mv /nsm/elastic-agent-workspace/elastic-agent-*-$OS /nsm/elastic-agent-workspace/elastic-agent
|
||||||
tar -czvf /nsm/elastic-agent-workspace/$OS.tar.gz -C /nsm/elastic-agent-workspace elastic-agent
|
tar -czf /nsm/elastic-agent-workspace/$OS.tar.gz -C /nsm/elastic-agent-workspace elastic-agent
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "\n### Generating OS packages using the cleaned up tarballs"
|
GOTARGETOS=( "linux" "windows" "darwin" "darwin/arm64" )
|
||||||
for OS in "${TARGETOS[@]}"
|
GOARCH="amd64"
|
||||||
|
printf "\n### Generating OS packages using the cleaned up tarballs"for GOOS in "${GOTARGETOS[@]}"
|
||||||
|
|
||||||
do
|
do
|
||||||
printf "\n\n### Generating $OS Installer...\n"
|
if [[ $GOOS == 'darwin/arm64' ]]; then GOOS="darwin" && GOARCH="arm64"; fi
|
||||||
docker run -e CGO_ENABLED=0 -e GOOS=$OS \
|
printf "\n\n### Generating $GOOS/$GOARCH Installer...\n"
|
||||||
|
docker run -e CGO_ENABLED=0 -e GOOS=$GOOS -e GOARCH=$GOARCH \
|
||||||
--mount type=bind,source=/etc/ssl/certs/,target=/workspace/files/cert/ \
|
--mount type=bind,source=/etc/ssl/certs/,target=/workspace/files/cert/ \
|
||||||
--mount type=bind,source=/nsm/elastic-agent-workspace/,target=/workspace/files/elastic-agent/ \
|
--mount type=bind,source=/nsm/elastic-agent-workspace/,target=/workspace/files/elastic-agent/ \
|
||||||
--mount type=bind,source=/opt/so/saltstack/local/salt/elasticfleet/files/so_agent-installers/,target=/output/ \
|
--mount type=bind,source=/opt/so/saltstack/local/salt/elasticfleet/files/so_agent-installers/,target=/output/ \
|
||||||
{{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-elastic-agent-builder:{{ GLOBALS.so_version }} go build -ldflags "-X main.fleetHost=$FLEETHOST -X main.enrollmentToken=$ENROLLMENTOKEN" -o /output/so-elastic-agent_$OS
|
{{ GLOBALS.registry_host }}:5000/{{ GLOBALS.image_repo }}/so-elastic-agent-builder:{{ GLOBALS.so_version }} go build -ldflags "-X main.fleetHostURLsList=$FLEETHOST -X main.enrollmentToken=$ENROLLMENTOKEN" -o /output/so-elastic-agent_${GOOS}_${GOARCH}
|
||||||
printf "\n### $OS Installer Generated...\n"
|
printf "\n### $GOOS/$GOARCH Installer Generated...\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "\n### Cleaning up temp files in /nsm/elastic-agent-workspace"
|
printf "\n### Cleaning up temp files in /nsm/elastic-agent-workspace"
|
||||||
|
|||||||
Reference in New Issue
Block a user