Add Linux and macOS execution commands
Some checks failed
Repo Quality / structure (push) Has been cancelled

This commit is contained in:
Rodrigo Pace
2026-05-08 12:25:51 -03:00
parent 703e072682
commit 97cab6d894
5 changed files with 184 additions and 8 deletions

44
scripts/run-scenario.sh Normal file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "Usage: $0 <scenario> [connect_string] [sql_client]" >&2
echo "Example: $0 01-ai-prompt-injection 'admin/password@db_high' sql" >&2
}
if [[ $# -lt 1 ]]; then
usage
exit 1
fi
SCENARIO="$1"
CONNECT_STRING="${2:-}"
SQL_CLIENT="${3:-sql}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
SQL_DIR="$REPO_ROOT/scenarios/$SCENARIO/sql"
if [[ ! -d "$SQL_DIR" ]]; then
echo "Scenario SQL directory not found: $SQL_DIR" >&2
exit 1
fi
mapfile -t SCRIPTS < <(find "$SQL_DIR" -maxdepth 1 -type f -name "*.sql" ! -name "99_reset.sql" | sort)
echo "Scenario: $SCENARIO"
echo "Scripts to execute:"
for script in "${SCRIPTS[@]}"; do
echo " - $(basename "$script")"
done
if [[ -z "$CONNECT_STRING" ]]; then
echo "WARNING: Connect string not provided. Review the SQL files above and execute them manually with SQLcl or SQL*Plus." >&2
exit 0
fi
for script in "${SCRIPTS[@]}"; do
echo "Running $script"
"$SQL_CLIENT" "$CONNECT_STRING" "@$script"
done