Files
ecs-relay-service/patch-source/51c062dff81e268e/scripts/update-work1067.sh

41 lines
2.1 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
cd "$root"
test -f .env && test -d wheelhouse && test -f Dockerfile.offline
stamp=$(date +%Y%m%d-%H%M%S)
# Enable automatic issuance using the current test CA, never generate a new CA.
# Only the internal issuer container receives this key; no host port is published.
if [[ ! -f runtime/issuer/ca.key ]]; then
test -f operator/ca.key || { echo 'Existing CA key missing: provide the original CA to the internal issuer first.' >&2; exit 1; }
install -d -m 700 -o 10001 -g 10001 runtime/issuer
install -m 400 -o 10001 -g 10001 operator/ca.key runtime/issuer/ca.key
fi
docker image tag hainuo-relay:0.1.0 "hainuo-relay:before-work1067-$stamp"
docker build --network none --pull=false -f Dockerfile.offline -t hainuo-relay:0.1.0 .
args=(-f compose.yaml)
for override in compose.offline.yaml compose.edge-fix.yaml compose.h5.yaml compose.work.yaml compose.feishu.yaml; do
if [[ -f "$override" ]]; then args+=(-f "$override"); fi
done
args+=(-f compose.autoreg.yaml)
# Bring up signer and verify it before changing the serving connector.
docker compose "${args[@]}" up -d --no-build --pull never --no-deps --force-recreate enrollment-signer
docker compose "${args[@]}" exec -T enrollment-signer python -c 'import time,urllib.request
for attempt in range(30):
try:
urllib.request.urlopen("http://127.0.0.1:8000/ready", timeout=2)
print("Automatic certificate issuer ready")
break
except Exception:
time.sleep(1)
else:
raise SystemExit("Issuer not ready; connector unchanged")'
docker compose "${args[@]}" up -d --no-build --pull never --no-deps --force-recreate connector router
if [[ -n "$(docker compose -f compose.yaml ps -q longconn)" ]]; then
docker compose "${args[@]}" --profile longconn up -d --no-build --pull never --no-deps --force-recreate longconn
fi
docker compose "${args[@]}" ps
echo "Previous image: hainuo-relay:before-work1067-$stamp"
echo 'Automatic registration enabled. New PCs only need a Work binding code; no per-PC approval command.'
echo 'Keep -f compose.autoreg.yaml in future compose up commands.'