release: sync public installer asset install.sh
This commit is contained in:
+41
-2
@@ -1046,7 +1046,14 @@ if [[ -n $MENU_PROFILES ]]; then
|
|||||||
if [[ ${XYMEDIA_XIAOYA_MANAGED:-0} == 1 ]]; then
|
if [[ ${XYMEDIA_XIAOYA_MANAGED:-0} == 1 ]]; then
|
||||||
[[ ${XYMEDIA_INSTALL_CONFIRM:-} == INSTALL_XIAOYA ]] || { confirm=$(prompt_tty '安装小雅将创建并启动相关容器,输入 1 继续,其他内容取消: '); [[ $confirm == 1 ]] || die '已取消小雅安装'; }
|
[[ ${XYMEDIA_INSTALL_CONFIRM:-} == INSTALL_XIAOYA ]] || { confirm=$(prompt_tty '安装小雅将创建并启动相关容器,输入 1 继续,其他内容取消: '); [[ $confirm == 1 ]] || die '已取消小雅安装'; }
|
||||||
fi
|
fi
|
||||||
for profile in $MENU_PROFILES; do run_logged "${COMPOSE[@]}" --profile "$profile" --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" up -d || die "小雅 profile 启动失败:$profile"; done
|
for profile in $MENU_PROFILES; do
|
||||||
|
case "$profile" in
|
||||||
|
xiaoya) profile_service=xiaoya-alist;;
|
||||||
|
xiaoya-control) profile_service=xiaoya-control;;
|
||||||
|
*) die "未知小雅 profile:$profile";;
|
||||||
|
esac
|
||||||
|
run_logged "${COMPOSE[@]}" --profile "$profile" --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" up -d --no-deps "$profile_service" || die "小雅 profile 启动失败:$profile"
|
||||||
|
done
|
||||||
if [[ $MENU_PROFILES == *xiaoya-control* ]]; then
|
if [[ $MENU_PROFILES == *xiaoya-control* ]]; then
|
||||||
controller_state=$(docker inspect --format '{{.State.Status}}' xymedia-controller 2>>"$INSTALL_LOG" || true)
|
controller_state=$(docker inspect --format '{{.State.Status}}' xymedia-controller 2>>"$INSTALL_LOG" || true)
|
||||||
[[ $controller_state == running ]] || die '本机小雅控制器未正常运行'
|
[[ $controller_state == running ]] || die '本机小雅控制器未正常运行'
|
||||||
@@ -1057,7 +1064,7 @@ progress '下载 bootstrap runtime'
|
|||||||
if ! run_logged "${COMPOSE[@]}" --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" "${COMPOSE_FUSE[@]}" pull app; then
|
if ! run_logged "${COMPOSE[@]}" --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" "${COMPOSE_FUSE[@]}" pull app; then
|
||||||
die 'bootstrap runtime 下载失败;请确认能访问 git.keeper.work Container Registry'
|
die 'bootstrap runtime 下载失败;请确认能访问 git.keeper.work Container Registry'
|
||||||
fi
|
fi
|
||||||
progress '启动 PostgreSQL'
|
progress '准备 PostgreSQL 连接'
|
||||||
if (( LOCAL_DB )); then
|
if (( LOCAL_DB )); then
|
||||||
if ! run_logged "${COMPOSE[@]}" --profile local-db --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" up -d postgres; then
|
if ! run_logged "${COMPOSE[@]}" --profile local-db --project-directory "$INSTALL_DIR" --env-file "$INSTALL_DIR/.env" -f "$INSTALL_DIR/compose.yaml" up -d postgres; then
|
||||||
die 'PostgreSQL 启动失败'
|
die 'PostgreSQL 启动失败'
|
||||||
@@ -1101,6 +1108,38 @@ if (( LOCAL_DB )); then
|
|||||||
}
|
}
|
||||||
wait_for_postgres || die 'PostgreSQL 等待被中断,安装未完成'
|
wait_for_postgres || die 'PostgreSQL 等待被中断,安装未完成'
|
||||||
fi
|
fi
|
||||||
|
wait_postgres_external() {
|
||||||
|
local started_at elapsed db_network project_name network_name
|
||||||
|
local -a client_command
|
||||||
|
PG_PASSWORD=$(<"$PG_PASSWORD_FILE")
|
||||||
|
[[ -n $PG_PASSWORD ]] || die 'PostgreSQL 密码不能为空'
|
||||||
|
if (( LOCAL_DB )); then
|
||||||
|
db_network=$(docker inspect --format '{{range $network, $config := .NetworkSettings.Networks}}{{$network}}{{"\n"}}{{end}}' xymedia-postgres 2>>"$INSTALL_LOG" | head -n 1)
|
||||||
|
else
|
||||||
|
project_name=${COMPOSE_PROJECT_NAME:-$(basename "$INSTALL_DIR")}
|
||||||
|
network_name="${project_name}_default"
|
||||||
|
db_network=$(docker network ls --filter "label=com.docker.compose.project=$project_name" --format '{{.Name}}' 2>>"$INSTALL_LOG" | head -n 1 || true)
|
||||||
|
if [[ -z $db_network ]]; then
|
||||||
|
db_network=$network_name
|
||||||
|
docker network create --label "com.docker.compose.project=$project_name" --label com.docker.compose.network=default "$db_network" >>"$INSTALL_LOG" 2>&1 || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
[[ -n $db_network ]] || die '无法确定 PostgreSQL 外部连接探测所需的 Compose 网络'
|
||||||
|
started_at=$(date +%s)
|
||||||
|
while :; do
|
||||||
|
client_command=(docker run --rm --network "$db_network" -e "PGPASSWORD=$PG_PASSWORD" postgres:17-bookworm psql -h "$PG_HOST" -p "$PG_PORT" -U "$PG_USER" -d "$PG_DB" -c 'SELECT 1')
|
||||||
|
if "${client_command[@]}" >>"$INSTALL_LOG" 2>&1; then
|
||||||
|
elapsed=$(( $(date +%s) - started_at ))
|
||||||
|
printf '\033[2K\r[%d/%d] PostgreSQL 外部连接已验证(%s 秒)\n' "$STEP" "$TOTAL_STEPS" "$elapsed"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
elapsed=$(( $(date +%s) - started_at ))
|
||||||
|
printf '\033[2K\r[%d/%d] 数据库外部连接仍在等待(%s秒)' "$STEP" "$TOTAL_STEPS" "$elapsed"
|
||||||
|
printf 'PostgreSQL external status: elapsed=%s host=%s port=%s\n' "$elapsed" "$PG_HOST" "$PG_PORT" >>"$INSTALL_LOG"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
}
|
||||||
|
wait_postgres_external || die 'PostgreSQL 外部连接验证失败'
|
||||||
progress '初始化数据库结构'
|
progress '初始化数据库结构'
|
||||||
printf '正在初始化数据库,请稍候...\n'
|
printf '正在初始化数据库,请稍候...\n'
|
||||||
run_migration() {
|
run_migration() {
|
||||||
|
|||||||
Reference in New Issue
Block a user