#!/usr/bin/env bash # Keep mount, reads and unmount inside the same rootless user/mount namespace. set -euo pipefail image="${1:?usage: extract-node-binaries.sh }" destination="${2:?}" mkdir -p "$destination" buildah unshare bash -s -- "$image" "$destination" <<'SH' set -euo pipefail container="$(buildah from "$1")" trap 'buildah unmount "$container" >/dev/null 2>&1 || true; buildah rm "$container" >/dev/null' EXIT mount="$(buildah mount "$container")" install -m 0755 "$mount/out/agent/moshiro-agent" "$mount/out/enroll/fleet-enroll" "$2/" SH