mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2026-05-04 18:37:52 +02:00
Change from tmp
This commit is contained in:
@@ -16,42 +16,44 @@ OSARCH=( "linux-x86_64" "windows-x86_64" "darwin-x86_64" "darwin-aarch64" )
|
|||||||
|
|
||||||
if [[ -z $FLEETHOST ]] || [[ -z $ENROLLMENTOKEN ]]; then printf "\nFleet Host URL or Enrollment Token empty - exiting..." && exit; fi
|
if [[ -z $FLEETHOST ]] || [[ -z $ENROLLMENTOKEN ]]; then printf "\nFleet Host URL or Enrollment Token empty - exiting..." && exit; fi
|
||||||
|
|
||||||
printf "\n### Get rid of any previous runs\n"
|
printf "\n### Creating a temp directory at /nsm/elastic-agent-workspace\n"
|
||||||
rm -rf /tmp/elastic-agent-workspace
|
rm -rf /nsm/elastic-agent-workspace
|
||||||
mkdir -p /tmp/elastic-agent-workspace
|
mkdir -p /nsm/elastic-agent-workspace
|
||||||
|
|
||||||
printf "\n### Extract 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 /tmp/elastic-agent-workspace/
|
tar -xf /nsm/elastic-fleet/artifacts/elastic-agent_SO-{{ GLOBALS.so_version }}.tar.gz -C /nsm/elastic-agent-workspace/
|
||||||
unzip -q /tmp/elastic-agent-workspace/elastic-agent-*.zip -d /tmp/elastic-agent-workspace/
|
unzip -q /nsm/elastic-agent-workspace/elastic-agent-*.zip -d /nsm/elastic-agent-workspace/
|
||||||
for archive in /tmp/elastic-agent-workspace/*.tar.gz
|
for archive in /nsm/elastic-agent-workspace/*.tar.gz
|
||||||
do
|
do
|
||||||
printf "\nExtracting $archive..."
|
printf "\nExtracting $archive..."
|
||||||
tar xf "$archive" -C /tmp/elastic-agent-workspace/
|
tar xf "$archive" -C /nsm/elastic-agent-workspace/
|
||||||
done
|
done
|
||||||
|
|
||||||
printf "\n\n### Strip out unused components"
|
printf "\n### Stripping out unused components"
|
||||||
find /tmp/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\n### Tar everything up again"
|
printf "\n### Tarring everything up again"
|
||||||
for OS in "${OSARCH[@]}"
|
for OS in "${OSARCH[@]}"
|
||||||
do
|
do
|
||||||
printf "\nCreating tarball for $OS..."
|
printf "\nCreating tarball for $OS..."
|
||||||
rm -rf /tmp/elastic-agent-workspace/elastic-agent
|
rm -rf /nsm/elastic-agent-workspace/elastic-agent
|
||||||
mv /tmp/elastic-agent-workspace/elastic-agent-*-$OS /tmp/elastic-agent-workspace/elastic-agent
|
mv /nsm/elastic-agent-workspace/elastic-agent-*-$OS /nsm/elastic-agent-workspace/elastic-agent
|
||||||
tar -czf /tmp/elastic-agent-workspace/$OS.tar.gz -C /tmp/elastic-agent-workspace elastic-agent
|
tar -czf /nsm/elastic-agent-workspace/$OS.tar.gz -C /nsm/elastic-agent-workspace elastic-agent
|
||||||
done
|
done
|
||||||
|
|
||||||
GOTARGETOS=( "linux" "windows" "darwin" "darwin/arm64" )
|
GOTARGETOS=( "linux" "windows" "darwin" "darwin/arm64" )
|
||||||
GOARCH="amd64"
|
GOARCH="amd64"
|
||||||
printf "\n### Generate OS packages using the cleaned up tarballs"
|
printf "\n### Generating OS packages using the cleaned up tarballs"for GOOS in "${GOTARGETOS[@]}"
|
||||||
for GOOS in "${GOTARGETOS[@]}"
|
|
||||||
do
|
do
|
||||||
if [[ $GOOS == 'darwin/arm64' ]]; then GOOS="darwin" && GOARCH="arm64"; fi
|
if [[ $GOOS == 'darwin/arm64' ]]; then GOOS="darwin" && GOARCH="arm64"; fi
|
||||||
printf "\n\n### Generating $GOOS/$GOARCH Installer...\n"
|
printf "\n\n### Generating $GOOS/$GOARCH Installer...\n"
|
||||||
docker run -e CGO_ENABLED=0 -e GOOS=$GOOS -e GOARCH=$GOARCH \
|
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=/tmp/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.fleetHostURLsList=$FLEETHOST -X main.enrollmentToken=$ENROLLMENTOKEN" -o /output/so-elastic-agent_${GOOS}_${GOARCH}
|
{{ 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### $GOOS/$GOARCH Installer Generated...\n"
|
printf "\n### $GOOS/$GOARCH Installer Generated...\n"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
printf "\n### Cleaning up temp files in /nsm/elastic-agent-workspace"
|
||||||
|
rm -rf /nsm/elastic-agent-workspace
|
||||||
Reference in New Issue
Block a user