diff --git a/README.md b/README.md index d399b61..43797d0 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Administrator -> System Update UI -> erp-update helper 克隆仓库并进入开发分支: ```bash -git clone git@38.76.196.225:awaioi/ERP.git +git clone https://git.awaioi.com/awaioi/ERP.git cd ERP git switch dev git config core.hooksPath .githooks @@ -111,7 +111,7 @@ PostgreSQL-only 正式构建: ```bash cd oa-backend -./gradlew clean bootJar -PreleaseVersion=0.3.7 -PproductionBuild=true +./gradlew clean bootJar -PreleaseVersion=0.3.8 -PproductionBuild=true ``` 正式 JAR 必须包含 PostgreSQL 驱动,并且不得包含 `sqlite-jdbc` 或 `hibernate-community-dialects`。 @@ -168,15 +168,14 @@ https://resonant-elated-launder.ngrok-free.dev/ ### Linux 一键安装 -生产环境应先为 Gitea 配置 HTTPS: +官方 Gitea 已启用 HTTPS,Linux 可直接执行: ```bash -curl -fsSL https://git.example.com/awaioi/ERP/raw/branch/main/install.sh \ - | sudo -E bash -s -- \ - --gitea-url https://git.example.com \ - --repository awaioi/ERP +curl -fsSL https://git.awaioi.com/awaioi/ERP/raw/branch/main/install.sh | sudo -E bash ``` +安装器默认使用 `https://git.awaioi.com` 和 `awaioi/ERP`;私有镜像或分叉仓库仍可通过 `--gitea-url` 和 `--repository` 覆盖。 + 命令行只做环境准备:优先使用已有的 Java 17+,缺少时通过当前系统的 `apt-get`、`dnf`、`yum`、`zypper` 或 Homebrew 安装 Java、curl、tar、Python 3 和 OpenSSL 3,然后下载并启动独立安装器。数据库信息不在命令行输入。 Linux 生产服务要求主机使用 systemd;没有 systemd 的容器、WSL 或精简系统只能显式使用 `--no-service` 做开发验收,在线更新也会保持关闭。 @@ -184,7 +183,7 @@ Linux 生产服务要求主机使用 systemd;没有 systemd 的容器、WSL 安装器启动后会输出带一次性令牌的访问地址。优先级依次为:命令行 `--public-url`(或 `ERP_PUBLIC_URL`)、HTTPS 服务探测到的公网 IP、局域网 IP。无论使用哪一种方式,都会同时输出仅服务器本机可用的 `Local URL`;公网探测失败时还会明确提示正在回退局域网地址。公网服务器建议显式传入地址,避免 NAT、多网卡或代理环境识别错误: ```text -Setup URL: http://38.76.196.225:8091/?token= +Setup URL: https://erp.example.com/?token= Local URL: http://127.0.0.1:8091/?token= ``` @@ -199,33 +198,25 @@ PostgreSQL 必须使用专用空数据库,网页中填写的账号必须是该 macOS 需要 Homebrew,并使用已有 PostgreSQL: ```bash -curl -fsSL https://git.example.com/awaioi/ERP/raw/branch/main/install.sh \ - | bash -s -- \ - --gitea-url https://git.example.com \ - --repository awaioi/ERP +curl -fsSL https://git.awaioi.com/awaioi/ERP/raw/branch/main/install.sh | bash ``` -### 当前 HTTP 测试服务器 +### 当前正式版本 -当前 Gitea 地址 `http://38.76.196.225:10099` 只允许用于开发验收: +需要固定安装 `v0.3.8` 并验证引导脚本 SHA-256 时: ```bash ( set -e tmp="$(mktemp)" trap 'rm -f -- "$tmp"' EXIT - curl -fsSL http://38.76.196.225:10099/awaioi/ERP/raw/tag/v0.3.7/install.sh -o "$tmp" - printf '%s %s\n' '88328b3086ece360d3c05d4a22bee06b03ed3639a454c1fe7b9c04b1da80a980' "$tmp" | sha256sum -c - - sudo -E bash "$tmp" \ - --gitea-url http://38.76.196.225:10099 \ - --repository awaioi/ERP \ - --version 0.3.7 \ - --public-url http://38.76.196.225:8091 \ - --allow-insecure + curl -fsSL https://git.awaioi.com/awaioi/ERP/raw/tag/v0.3.8/install.sh -o "$tmp" + printf '%s %s\n' '716f6a9ea75659be3c7162d031f1b1fe5e8aa0e82e0101296153842dff9b35d6' "$tmp" | sha256sum -c - + sudo -E bash "$tmp" --version 0.3.8 ) ``` -只有 `v0.3.7` Release 发布后这条命令才可下载安装包。固定 tag 和 SHA-256 只用于保护当前 HTTP 引导脚本不被传输途中篡改;Release 资产仍会继续执行 Ed25519 和 SHA-256 双重校验。HTTP 会暴露请求、Release 元数据和可能使用的访问令牌,不得作为长期生产方案。 +只有 `v0.3.8` Release 发布后这条命令才可下载安装包。引导脚本通过固定 tag 和 SHA-256 校验,Release 资产继续执行 Ed25519 和 SHA-256 双重校验。 ### 完整卸载后重装 @@ -236,7 +227,7 @@ curl -fsSL https://git.example.com/awaioi/ERP/raw/branch/main/install.sh \ set -e tmp="$(mktemp)" trap 'rm -f -- "$tmp"' EXIT - curl -fsSL http://38.76.196.225:10099/awaioi/ERP/raw/tag/v0.3.7/uninstall.sh -o "$tmp" + curl -fsSL https://git.awaioi.com/awaioi/ERP/raw/tag/v0.3.8/uninstall.sh -o "$tmp" printf '%s %s\n' '98c56fed2fd4d01874e4ab5a1a4f3ec42ec3e29b315ffd87385a95488d587546' "$tmp" | sha256sum -c - sudo -E bash "$tmp" --purge-database --yes ) @@ -291,7 +282,7 @@ location / { 入口只对 `ADMIN` 角色显示,对应前端路由为 `/appdev/update`,后端 API 为 `/api/oa/system-update/*`。页面只显示当前版本、在线最新版本、检查时间、最新版本更新日志、历史正式版本,以及下载、验签、安装、重启和自动回滚进度。顶部和手机入口发现新版本时会显示版本提示。 -更新源由安装器写入服务器的 `/etc/kaidi-erp/erp.env`,后台页面不会要求管理员重复填写 Gitea 地址、仓库、Token、通道或 HTTP 开关。需要变更基础设施配置时由服务器运维人员修改 `OA_UPDATE_*` 环境变量并重启服务;公开仓库无需 Token,正式环境应使用 HTTPS。 +更新源由安装器写入服务器的 `/etc/kaidi-erp/erp.env`,后台页面不会要求管理员重复填写 Gitea 地址、仓库、Token、通道或 HTTP 开关。`v0.3.8` 启动时会把旧官方地址 `http://38.76.196.225:10099` 自动迁移到 `https://git.awaioi.com`;其他自定义地址保持不变。需要变更基础设施配置时由服务器运维人员修改 `OA_UPDATE_*` 环境变量并重启服务;公开仓库无需 Token,正式环境应使用 HTTPS。 更新过程如下: @@ -307,7 +298,7 @@ location / { 同一安装目录使用操作系统文件锁,不能并发执行两个更新任务。也可以手工触发: ```bash -/opt/kaidi-erp/current/bin/erp-update install 0.3.7 +/opt/kaidi-erp/current/bin/erp-update install 0.3.8 ``` 应用回滚不等于数据库回滚。包含不可逆 Flyway 迁移的版本必须先保证旧应用仍兼容新结构,并建议在安装配置中启用: @@ -335,7 +326,7 @@ Gitea 1.27 仓库需要启用 Actions,并配置带 `ubuntu-latest` 标签的 流水线使用 Gitea 内置短期 `GITEA_TOKEN`,权限限定为代码只读、当前仓库 Release 可写。仓库设置只需添加: - Secret `RELEASE_PRIVATE_KEY_B64` -- 当前纯 HTTP 测试服务器额外添加 Variable `ERP_RELEASE_ALLOW_INSECURE_HTTP=1`(Gitea 禁止变量名以保留前缀 `GITEA_` 或 `GITHUB_` 开头) +- `ERP_RELEASE_ALLOW_INSECURE_HTTP` 保持未设置;正式 Release API 和资产下载固定使用 HTTPS 签名私钥不得提交到 Git。生成 Secret 值: @@ -348,8 +339,8 @@ base64 < ~/.config/kaidi-erp/release-signing-key.pem | tr -d '\n' ```bash git switch main git pull --ff-only origin main -git tag -a v0.3.7 -m 'Kaidi ERP v0.3.7' -git push origin v0.3.7 +git tag -a v0.3.8 -m 'Kaidi ERP v0.3.8' +git push origin v0.3.8 ``` 发布完成后必须确认 Release 页面存在四个资产,并使用仓库中的 `distribution/release-public-key.pem` 验证签名。私钥与该公钥不匹配时打包脚本会直接失败。 @@ -358,7 +349,7 @@ git push origin v0.3.7 ```bash ERP_RELEASE_PRIVATE_KEY_FILE="$HOME/.config/kaidi-erp/release-signing-key.pem" \ - bash scripts/package-release.sh 0.3.7 + bash scripts/package-release.sh 0.3.8 ``` ## 配置参考 @@ -372,7 +363,7 @@ ERP_RELEASE_PRIVATE_KEY_FILE="$HOME/.config/kaidi-erp/release-signing-key.pem" \ | `OA_DB_POOL_MAX` | 最大连接池 | `20` | | `OA_DB_POOL_MIN` | 最小空闲连接 | `2` | | `OA_UPDATE_ENABLED` | 启用管理后台在线更新 | 安装服务时为 `true` | -| `OA_UPDATE_GITEA_BASE_URL` | Gitea 外部地址 | 正式安装时写入 | +| `OA_UPDATE_GITEA_BASE_URL` | Gitea 外部地址 | `https://git.awaioi.com` | | `OA_UPDATE_REPOSITORY` | Release 仓库 | `awaioi/ERP` | | `OA_UPDATE_CHANNEL` | 更新通道 | `stable` | | `OA_UPDATE_TOKEN` | 私有仓库下载令牌 | 空;公开仓库不需要 | @@ -467,7 +458,7 @@ Gitea 仓库尚未发布首个可安装版本,或 Release 缺少四个必需 远程仓库: ```text -git@38.76.196.225:awaioi/ERP.git +https://git.awaioi.com/awaioi/ERP.git ``` ## 延伸文档 diff --git a/distribution/bin/erp-run b/distribution/bin/erp-run index f219b0f..8658ff9 100755 --- a/distribution/bin/erp-run +++ b/distribution/bin/erp-run @@ -8,6 +8,44 @@ CONFIG_FILE="${ERP_CONFIG_FILE:-$INSTALL_ROOT/config/erp.env}" say() { printf '[ERP] %s\n' "$*"; } fail() { printf '[ERP] ERROR: %s\n' "$*" >&2; exit 1; } +migrate_legacy_update_source() { + local legacy_url='http://38.76.196.225:10099' + local official_url='https://git.awaioi.com' + local configured_url="${OA_UPDATE_GITEA_BASE_URL:-}" + [[ "${configured_url%/}" == "$legacy_url" ]] || return 0 + + local temporary + temporary="$(mktemp "${CONFIG_FILE}.migration.XXXXXX")" \ + || fail 'unable to create the update-source migration file' + if awk -v official_url="$official_url" ' + BEGIN { base_url_written = 0; insecure_written = 0 } + /^OA_UPDATE_GITEA_BASE_URL=/ { + if (!base_url_written) print "OA_UPDATE_GITEA_BASE_URL=\047" official_url "\047" + base_url_written = 1 + next + } + /^OA_UPDATE_ALLOW_INSECURE_HTTP=/ { + if (!insecure_written) print "OA_UPDATE_ALLOW_INSECURE_HTTP=\047false\047" + insecure_written = 1 + next + } + { print } + END { + if (!base_url_written) print "OA_UPDATE_GITEA_BASE_URL=\047" official_url "\047" + if (!insecure_written) print "OA_UPDATE_ALLOW_INSECURE_HTTP=\047false\047" + } + ' "$CONFIG_FILE" > "$temporary" && chmod 600 "$temporary" && mv -f "$temporary" "$CONFIG_FILE"; then + say "Update source migrated to $official_url" + else + rm -f "$temporary" + say "WARNING: could not persist the update source migration; using $official_url for this process" + fi + + OA_UPDATE_GITEA_BASE_URL="$official_url" + OA_UPDATE_ALLOW_INSECURE_HTTP=false + export OA_UPDATE_GITEA_BASE_URL OA_UPDATE_ALLOW_INSECURE_HTTP +} + load_configuration() { [[ -r "$CONFIG_FILE" ]] || fail "configuration not readable: $CONFIG_FILE" set -a @@ -15,6 +53,7 @@ load_configuration() { # shellcheck disable=SC1090 source "$CONFIG_FILE" set +a + migrate_legacy_update_source RUN_DIR="${ERP_RUN_DIR:-$INSTALL_ROOT/run}" JAR_PATH="${ERP_JAR_PATH:-$INSTALL_ROOT/current/app/kaidi-erp.jar}" diff --git a/distribution/bin/erp-update b/distribution/bin/erp-update index 2725c5d..b450f8e 100755 --- a/distribution/bin/erp-update +++ b/distribution/bin/erp-update @@ -25,6 +25,10 @@ REPOSITORY="${OA_UPDATE_REPOSITORY:-awaioi/ERP}" CHANNEL="${OA_UPDATE_CHANNEL:-stable}" TOKEN="${OA_UPDATE_TOKEN:-}" ALLOW_INSECURE="${OA_UPDATE_ALLOW_INSECURE_HTTP:-false}" +if [[ "${GITEA_BASE_URL%/}" == "http://38.76.196.225:10099" ]]; then + GITEA_BASE_URL="https://git.awaioi.com" + ALLOW_INSECURE=false +fi PUBLIC_KEY_FILE="${ERP_UPDATE_PUBLIC_KEY_FILE:-$INSTALL_ROOT/config/release-public-key.pem}" REQUIRE_SIGNATURE="${ERP_UPDATE_REQUIRE_SIGNATURE:-true}" BACKUP_MODE="${ERP_UPDATE_BACKUP_MODE:-none}" diff --git a/docs/online-install-and-update.md b/docs/online-install-and-update.md index 33f1a2d..27f6462 100644 --- a/docs/online-install-and-update.md +++ b/docs/online-install-and-update.md @@ -16,7 +16,7 @@ Gitea Actions runner 需要预装 Java 17 或更高版本、Node.js/npm、Python 流水线使用 Gitea 1.27 提供的短期 `GITEA_TOKEN`,权限限定为代码只读、当前仓库 Release 可写,不需要创建个人访问令牌。仓库 Actions 设置只需创建: - Secret `RELEASE_PRIVATE_KEY_B64`:Ed25519 私钥的单行 Base64 内容。 -- Variable `ERP_RELEASE_ALLOW_INSECURE_HTTP`:生产环境不要设置;当前 HTTP 测试服务器必须显式设为 `1`。Gitea 不允许仓库变量名以保留前缀 `GITEA_` 或 `GITHUB_` 开头。 +- Variable `ERP_RELEASE_ALLOW_INSECURE_HTTP`:正式 HTTPS 服务器保持未设置;仅隔离的 HTTP 开发镜像才允许设为 `1`。Gitea 不允许仓库变量名以保留前缀 `GITEA_` 或 `GITHUB_` 开头。 本机现有签名私钥位于 `~/.config/kaidi-erp/release-signing-key.pem`,不得提交到 Git。macOS 可用以下命令生成 Secret 值: @@ -29,43 +29,38 @@ base64 < ~/.config/kaidi-erp/release-signing-key.pem | tr -d '\n' ```bash git switch main git pull --ff-only origin main -git tag -a v0.3.7 -m 'Kaidi ERP v0.3.7' -git push origin v0.3.7 +git tag -a v0.3.8 -m 'Kaidi ERP v0.3.8' +git push origin v0.3.8 ``` ## 首次安装 -推荐给 Gitea 配置 HTTPS 域名,然后执行: +官方 Gitea 已启用 HTTPS,Linux 可直接执行: ```bash -curl -fsSL https://git.example.com/awaioi/ERP/raw/branch/main/install.sh \ - | sudo -E bash -s -- \ - --gitea-url https://git.example.com \ - --repository awaioi/ERP +curl -fsSL https://git.awaioi.com/awaioi/ERP/raw/branch/main/install.sh | sudo -E bash ``` 命令行只检查并安装 Java 17+、curl、tar、Python 3 和 OpenSSL 3,然后启动独立安装器并输出带一次性 token 的网页地址。数据库、管理员和密码全部在首次网页向导填写;安装器会真实测试 PostgreSQL 15+、数据库所有权、`public` schema 建表权限和 `pg_trgm` 所有权,迁移完成并确认正式服务健康后才写 `install.lock`,随后物理删除安装器目录。 -安装地址优先使用 `--public-url`(或 `ERP_PUBLIC_URL`);未指定时依次尝试探测公网 IP、回退局域网 IP,并始终额外输出 `Local URL`。公网服务器建议显式传入例如 `--public-url http://38.76.196.225:8091`。参数支持 HTTPS 域名、端口、路径和已有查询参数,安装器会安全追加 token,不会用局域网 IP 覆盖显式公网地址。 +安装器默认从 `https://git.awaioi.com/awaioi/ERP` 获取签名 Release。安装地址优先使用 `--public-url`(或 `ERP_PUBLIC_URL`);未指定时依次尝试探测公网 IP、回退局域网 IP,并始终额外输出 `Local URL`。ERP 已绑定独立业务域名时可显式传入例如 `--public-url https://erp.example.com`。参数支持 HTTPS 域名、端口、路径和已有查询参数,安装器会安全追加 token,不会用局域网 IP 覆盖显式公网地址。 目标 PostgreSQL 必须是专用空数据库,网页中填写的账号必须是该数据库的所有者。只拥有连接权限的账号会在网页连接测试阶段被拒绝,不再等到 Flyway 迁移后才显示笼统错误。 Linux 生产服务要求主机使用 systemd;没有 systemd 的容器、WSL 或精简系统只能显式使用 `--no-service` 做开发验收,在线更新也会保持关闭。 -当前 `http://38.76.196.225:10099` 仅用于开发测试,安装器必须同时传入 `--allow-insecure`。在没有 HTTPS 的情况下,必须从固定 tag 下载引导脚本并验证本版本记录的 SHA-256,禁止把可变的 `main` 分支脚本直接管道给 root。HTTP 仍会暴露请求、Release 元数据和 Gitea token,不应作为生产部署方式。 +正式安装和更新不得启用 `--allow-insecure`。需要锁定版本时,应从固定 tag 下载引导脚本并验证本版本记录的 SHA-256。 -当前 `v0.3.7` 安装命令: +当前 `v0.3.8` 安装命令: ```bash ( set -e tmp="$(mktemp)" trap 'rm -f -- "$tmp"' EXIT - curl -fsSL http://38.76.196.225:10099/awaioi/ERP/raw/tag/v0.3.7/install.sh -o "$tmp" - printf '%s %s\n' '88328b3086ece360d3c05d4a22bee06b03ed3639a454c1fe7b9c04b1da80a980' "$tmp" | sha256sum -c - - sudo -E bash "$tmp" --gitea-url http://38.76.196.225:10099 \ - --repository awaioi/ERP --version 0.3.7 \ - --public-url http://38.76.196.225:8091 --allow-insecure + curl -fsSL https://git.awaioi.com/awaioi/ERP/raw/tag/v0.3.8/install.sh -o "$tmp" + printf '%s %s\n' '716f6a9ea75659be3c7162d031f1b1fe5e8aa0e82e0101296153842dff9b35d6' "$tmp" | sha256sum -c - + sudo -E bash "$tmp" --version 0.3.8 ) ``` @@ -76,7 +71,7 @@ Linux 生产服务要求主机使用 systemd;没有 systemd 的容器、WSL set -e tmp="$(mktemp)" trap 'rm -f -- "$tmp"' EXIT - curl -fsSL http://38.76.196.225:10099/awaioi/ERP/raw/tag/v0.3.7/uninstall.sh -o "$tmp" + curl -fsSL https://git.awaioi.com/awaioi/ERP/raw/tag/v0.3.8/uninstall.sh -o "$tmp" printf '%s %s\n' '98c56fed2fd4d01874e4ab5a1a4f3ec42ec3e29b315ffd87385a95488d587546' "$tmp" | sha256sum -c - sudo -E bash "$tmp" --purge-database --yes ) @@ -88,7 +83,7 @@ Linux 生产服务要求主机使用 systemd;没有 systemd 的容器、WSL 管理员可从顶部工具栏、用户菜单、手机导航抽屉或“应用定制平台 -> 系统更新”进入 `/appdev/update`。入口只对 `ADMIN` 角色显示;发现新版本时顶部和手机入口会显示版本提示。 -更新源由首次安装器写入 `ERP_CONFIG_FILE` 指向的 `erp.env`。更新页面不会要求管理员重复填写 Gitea 地址、仓库、Token、通道或 HTTP 开关;需要变更这些基础设施参数时,由服务器运维人员修改 `OA_UPDATE_*` 环境变量并重启服务。 +更新源由首次安装器写入 `ERP_CONFIG_FILE` 指向的 `erp.env`。更新页面不会要求管理员重复填写 Gitea 地址、仓库、Token、通道或 HTTP 开关。`v0.3.8` 会把旧官方 HTTP 地址自动迁移到 `https://git.awaioi.com`,但不会覆盖其他自定义源;需要变更基础设施参数时,由服务器运维人员修改 `OA_UPDATE_*` 环境变量并重启服务。 点击“检查更新”后,页面会展示当前版本、在线最新版本、发布日期、最新版本更新日志和历史正式版本记录。点击“安装并重启”后持续显示下载、验签、安装、重启和回滚进度;服务重启短暂断开期间页面会自动重连。后端启动独立更新助手,更新助手会: @@ -101,7 +96,7 @@ Linux 生产服务要求主机使用 systemd;没有 systemd 的容器、WSL 更新过程使用操作系统文件锁,同一安装目录同时只允许一个更新任务。手动触发可执行: ```bash -/opt/kaidi-erp/current/bin/erp-update install 0.3.7 +/opt/kaidi-erp/current/bin/erp-update install 0.3.8 ``` 在线更新依赖安装器注册的 systemd 或 launchd 服务来拉起新旧版本。使用 `--no-service` 时后台更新默认关闭;如由其他进程管理器接管,须先确认它会在 ERP 进程退出后自动重启,再手工启用 `OA_UPDATE_ENABLED=true`。健康检查默认最多等待 120 秒、每 2 秒轮询一次,可分别通过 `ERP_UPDATE_HEALTH_TIMEOUT_SECONDS` 和 `ERP_UPDATE_HEALTH_POLL_SECONDS` 调整。 diff --git a/install.sh b/install.sh index fdb48d2..a76bfa4 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -GITEA_BASE_URL="${ERP_GITEA_BASE_URL:-}" +GITEA_BASE_URL="${ERP_GITEA_BASE_URL:-https://git.awaioi.com}" REPOSITORY="${ERP_UPDATE_REPOSITORY:-awaioi/ERP}" REQUESTED_VERSION="${ERP_INSTALL_VERSION:-}" INSTALL_ROOT="${ERP_INSTALL_ROOT:-}" @@ -20,7 +20,7 @@ fail() { printf '[ERP Install] ERROR: %s\n' "$*" >&2; exit 1; } usage() { cat <<'EOF' Usage: install.sh [options] - --gitea-url URL Gitea public base URL + --gitea-url URL Gitea public base URL (default: https://git.awaioi.com) --repository O/R Release repository (default: awaioi/ERP) --version VERSION Install one exact stable release --install-root PATH Override installation directory diff --git a/oa-backend/src/installer/java/com/kaidi/oa/install/InstallerService.java b/oa-backend/src/installer/java/com/kaidi/oa/install/InstallerService.java index 4b8006a..32deb9c 100644 --- a/oa-backend/src/installer/java/com/kaidi/oa/install/InstallerService.java +++ b/oa-backend/src/installer/java/com/kaidi/oa/install/InstallerService.java @@ -409,7 +409,7 @@ public class InstallerService { values.put("OA_DB_POOL_MIN", environment("OA_DB_POOL_MIN", "2")); values.put("OA_SEED_DEMO", "false"); values.put("OA_UPDATE_ENABLED", environment("OA_UPDATE_ENABLED", "true")); - values.put("OA_UPDATE_GITEA_BASE_URL", environment("OA_UPDATE_GITEA_BASE_URL", "")); + values.put("OA_UPDATE_GITEA_BASE_URL", environment("OA_UPDATE_GITEA_BASE_URL", "https://git.awaioi.com")); values.put("OA_UPDATE_REPOSITORY", environment("OA_UPDATE_REPOSITORY", "awaioi/ERP")); values.put("OA_UPDATE_CHANNEL", environment("OA_UPDATE_CHANNEL", "stable")); values.put("OA_UPDATE_TOKEN", environment("OA_UPDATE_TOKEN", "")); diff --git a/oa-backend/src/main/java/com/kaidi/oa/config/UpdateProperties.java b/oa-backend/src/main/java/com/kaidi/oa/config/UpdateProperties.java index 37318de..b47e139 100644 --- a/oa-backend/src/main/java/com/kaidi/oa/config/UpdateProperties.java +++ b/oa-backend/src/main/java/com/kaidi/oa/config/UpdateProperties.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component; public class UpdateProperties { private boolean enabled; - private String giteaBaseUrl = ""; + private String giteaBaseUrl = "https://git.awaioi.com"; private String repository = "awaioi/ERP"; private String channel = "stable"; private String token = ""; diff --git a/oa-backend/src/main/resources/application.yml b/oa-backend/src/main/resources/application.yml index 7726495..3ccfba0 100644 --- a/oa-backend/src/main/resources/application.yml +++ b/oa-backend/src/main/resources/application.yml @@ -64,7 +64,7 @@ oa: model: claude-haiku-4-5-20251001 update: enabled: ${OA_UPDATE_ENABLED:false} - gitea-base-url: ${OA_UPDATE_GITEA_BASE_URL:} + gitea-base-url: ${OA_UPDATE_GITEA_BASE_URL:https://git.awaioi.com} repository: ${OA_UPDATE_REPOSITORY:awaioi/ERP} channel: ${OA_UPDATE_CHANNEL:stable} token: ${OA_UPDATE_TOKEN:} diff --git a/oa-backend/src/test/java/com/kaidi/oa/service/SystemUpdateConfigServiceTest.java b/oa-backend/src/test/java/com/kaidi/oa/service/SystemUpdateConfigServiceTest.java index 42bce13..b85fb97 100644 --- a/oa-backend/src/test/java/com/kaidi/oa/service/SystemUpdateConfigServiceTest.java +++ b/oa-backend/src/test/java/com/kaidi/oa/service/SystemUpdateConfigServiceTest.java @@ -35,7 +35,7 @@ class SystemUpdateConfigServiceTest { SystemUpdateConfigService.UpdateConfig saved = service.save( new SystemUpdateConfigService.UpdateConfigRequest( true, - "http://38.76.196.225:10099/", + "http://gitea.internal.test:10099/", "awaioi/ERP", "stable", "new-token_123", @@ -44,7 +44,7 @@ class SystemUpdateConfigServiceTest { String persisted = Files.readString(configFile); assertThat(persisted).contains("OA_DB_PASSWORD='keep-this-secret'"); - assertThat(persisted).contains("OA_UPDATE_GITEA_BASE_URL='http://38.76.196.225:10099'"); + assertThat(persisted).contains("OA_UPDATE_GITEA_BASE_URL='http://gitea.internal.test:10099'"); assertThat(persisted).contains("OA_UPDATE_TOKEN='new-token_123'"); assertThat(saved.tokenConfigured()).isTrue(); assertThat(saved.toString()).doesNotContain("new-token_123"); diff --git a/r b/r index adbdb4d..fc5c682 100755 --- a/r +++ b/r @@ -1,9 +1,9 @@ #!/usr/bin/env bash set -Eeuo pipefail -TARGET=/root/kaidi-erp-reinstall-v031.sh -URL=http://38.76.196.225:10099/awaioi/ERP/raw/tag/recovery-v0.3.1-1/reinstall-centos9.sh -SHA256=0370fb17926f3b53d5ae849310fdc6cbbf019150415365a464b0972b8edf5d9a +TARGET=/root/kaidi-erp-reinstall-v038.sh +URL=https://git.awaioi.com/awaioi/ERP/raw/tag/v0.3.8/reinstall-centos9.sh +SHA256=77c21df88b23596ce0b0ffd40c1eb341c7a0653871cdd359ef13af22c6ffe8c4 curl -fsSL --connect-timeout 15 --max-time 300 "$URL" -o "$TARGET" printf '%s %s\n' "$SHA256" "$TARGET" | sha256sum -c - diff --git a/reinstall-centos9.sh b/reinstall-centos9.sh index 7fae8ea..479945f 100755 --- a/reinstall-centos9.sh +++ b/reinstall-centos9.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash set -Eeuo pipefail -GITEA_BASE_URL="http://38.76.196.225:10099" +GITEA_BASE_URL="https://git.awaioi.com" REPOSITORY="awaioi/ERP" -VERSION="0.3.4" +VERSION="0.3.8" TAG="v${VERSION}" -INSTALL_SHA256="89a3c45e76f500c9475cb596ea29e3518bfafdc59f36dd3c7b316ed3cdd0448c" +INSTALL_SHA256="716f6a9ea75659be3c7162d031f1b1fe5e8aa0e82e0101296153842dff9b35d6" UNINSTALL_SHA256="98c56fed2fd4d01874e4ab5a1a4f3ec42ec3e29b315ffd87385a95488d587546" PG_ROOT="${ERP_RECOVERY_PG_ROOT:-/www/server/pgsql}" PG_DATA="${ERP_RECOVERY_PG_DATA:-/www/server/pgsql/data}" @@ -96,8 +96,7 @@ main() { bash "$installer" \ --gitea-url "$GITEA_BASE_URL" \ --repository "$REPOSITORY" \ - --version "$VERSION" \ - --allow-insecure + --version "$VERSION" } if [[ "${BASH_SOURCE[0]:-$0}" == "$0" ]]; then diff --git a/setup-gitea-runner.sh b/setup-gitea-runner.sh index 47fe94b..3130950 100755 --- a/setup-gitea-runner.sh +++ b/setup-gitea-runner.sh @@ -2,7 +2,7 @@ set -Eeuo pipefail -GITEA_URL="${GITEA_URL:-http://38.76.196.225:10099/}" +GITEA_URL="${GITEA_URL:-https://git.awaioi.com/}" GITEA_REPOSITORY="${GITEA_REPOSITORY:-awaioi/ERP}" RUNNER_IMAGE="${RUNNER_IMAGE:-}" RUNNER_CONTAINER="${RUNNER_CONTAINER:-gitea-runner}" diff --git a/tests/release-scripts.test.sh b/tests/release-scripts.test.sh index 6892488..042bd8e 100755 --- a/tests/release-scripts.test.sh +++ b/tests/release-scripts.test.sh @@ -56,6 +56,34 @@ test_erp_run_preserves_java_option_arguments() ( grep -Fqx -- "$tmp/current/app/kaidi-erp.jar" <<< "$output" ) +test_erp_run_migrates_legacy_update_source() ( + local tmp + tmp="$(mktemp -d "${TMPDIR:-/tmp}/erp-source-migration.XXXXXX")" || return 1 + trap 'rm -rf "$tmp"' EXIT + mkdir -p "$tmp/current/app" "$tmp/run" "$tmp/state" + : > "$tmp/current/app/kaidi-erp.jar" + : > "$tmp/state/install.lock" + printf '%s\n' \ + '#!/usr/bin/env bash' \ + 'if [[ "${1:-}" == "-version" ]]; then printf '\''openjdk version "17.0.12"\n'\'' >&2; fi' \ + 'exit 0' > "$tmp/java" + chmod +x "$tmp/java" + { + printf 'ERP_JAVA_BIN=%q\n' "$tmp/java" + printf 'ERP_RUN_DIR=%q\n' "$tmp/run" + printf "OA_UPDATE_GITEA_BASE_URL='http://38.76.196.225:10099/'\n" + printf "OA_UPDATE_ALLOW_INSECURE_HTTP='true'\n" + } > "$tmp/erp.env" + chmod 600 "$tmp/erp.env" + + ERP_INSTALL_ROOT="$tmp" ERP_CONFIG_FILE="$tmp/erp.env" \ + "$PROJECT_ROOT/distribution/bin/erp-run" >/dev/null 2>&1 || return 1 + + grep -Fqx "OA_UPDATE_GITEA_BASE_URL='https://git.awaioi.com'" "$tmp/erp.env" || return 1 + grep -Fqx "OA_UPDATE_ALLOW_INSECURE_HTTP='false'" "$tmp/erp.env" || return 1 + ! grep -Fq '38.76.196.225' "$tmp/erp.env" +) + test_erp_run_finalizes_healthy_pending_install() ( local tmp tmp="$(mktemp -d "${TMPDIR:-/tmp}/erp-handoff-success.XXXXXX")" || return 1 @@ -562,17 +590,15 @@ test_installer_moves_database_setup_to_web_wizard() ( [[ "$status" -ne 0 && "$output" == *'unknown option: --db-mode'* ]] ) -test_installer_requires_explicit_gitea_url() ( - local output status=0 +test_installer_defaults_to_official_gitea_url() ( + local output output="$(ERP_GITEA_BASE_URL= bash -c ' root="$1" set -- source "$root/install.sh" - GITEA_BASE_URL= - NO_SERVICE=1 - main - ' _ "$PROJECT_ROOT" 2>&1)" || status=$? - [[ "$status" -ne 0 && "$output" == *'Gitea URL is required'* ]] + printf "%s\n" "$GITEA_BASE_URL" + ' _ "$PROJECT_ROOT")" || return 1 + [[ "$output" == 'https://git.awaioi.com' ]] ) test_linux_service_preflight_requires_systemd() ( @@ -739,7 +765,8 @@ test_release_workflow_uses_scoped_job_token() ( test_installer_runs_when_piped_to_bash() ( local output status=0 - output="$(ERP_GITEA_BASE_URL= bash -s -- --no-service < "$PROJECT_ROOT/install.sh" 2>&1)" || status=$? + output="$(bash -s -- --no-service --gitea-url invalid://example.test \ + < "$PROJECT_ROOT/install.sh" 2>&1)" || status=$? [[ "$status" -ne 0 ]] [[ "$output" == *'[ERP Install] ERROR:'* ]] [[ "$output" != *'BASH_SOURCE'* ]] @@ -763,6 +790,7 @@ test_app_honors_reverse_proxy_headers() ( ) run_test 'erp-run preserves Java option arguments' test_erp_run_preserves_java_option_arguments +run_test 'erp-run migrates the legacy Gitea update source' test_erp_run_migrates_legacy_update_source run_test 'erp-run finalizes a healthy pending installation' test_erp_run_finalizes_healthy_pending_install run_test 'erp-run preserves a failed pending installation' test_erp_run_preserves_failed_pending_install run_test 'installer accepts a correctly signed archive' test_installer_verifies_signed_safe_archive @@ -775,7 +803,7 @@ run_test 'update helper installs a healthy release end to end' test_update_helpe run_test 'update helper rolls back an unhealthy release end to end' test_update_helper_rolls_back_unhealthy_release run_test 'update helper rejects a concurrent process' test_update_lock_rejects_concurrent_process run_test 'installer moves database setup to the web wizard' test_installer_moves_database_setup_to_web_wizard -run_test 'installer requires an explicit Gitea URL' test_installer_requires_explicit_gitea_url +run_test 'installer defaults to the official Gitea URL' test_installer_defaults_to_official_gitea_url run_test 'Linux production install requires systemd' test_linux_service_preflight_requires_systemd run_test 'systemd unit uses compatible protection' test_systemd_unit_uses_compatible_protection run_test 'systemd unit preserves update helper during restart' test_systemd_unit_preserves_update_helper_during_restart