3grade_1change

This commit is contained in:
caramelteawithmint
2026-12-04 19:26:02 +03:00
parent 4f21a985f7
commit 22886d6314
10 changed files with 388 additions and 32 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/bin/sh
set -eu
echo "Waiting for OpenBao to start..."
sleep 5
INIT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://openbao:8200/v1/sys/init)
if [ "$INIT_STATUS" = "200" ]; then
echo "OpenBao is already initialized. Skipping init."
exit 0
fi
echo "Initializing OpenBao..."
INIT_OUTPUT=$(curl -s -X PUT http://openbao:8200/v1/sys/init -d '{"secret_shares": 1, "secret_threshold": 1}')
ROOT_TOKEN=$(echo "$INIT_OUTPUT" | grep -o '"root_token":"[^"]*' | cut -d'"' -f4)
UNSEAL_KEY=$(echo "$INIT_OUTPUT" | grep -o '"keys":\["[^"]*' | cut -d'"' -f4)
echo "Unsealing OpenBao..."
curl -s -X PUT http://openbao:8200/v1/sys/unseal -d "{\"key\": \"$UNSEAL_KEY\"}" > /dev/null
echo "Writing secrets to OpenBao..."
curl -s -X POST -H "X-Vault-Token: $ROOT_TOKEN" http://openbao:8200/v1/sys/mounts/secret -d '{"type": "kv", "options": {"version": "2"}}' > /dev/null
curl -s -X POST -H "X-Vault-Token: $ROOT_TOKEN" http://openbao:8200/v1/secret/data/messenger -d '{
"data": {
"db_password": "messenger_password",
"s3_access_key": "minioadmin",
"s3_secret_key": "minioadmin",
"broker_url": "amqp://guest:guest@broker:5672/"
}
}' > /dev/null
echo "OpenBao initialization complete."
echo "ROOT_TOKEN=$ROOT_TOKEN"
echo "UNSEAL_KEY=$UNSEAL_KEY"
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
set -eu
echo "Restarting API and Postgres (preserving volumes)..."
docker compose restart api1 api2 postgres
echo "Waiting for Postgres to be healthy..."
sleep 5
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
if [ "$TARGET_INSTANCE_ID" != "api-1" ] && [ "$TARGET_INSTANCE_ID" != "api-2" ]; then
echo "Unknown instance: $TARGET_INSTANCE_ID" >&2
exit 1
fi
SERVICE_NAME="$TARGET_INSTANCE_ID"
if [ "$SERVICE_NAME" = "api-1" ]; then SERVICE_NAME="api1"; fi
if [ "$SERVICE_NAME" = "api-2" ]; then SERVICE_NAME="api2"; fi
echo "Stopping container for $SERVICE_NAME..."
docker compose stop "$SERVICE_NAME"