跳到主要内容

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

浏览文件

ubuntu-browser.sh

75 行 · 3.5 KB历史下载
1# shellcheck shell=bash
2# Ubuntu's Chromium package is a Snap transition. Use the upstream portable
3# build with extension loading and inherited CDP pipes, without snapd.
4cage_is_ubuntu() (
5 . /etc/os-release
6 [ "$ID" = ubuntu ]
7)
8
9cage_install_ubuntu_browser() (
10 set -euo pipefail
11 local version="$CAGE_UBUNTU_BROWSER_VERSION" checksum="$CAGE_UBUNTU_BROWSER_SHA256" platform=linux64
12 case "$(dpkg --print-architecture)" in
13 amd64) ;;
14 arm64) platform=linux-arm64; checksum="$CAGE_UBUNTU_BROWSER_ARM64_SHA256" ;;
15 *) echo 'Ubuntu guest browsers require amd64 or arm64.' >&2; exit 1 ;;
16 esac
17 local directory=chrome-$platform
18 local cache="$HOME/.cache/cage/downloads/$checksum" target="/opt/cage-browser/$version" stage
19 mkdir -p "$cache"
20 exec 8>"$cache/lock"
21 flock -w 60 8
22 # Package names differ after Ubuntu's time_t transition.
23 local asound=libasound2 atk=libatk1.0-0 bridge=libatk-bridge2.0-0 cups=libcups2
24 if . /etc/os-release; [ "$VERSION_ID" = 24.04 ]; then
25 asound=libasound2t64 atk=libatk1.0-0t64 bridge=libatk-bridge2.0-0t64 cups=libcups2t64
26 fi
27 sudo env DEBIAN_FRONTEND=noninteractive APT_CONFIG="${CAGE_APT_CONFIG:-/dev/null}" apt-get install -y --no-install-recommends \
28 "$asound" "$atk" "$bridge" "$cups" libnss3 libnspr4 libdrm2 libgbm1 libgtk-3-0 \
29 libx11-6 libxcb1 libxcomposite1 libxdamage1 libxext6 libxfixes3 libxrandr2 libxkbcommon0 \
30 fonts-liberation fonts-dejavu-core xvfb xauth unzip </dev/null
31 if [ ! -x "$target/chrome" ]; then
32 cage_download_tool "https://storage.googleapis.com/chrome-for-testing-public/$version/$platform/chrome-$platform.zip" "$checksum" "$cache/chrome.zip"
33 sudo install -d -m 0755 /opt/cage-browser
34 stage=$(sudo mktemp -d /opt/cage-browser/.install-XXXXXX)
35 trap 'sudo rm -rf "$stage"' EXIT
36 sudo unzip -q "$cache/chrome.zip" -d "$stage"
37 sudo chown -R root:root "$stage/$directory"
38 sudo chmod 4755 "$stage/$directory/chrome_sandbox"
39 sudo mv "$stage/$directory" "$target"
40 fi
41 sudo ln -sfn "$target/chrome" /usr/bin/chromium
42)
43
44cage_install_chromium() {
45 if cage_is_ubuntu; then
46 cage_install_ubuntu_browser
47 else
48 cage_cache_chromium --no-install-recommends chromium chromium-l10n
49 sudo env DEBIAN_FRONTEND=noninteractive APT_CONFIG="${CAGE_APT_CONFIG:-/dev/null}" apt-get install -y --no-install-recommends chromium chromium-l10n </dev/null
50 fi
51}
52
53# Jammy ships noVNC 1.0. The shared input/clipboard patch needs 1.6.
54# Keep the system package untouched; websockify serves the Cage-owned copy.
55cage_install_ubuntu_novnc() (
56 set -euo pipefail
57 local cache="$HOME/.cache/cage/downloads/$CAGE_UBUNTU_NOVNC_SHA256" stage
58 if [ -f /usr/local/share/cage-novnc/VERSION ] && [ "$(cat /usr/local/share/cage-novnc/VERSION)" = "$CAGE_UBUNTU_NOVNC_VERSION" ]; then
59 sudo chmod 0755 /usr/local/share/cage-novnc
60 return
61 fi
62 mkdir -p "$cache"
63 exec 8>"$cache/lock"
64 flock -w 60 8
65 cage_download_tool "https://github.com/novnc/noVNC/archive/refs/tags/v$CAGE_UBUNTU_NOVNC_VERSION.tar.gz" "$CAGE_UBUNTU_NOVNC_SHA256" "$cache/novnc.tar.gz"
66 sudo install -d -m 0755 /usr/local/share
67 stage=$(sudo mktemp -d /usr/local/share/.cage-novnc-XXXXXX)
68 trap 'sudo rm -rf "$stage"' EXIT
69 sudo tar -xzf "$cache/novnc.tar.gz" --strip-components=1 -C "$stage"
70 sudo chmod 0755 "$stage"
71 printf '%s\n' "$CAGE_UBUNTU_NOVNC_VERSION" | sudo tee "$stage/VERSION" >/dev/null
72 # Called only after cage-webvnc has stopped.
73 sudo rm -rf /usr/local/share/cage-novnc
74 sudo mv "$stage" /usr/local/share/cage-novnc
75)