Files
bash-sfx/sfx_header.sh
Max P. 65f26e495a feat: add script for creating self-extracting archives
- Introduces a script to build self-extracting archives with validation
- Includes payload compression, placeholder replacement, and output creation
- Adds a header script to extract and execute the embedded entrypoint
2025-06-15 16:30:03 +02:00

20 lines
363 B
Bash

#!/usr/bin/env bash
set -euo pipefail
TMPDIR="$(mktemp -d "${TMPDIR:-/tmp}/sfx.XXXXXX")"
ARCHIVE_LINE=__ARCHIVE_LINE__
cleanup() {
rm -rf "$TMPDIR"
}
trap cleanup EXIT
tail -n +$ARCHIVE_LINE "$0" | unzstd | tar -xf - -C "$TMPDIR"
ENTRYPOINT="$TMPDIR/__ENTRYPOINT__"
chmod +x "$ENTRYPOINT"
"$ENTRYPOINT" "$@"
exit_code=$?
exit $exit_code
__ARCHIVE_BEGIN__