chore: track version files, docs, web app split, scripts (missed commits from March work)
This commit is contained in:
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BASE_FILE="$ROOT_DIR/VERSION_BASE"
|
||||
SEQ_FILE="$ROOT_DIR/BUILD_SEQ"
|
||||
VER_FILE="$ROOT_DIR/VERSION"
|
||||
|
||||
# 初始化基础版本
|
||||
if [[ ! -f "$BASE_FILE" ]]; then
|
||||
if [[ -f "$VER_FILE" ]]; then
|
||||
cur="$(tr -d ' \n\r\t' < "$VER_FILE")"
|
||||
# 取 +build 之前的基础版本
|
||||
base="${cur%%+build.*}"
|
||||
[[ -z "$base" ]] && base="0.1.0"
|
||||
echo "$base" > "$BASE_FILE"
|
||||
else
|
||||
echo "0.1.0" > "$BASE_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 初始化构建序号
|
||||
if [[ ! -f "$SEQ_FILE" ]]; then
|
||||
echo "0" > "$SEQ_FILE"
|
||||
fi
|
||||
|
||||
base="$(tr -d ' \n\r\t' < "$BASE_FILE")"
|
||||
seq="$(tr -d ' \n\r\t' < "$SEQ_FILE")"
|
||||
|
||||
if ! [[ "$seq" =~ ^[0-9]+$ ]]; then
|
||||
seq=0
|
||||
fi
|
||||
|
||||
seq=$((seq + 1))
|
||||
new_ver="${base}+build.${seq}"
|
||||
|
||||
echo "$seq" > "$SEQ_FILE"
|
||||
echo "$new_ver" > "$VER_FILE"
|
||||
|
||||
echo "$new_ver"
|
||||
Executable
+117
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
EXPECTED_VERSION="$(tr -d ' \n\r\t' < "$ROOT_DIR/VERSION")"
|
||||
REPORT_DIR="$ROOT_DIR/run/deploy-check"
|
||||
TS="$(date +%Y%m%d-%H%M%S)"
|
||||
REPORT="$REPORT_DIR/deploy-check-$TS.txt"
|
||||
|
||||
mkdir -p "$REPORT_DIR"
|
||||
|
||||
pass() { echo "[PASS] $*" | tee -a "$REPORT"; }
|
||||
fail() { echo "[FAIL] $*" | tee -a "$REPORT"; FAIL_COUNT=$((FAIL_COUNT+1)); }
|
||||
info() { echo "[INFO] $*" | tee -a "$REPORT"; }
|
||||
|
||||
FAIL_COUNT=0
|
||||
|
||||
info "root=$ROOT_DIR"
|
||||
info "expected_version=$EXPECTED_VERSION"
|
||||
|
||||
# 1) 二进制版本校验
|
||||
for bin in "$ROOT_DIR/bin/inp2ps" "$ROOT_DIR/bin/inp2pc"; do
|
||||
if [[ ! -x "$bin" ]]; then
|
||||
fail "binary missing or not executable: $bin"
|
||||
continue
|
||||
fi
|
||||
ver_out="$($bin -version 2>/dev/null || true)"
|
||||
if [[ -z "$ver_out" ]]; then
|
||||
fail "cannot read version: $bin"
|
||||
continue
|
||||
fi
|
||||
got_ver="$(echo "$ver_out" | awk '/^inp2p[sc] version/{print $3; exit}')"
|
||||
if [[ "$got_ver" == "$EXPECTED_VERSION" ]]; then
|
||||
pass "$(basename "$bin") version ok: $got_ver"
|
||||
else
|
||||
fail "$(basename "$bin") version mismatch: got=$got_ver expected=$EXPECTED_VERSION"
|
||||
fi
|
||||
echo "$ver_out" | sed 's/^/[BIN] /' | tee -a "$REPORT" >/dev/null
|
||||
done
|
||||
|
||||
# 2) systemd 进程与路径校验(仅 inp2ps.service)
|
||||
if systemctl show inp2ps.service -p Id --value >/dev/null 2>&1; then
|
||||
pass "inp2ps.service exists"
|
||||
active_state="$(systemctl is-active inp2ps.service || true)"
|
||||
if [[ "$active_state" == "active" ]]; then
|
||||
pass "inp2ps.service active"
|
||||
else
|
||||
fail "inp2ps.service not active: $active_state"
|
||||
fi
|
||||
|
||||
main_pid="$(systemctl show inp2ps.service -p MainPID --value 2>/dev/null || echo 0)"
|
||||
if [[ -n "$main_pid" && "$main_pid" != "0" ]]; then
|
||||
pass "inp2ps.service main pid: $main_pid"
|
||||
exe_path="$(readlink -f "/proc/$main_pid/exe" 2>/dev/null || true)"
|
||||
if [[ "$exe_path" == "$ROOT_DIR/bin/inp2ps" ]]; then
|
||||
pass "inp2ps.service uses expected binary: $exe_path"
|
||||
else
|
||||
fail "inp2ps.service binary path mismatch: $exe_path"
|
||||
fi
|
||||
else
|
||||
fail "inp2ps.service MainPID is empty/0"
|
||||
fi
|
||||
else
|
||||
fail "inp2ps.service not found"
|
||||
fi
|
||||
|
||||
# 3) 残留进程检查(inp2ps/inp2pc)
|
||||
mapfile -t pids < <(pgrep -f '(^|/)inp2p[sc](\s|$)' || true)
|
||||
if [[ ${#pids[@]} -eq 0 ]]; then
|
||||
pass "no inp2p processes running"
|
||||
else
|
||||
info "found inp2p-related pids: ${pids[*]}"
|
||||
allow_pid="$(systemctl show inp2ps.service -p MainPID --value 2>/dev/null || echo 0)"
|
||||
residual=0
|
||||
for pid in "${pids[@]}"; do
|
||||
exe="$(readlink -f "/proc/$pid/exe" 2>/dev/null || true)"
|
||||
cmd="$(tr '\0' ' ' < "/proc/$pid/cmdline" 2>/dev/null || true)"
|
||||
echo "[PROC] pid=$pid exe=$exe cmd=$cmd" | tee -a "$REPORT" >/dev/null
|
||||
|
||||
if [[ "$pid" == "$allow_pid" ]]; then
|
||||
continue
|
||||
fi
|
||||
# 允许合法 systemd-run 的 inp2pc 客户端由独立服务名管理:后续可加白名单
|
||||
residual=$((residual+1))
|
||||
done
|
||||
|
||||
if [[ $residual -eq 0 ]]; then
|
||||
pass "no residual inp2p process (except inp2ps main pid=$allow_pid)"
|
||||
else
|
||||
fail "residual inp2p processes detected: $residual"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 4) 旧二进制残留(根目录/临时后缀)
|
||||
residual_bins=0
|
||||
while IFS= read -r f; do
|
||||
[[ -z "$f" ]] && continue
|
||||
echo "[FILE] residual-bin: $f" | tee -a "$REPORT" >/dev/null
|
||||
residual_bins=$((residual_bins+1))
|
||||
done < <(find "$ROOT_DIR" -maxdepth 2 -type f \( -name 'inp2ps.old*' -o -name 'inp2pc.old*' -o -name 'inp2ps.new*' -o -name 'inp2pc.new*' -o -path "$ROOT_DIR/inp2ps" -o -path "$ROOT_DIR/inp2pc" \) 2>/dev/null)
|
||||
|
||||
if [[ $residual_bins -eq 0 ]]; then
|
||||
pass "no residual old/new binaries found"
|
||||
else
|
||||
fail "residual binary files found: $residual_bins"
|
||||
fi
|
||||
|
||||
# 5) 输出总结
|
||||
if [[ $FAIL_COUNT -eq 0 ]]; then
|
||||
pass "deploy check passed"
|
||||
info "report=$REPORT"
|
||||
exit 0
|
||||
else
|
||||
fail "deploy check failed (count=$FAIL_COUNT)"
|
||||
info "report=$REPORT"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user