准备

  1. 在 macOS 安装 Forgejo
    brew install forgejo
    brew services start forgejo
    
    # 访问 http://localhost:3000 初始化
    
    vim /usr/local/var/forgejo/custom/conf/app.ini
    ## 在 [server] 段设置:
    ## START_SSH_SERVER = true
    ## SSH_DOMAIN = forgejo.local
    ## DOMAIN = forgejo.local
    ## HTTP_PORT = 4444
    ## ROOT_URL = http://forgejo.local:4444/
    ## SSH_PORT = 2222
    ## DISABLE_SSH = false
    
    # 在 /etc/hosts 添加 127.0.0.1 forgejo.local 的映射
    
    brew services restart forgejo
    
    # 访问 http://forgejo.local:4444
    

OpenClaw

  1. 在 Linux 安装 Incus,Debian 12 可以使用 https://github.com/zabbly/incus
    apt install incus
    sudo incus admin init
    sudo adduser $USER incus
    
  2. 创建容器:incus launch images:debian/13 claw
  3. 允许快照:sudo incus project set user-1000 restricted.snapshots=allow
  4. 进入 claw 容器:
incus exec claw bash

dpkg-reconfigure tzdata  # 选择 Asia/Shanghai

# 换 APT 源: https://mirrors.tuna.tsinghua.edu.cn/help/debian/
apt update
apt install etckeeper curl less telnet byobu man-db python3 nodejs npm golang

# 在 /etc/hosts 添加 MACOS-IP forgejo.local 的映射

adduser claw
adduser claw sudo

su - claw   # 切换到 claw 用户

byobu-enable
byobu-ctrl-a
byobu-config  # change escape sequence: Ctrl-j

echo 'registry=https://registry.npmmirror.com' > ~claw/.npmrc

go env -w GOPROXY=https://goproxy.cn,direct

ssh-keygen -t ed25519
# 将 ~claw/.ssh/id_ed25519.pub 添加到 Forgejo 的用户 SSH key 设置中
  1. 创建容器快照: incus snapshot create claw after-basic-setup
  2. 安装 OpenClaw:
incus exec claw bash
su - claw

# OpenClaw 会安装 linuxbrew,访问 Github
export http_proxy=http://....
export https_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy

curl -fsSL https://openclaw.ai/install.sh | bash

# 加上代理环境变量,以及 PATH=/home/linuxbrew/.linuxbrew/bin:$PATH
systemctl edit --user openclaw-gateway
systemctl restart --user openclaw-gateway