Files
mtusi2026lab7/scripts/bootstrap-local.sh
T
dizi c03e067de8
CI / verify (pull_request) Failing after 1m23s
chore: finalize lab7 security verification
2026-11-06 21:44:48 +03:00

60 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(CDPATH= cd -- "$script_dir/.." && pwd)
env_file=${1:-$repo_dir/lab7.env.example}
if [ ! -f "$env_file" ]; then
echo "environment file not found: $env_file" >&2
exit 2
fi
compose() {
docker compose --project-directory "$repo_dir" --env-file "$env_file" "$@"
}
if [ ! -f "$repo_dir/.runtime/security/openbao/tls.crt" ]; then
"$repo_dir/infra/pki/bootstrap.sh"
fi
"$script_dir/openbao-seed.sh" "$env_file"
"$script_dir/sync-docker-workspace.sh"
compose up -d security-bootstrap openbao-permissions openbao
if [ -z "${BAO_ADDR:-}" ]; then
openbao_address=$(compose port openbao 8200)
BAO_ADDR="https://$openbao_address"
fi
BAO_CACERT="$repo_dir/.runtime/security/openbao/ca.crt"
export BAO_ADDR BAO_CACERT ENV_FILE="$env_file"
remaining=60
until curl --silent --show-error --connect-timeout 2 --max-time 3 --cacert "$BAO_CACERT" \
--output /dev/null "$BAO_ADDR/v1/sys/health"; do
remaining=$((remaining - 1))
[ "$remaining" -gt 0 ] || {
echo "OpenBao did not start" >&2
exit 1
}
sleep 1
done
ENV_FILE="$env_file" "$script_dir/openbao-init.sh"
ENV_FILE="$env_file" "$script_dir/openbao-unseal.sh"
remaining=60
until curl --fail --silent --show-error --connect-timeout 2 --max-time 3 --cacert "$BAO_CACERT" \
--output /dev/null "$BAO_ADDR/v1/sys/health"; do
remaining=$((remaining - 1))
[ "$remaining" -gt 0 ] || {
echo "OpenBao did not become active after unseal" >&2
exit 1
}
sleep 1
done
ENV_FILE="$env_file" "$script_dir/openbao-bootstrap.sh" \
"$repo_dir/.runtime/openbao/seed/api.json" \
"$repo_dir/.runtime/openbao/seed/worker.json"
compose up -d --build --scale api=2 --wait --wait-timeout 240