mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
feat: add test env infra compose, config templates, build/prepare scripts
Former-commit-id: 70b7cd14e81c8f43300638dcd5f9859115e1959a
This commit is contained in:
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
# prepare-services.sh — 解压 tar.gz + 从模板生成配置
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/config/env.sh"
|
||||
|
||||
log_info "Phase 4: Service preparation"
|
||||
mkdir -p "$SERVICE_DIR" "$LOG_DIR"
|
||||
|
||||
# Tarballs to extract
|
||||
TARBALLS=(
|
||||
"$STAR_CENTER/ninca_common_01-ninca_common_backend.tar.gz:ninca-common"
|
||||
"$STAR_CENTER/ninca_common_component_organization_01-ninca_common_component_organization.tar.gz:component-org"
|
||||
"$STAR_CENTER/ninca_common_snap_app_01-ninca_common_snap_app.tar.gz:snap-app"
|
||||
"$STAR_CENTER/ninca_common_vehicle_app_01-ninca_common_vehicle_app.tar.gz:vehicle-app"
|
||||
"$STAR_CENTER/ninca_common_monitor_app_01-ninca_common_monitor_app.tar.gz:monitor-app"
|
||||
"$STAR_CENTER/ninca-person-file-app-V2.9.2_20210216.tar.gz:person-file"
|
||||
)
|
||||
|
||||
for item in "${TARBALLS[@]}"; do
|
||||
tarball="${item%%:*}"
|
||||
svc_name="${item##*:}"
|
||||
svc_dir="$SERVICE_DIR/$svc_name"
|
||||
|
||||
if [[ -d "$svc_dir" ]]; then
|
||||
log_info "Already extracted: $svc_name — skipping"
|
||||
continue
|
||||
fi
|
||||
|
||||
log_info "Extracting $tarball → $svc_dir ..."
|
||||
mkdir -p "$svc_dir"
|
||||
tar -xzf "$tarball" -C "$svc_dir" --strip-components=1
|
||||
log_ok " $svc_name extracted"
|
||||
done
|
||||
|
||||
render_template() {
|
||||
local template="$1"
|
||||
local output="$2"
|
||||
sed \
|
||||
-e "s|__MYSQL_HOST__|$MYSQL_HOST|g" \
|
||||
-e "s|__MYSQL_PORT__|$MYSQL_PORT|g" \
|
||||
-e "s|__REDIS_HOST__|$REDIS_HOST|g" \
|
||||
-e "s|__REDIS_PASS__|$REDIS_PASS|g" \
|
||||
-e "s|__CONSUL_HOST__|$CONSUL_HOST|g" \
|
||||
-e "s|__CONSUL_PORT__|$CONSUL_PORT|g" \
|
||||
-e "s|__KAFKA_HOST__|$KAFKA_HOST|g" \
|
||||
-e "s|__KAFKA_PORT__|$KAFKA_PORT|g" \
|
||||
-e "s|__CRK_HOST__|127.0.0.1|g" \
|
||||
-e "s|__CRK_PORT__|$PORT_CRK_STD|g" \
|
||||
-e "s|__CRK_MGMT_PORT__|$PORT_CRK_MGMT|g" \
|
||||
-e "s|__ALARM_PORT__|$PORT_ALARM|g" \
|
||||
-e "s|__ALARM_MGMT_PORT__|$PORT_ALARM_MGMT|g" \
|
||||
-e "s|__NINCA_COMMON_PORT__|$PORT_NINCA_COMMON|g" \
|
||||
-e "s|__COMPONENT_ORG_PORT__|$PORT_COMPONENT_ORG|g" \
|
||||
"$template" > "$output"
|
||||
}
|
||||
|
||||
# Generate configs for each service
|
||||
render_template "$TEST_ENV_DIR/config/service-templates/elevator-v2.properties" \
|
||||
"$REPO_ROOT/maven-cw-elevator-application/deploy/v2-maven/application-test.properties"
|
||||
log_ok " elevator-v2 config generated"
|
||||
|
||||
render_template "$TEST_ENV_DIR/config/service-templates/crk-std.properties" \
|
||||
"$STAR_CENTER/ninca_crk_std_01-ninca_crk_std_backend/application-test.properties"
|
||||
log_ok " crk-std config generated"
|
||||
|
||||
render_template "$TEST_ENV_DIR/config/service-templates/alarm.properties" \
|
||||
"$STAR_CENTER/ninca_qk_alarm_app_01-ninca_qk_alarm_app/application-test.properties"
|
||||
log_ok " alarm config generated"
|
||||
|
||||
# Generate configs for extracted tarball services
|
||||
if [[ -d "$SERVICE_DIR/ninca-common" ]]; then
|
||||
render_template "$TEST_ENV_DIR/config/service-templates/ninca-common.properties" \
|
||||
"$SERVICE_DIR/ninca-common/application-test.properties"
|
||||
log_ok " ninca-common config generated"
|
||||
fi
|
||||
|
||||
if [[ -d "$SERVICE_DIR/component-org" ]]; then
|
||||
render_template "$TEST_ENV_DIR/config/service-templates/component-org.properties" \
|
||||
"$SERVICE_DIR/component-org/application-test.properties"
|
||||
log_ok " component-org config generated"
|
||||
fi
|
||||
|
||||
log_info "Service preparation complete"
|
||||
Reference in New Issue
Block a user