#!/usr/bin/env bash # Downloads, verifies and starts the SIEM installer (SIEMS-285), served as https://get.keelon.de/get.sh. # # curl -fsSLO https://get.keelon.de/get.sh && less get.sh && sudo bash get.sh # recommended # curl -fsSL https://get.keelon.de/get.sh | sudo bash -s -- --check # shorter, same steps # # Takes the version from https://get.keelon.de/latest (or SIEM_VERSION=vX.Y.Z), downloads the bundle and its SHA256SUMS, # refuses the bundle when the checksum does not match, unpacks it to /opt/siem-installer/ and runs # scripts/install.sh from there with the arguments given here. The checksum protects against a broken or truncated # download; the signature check of the images follows in the installer (SIEMS-286). # SIEM_GET_BASE overrides the server, SIEM_INSTALLER_DIR the unpack location, SIEM_GET_NO_RUN=1 stops after unpacking. set -euo pipefail BASE=${SIEM_GET_BASE:-https://get.keelon.de} ROOT=${SIEM_INSTALLER_DIR:-/opt/siem-installer} die() { echo "get.sh: $*" >&2 exit 1 } for c in curl tar sha256sum; do command -v "$c" >/dev/null || die "$c is missing"; done VERSION=${SIEM_VERSION:-$(curl -fsSL "$BASE/latest" | head -n1)} || die "cannot read $BASE/latest" [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]] || die "'$VERSION' is not a release version (vX.Y.Z)" NAME=siem-installer-$VERSION TMP=$(mktemp -d) trap 'rm -rf "$TMP"' EXIT echo "SIEM installer $VERSION from $BASE" curl -fsSL -o "$TMP/$NAME.tar.gz" "$BASE/$VERSION/$NAME.tar.gz" || die "download of $NAME.tar.gz failed" curl -fsSL -o "$TMP/SHA256SUMS" "$BASE/$VERSION/SHA256SUMS" || die "download of SHA256SUMS failed" grep -qE "^[0-9a-f]{64} $NAME\.tar\.gz$" "$TMP/SHA256SUMS" || die "SHA256SUMS has no entry for $NAME.tar.gz" (cd "$TMP" && sha256sum --check --strict --quiet SHA256SUMS) || die "checksum mismatch: the download is broken or was changed, nothing was installed" echo "checksum OK" DEST=$ROOT/$VERSION mkdir -p "$DEST" tar -xzf "$TMP/$NAME.tar.gz" -C "$DEST" --strip-components=1 --no-same-owner [ "$(head -n1 "$DEST/RELEASE")" = "$VERSION" ] || die "the bundle in $DEST is not $VERSION" echo "unpacked to $DEST" [ "${SIEM_GET_NO_RUN:-0}" != 1 ] || exit 0 # piped into bash, stdin is the script itself: the prompts of the installer need the terminal if [ -t 0 ] || ! { : /dev/null; then exec bash "$DEST/scripts/install.sh" "$@" fi exec bash "$DEST/scripts/install.sh" "$@"