Files
weichen 8476a2d71d Release 0.1.0: build pipeline from pinned dev combination
Details (original message):
Release 0.1.0: build pipeline from pinned dev combination, native deploy materials (systemd, install/rollback, sha256 verify), manifest snapshot.
2026-09-29 18:05:17 +00:00

59 lines
2.1 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Agent-System 原生安装/升级/回退脚本(单二进制;非容器)。
# 用法:
# ./install.sh install # 首次安装(或就地升级)
# ./install.sh rollback # 回退到上一版本(保留上一二进制备份)
set -euo pipefail
CMD="${1:-install}"
BIN_DST=/usr/local/bin/agent-system
DATA_DIR=/var/lib/agent-system
PLUGIN_DIR=/etc/agent-system/plugins
HERE="$(cd "$(dirname "$0")" && pwd)"
need_root() { [ "$(id -u)" -eq 0 ] || { echo "需要 root(sudo)"; exit 1; }; }
case "$CMD" in
install)
need_root
test -x "$HERE/agent-system" || { echo "缺少 agent-system 二进制"; exit 1; }
# 备份当前版本(升级路径)
if [ -x "$BIN_DST" ]; then
cp "$BIN_DST" "$BIN_DST.prev"
echo "已备份当前版本 → $BIN_DST.prev"
systemctl stop agent-system 2>/dev/null || true
fi
install -m 0755 "$HERE/agent-system" "$BIN_DST"
mkdir -p "$DATA_DIR" "$PLUGIN_DIR"
cp -r "$HERE/plugins/." "$PLUGIN_DIR/"
cp "$HERE/agent-system.service" /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now agent-system
echo "✓ 已安装并启动:http://127.0.0.1:8787 (数据:$DATA_DIR,插件:$PLUGIN_DIR)"
echo " 首次使用建议:设置 → 运行时 → 开启演示模式(无需模型密钥即可体验全部交互)"
;;
rollback)
need_root
test -x "$BIN_DST.prev" || { echo "无上一版本备份($BIN_DST.prev)"; exit 1; }
systemctl stop agent-system 2>/dev/null || true
cp "$BIN_DST" "$BIN_DST.staged" 2>/dev/null || true
mv "$BIN_DST.prev" "$BIN_DST"
systemctl start agent-system
echo "✓ 已回退到上一版本(当前版本暂存于 $BIN_DST.staged)"
;;
verify)
"$HERE/agent-system" version
test -f "$HERE/manifest.json" && python3 -c "
import json, hashlib
m = json.load(open('$HERE/manifest.json'))
sha = hashlib.sha256(open('$HERE/agent-system','rb').read()).hexdigest()
ok = sha == m['artifacts']['agent-system']
print('manifest↔制品校验:', '一致 ✓' if ok else '不一致 ✗')
exit(0 if ok else 1)"
;;
*)
echo "用法:$0 install|rollback|verify"
exit 1
;;
esac