跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

common.inc.sh

52 行 · 1.4 KB历史下载
1# shellcheck shell=bash
2cleanup_cmd=""
3trap 'eval ${cleanup_cmd}' EXIT
4function defer {
5 [ -n "${cleanup_cmd}" ] && cleanup_cmd="${cleanup_cmd}; "
6 cleanup_cmd="${cleanup_cmd}$1"
7}
8
9function INFO() {
10 echo "TEST| [INFO] $*"
11}
12
13function WARNING() {
14 echo >&2 "TEST| [WARNING] $*"
15}
16
17function ERROR() {
18 echo >&2 "TEST| [ERROR] $*"
19}
20
21# check_required_commands CMD...
22# Exits 1 (listing every missing command) if any required host command is absent.
23function check_required_commands() {
24 local missing=()
25 local cmd
26 for cmd in "$@"; do
27 command -v "${cmd}" >/dev/null 2>&1 || missing+=("${cmd}")
28 done
29 if [ "${#missing[@]}" -gt 0 ]; then
30 ERROR "Missing required host command(s): ${missing[*]}"
31 ERROR "Please install them before running this test."
32 exit 1
33 fi
34}
35
36if [[ ${BASH_VERSINFO:-0} -lt 4 ]]; then
37 ERROR "Bash version is too old: ${BASH_VERSION}"
38 exit 1
39fi
40
41: "${LIMA_HOME:=${HOME_HOST:-$HOME}/.lima}"
42_IPERF3=iperf3
43# iperf3-darwin does some magic on macOS to avoid "No route on host" on macOS 15
44# https://github.com/lima-vm/socket_vmnet/issues/85
45[ "$(uname -s)" = "Darwin" ] && _IPERF3="iperf3-darwin"
46: "${IPERF3:=$_IPERF3}"
47
48# Setup LIMA_TEMPLATES_PATH because the templates are not installed, but reference base templates
49# via template:_images/* and template:_default/*.
50templates_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../templates" && pwd)"
51: "${LIMA_TEMPLATES_PATH:-$templates_dir}"
52export LIMA_TEMPLATES_PATH