release: sync public installer asset install.sh
This commit is contained in:
+27
-1
@@ -368,7 +368,7 @@ menu() {
|
||||
[[ $# -eq 0 ]] || return 0
|
||||
[[ -r $TTY_IN && -w $TTY_OUT ]] || die '没有可用终端:安装菜单不能通过非交互管道运行'
|
||||
while :; do
|
||||
printf '\nXyMediaVault 安装器\n1) 仅安装管理平台\n2) 安装管理平台和本机小雅\n3) 安装管理平台并连接远程小雅控制器\n4) 仅安装小雅控制器\n5) 状态/诊断/维护\n6) 查看小雅控制器地址和密钥\n0) 退出\n选择:' >>$TTY_OUT
|
||||
printf '\nXyMediaVault 安装器\n1) 仅安装管理平台\n2) 安装管理平台和本机小雅\n3) 安装管理平台并连接远程小雅控制器\n4) 仅安装小雅控制器\n5) 状态/诊断/维护\n6) 查看小雅控制器地址和密钥\n7) 查看数据库连接信息\n0) 退出\n选择:' >>$TTY_OUT
|
||||
read_tty choice || die '无法读取终端输入'
|
||||
case "$choice" in
|
||||
1) return 0;;
|
||||
@@ -677,6 +677,24 @@ for _ in iter(int, 1):
|
||||
sock.close()
|
||||
PY
|
||||
}
|
||||
postgres_port_is_owned() {
|
||||
local published
|
||||
published=$(docker inspect --format '{{range $p, $bindings := .NetworkSettings.Ports}}{{if eq $p "5432/tcp"}}{{range $bindings}}{{.HostPort}}{{end}}{{end}}{{end}}' xymedia-postgres 2>/dev/null || true)
|
||||
[[ -n $published && $published == "$PG_PORT" ]]
|
||||
}
|
||||
postgres_port_is_available() {
|
||||
PG_PORT_CHECK=$1 python3 - <<'PY'
|
||||
import os, socket
|
||||
port = int(os.environ['PG_PORT_CHECK'])
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
sock.bind(('0.0.0.0', port))
|
||||
except OSError:
|
||||
raise SystemExit(1)
|
||||
finally:
|
||||
sock.close()
|
||||
PY
|
||||
}
|
||||
random_postgres_user() {
|
||||
python3 - <<'PY'
|
||||
import secrets, string
|
||||
@@ -693,6 +711,14 @@ if (( ! CONTROLLER_ONLY )) && (( ! INSTALL_EXISTING )) && (( ! PG_HOST_CLI )); t
|
||||
PG_USER=$(random_postgres_user) || die '无法生成 PostgreSQL 用户名'
|
||||
LOCAL_DB=1
|
||||
fi
|
||||
if (( ! CONTROLLER_ONLY )) && (( LOCAL_DB )) && (( ! PG_HOST_CLI )); then
|
||||
[[ -n ${XYMEDIA_POSTGRES_PUBLIC_PORT:-} ]] && PG_PORT=$XYMEDIA_POSTGRES_PUBLIC_PORT
|
||||
if ! postgres_port_is_owned && ! postgres_port_is_available "$PG_PORT"; then
|
||||
PG_PORT=$(select_random_postgres_port) || die '无法选择 PostgreSQL 对外端口,请稍后重试'
|
||||
XYMEDIA_POSTGRES_PUBLIC_PORT=$PG_PORT
|
||||
printf '检测到 PostgreSQL 端口被其他服务占用,已改用随机端口:%s\n' "$PG_PORT" >>$TTY_OUT
|
||||
fi
|
||||
fi
|
||||
if (( CONTROLLER_ONLY )) || [[ $MENU_PROFILES == *xiaoya-control* ]]; then
|
||||
if [[ ! -e "$INSTALL_DIR/config/XYMEDIA_HOST_ADDRESSES" ]]; then
|
||||
umask 077
|
||||
|
||||
Reference in New Issue
Block a user