51 lines
1.1 KiB
Bash
51 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# shellcheck disable=SC1091
|
|
source "${SCRIPT_DIR}/common.sh"
|
|
|
|
STEP="incident-launch"
|
|
incident_id=""
|
|
args=()
|
|
timeout_bin=""
|
|
|
|
while (($# > 0)); do
|
|
case "$1" in
|
|
--incident-id)
|
|
incident_id="${2:-}"
|
|
shift 2
|
|
;;
|
|
*)
|
|
args+=("$1")
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
blitz_load_boot_env
|
|
blitz_require_root "${STEP}"
|
|
blitz_require_command systemd-run "${STEP}"
|
|
blitz_require_command timeout "${STEP}"
|
|
timeout_bin="$(command -v timeout)"
|
|
|
|
if [[ -z "${incident_id}" ]]; then
|
|
incident_id="$(blitz_new_incident_id)"
|
|
fi
|
|
|
|
unit_name="blitz-incident-${incident_id//[^A-Za-z0-9_.-]/-}"
|
|
|
|
systemd-run \
|
|
--quiet \
|
|
--collect \
|
|
--unit "${unit_name}" \
|
|
--property=Type=oneshot \
|
|
--property="StandardOutput=append:${BLITZ_LOG_FILE}" \
|
|
--property="StandardError=append:${BLITZ_LOG_FILE}" \
|
|
"${timeout_bin}" "${BLITZ_INCIDENT_TOTAL_TIMEOUT_SEC}s" \
|
|
/bin/bash "${SCRIPT_DIR}/blitz-incident-capture.sh" \
|
|
--incident-id "${incident_id}" \
|
|
"${args[@]}"
|
|
|
|
printf '%s\n' "${incident_id}"
|