Add Linux and macOS execution commands
Some checks failed
Repo Quality / structure (push) Has been cancelled
Some checks failed
Repo Quality / structure (push) Has been cancelled
This commit is contained in:
44
scripts/run-scenario.sh
Normal file
44
scripts/run-scenario.sh
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user