2026年3月11日 星期三

[macos] 快速設定 Mac Mini M4 32GB/1TB 並安裝設定 OpenClaw + Telegram + FileVault 排錯 @ Macbook M1


昨天弄出一個簡單的工具 macstrap ,方便未來快速批次處理 mac mini M4。然而,mac mini M4 一開始還是有幾個步驟需要人工處理的。

初次把 Mac mini 開機,過程會設定網路連線,以及設定一組帳密登入。進入系統後:
  • Sound: 聲音調成靜音
  • Energy: 開啟避免自動睡眠、電源失敗後可自動開機、網路喚醒
  • General: Sharing -> Remote Login: On
  • General: Sharing -> Remote Management: On -> 選項全開, 密碼設置, 指定使用者使用且選項全開
  • General: About -> Name -> 可以改成簡短的名稱,如 mac-mini ,好處就是可以用 ssh mac-mini.local 連線
  • General: Users & Group -> Automatically log in as -> user
  • 開啟 termnial -> 輸入 python3 -> 會觸動透過 Xcode 安裝 python3 環境 



如此就完成 mac mini 可被遠端操作的基本設定了,可以測試:
  • ssh user@mac-mini.local 
  • 開啟 螢幕共享 -> 輸入 mac-mini.local -> 選擇帳號登入
以上兩種就是可遠端的配置了,而多了 python3 的安裝,是為了用 macstrap 快速安置開發環境

```
% mkdir openclaw-on-mac-mini && cd openclaw-on-mac-mini
% python3 -m venv venv && source venv/bin/activate && pip install macstrap
% macstrap init --examples
% macstrap ssh-auth mac-mini.local --user user
...
✓  Passwordless SSH to mac-mini.local working.
...
✓  Sudo password stored in macOS Keychain
% macstrap run --config examples/ai-cli --config examples/openclaw  mac-mini.local 
...
```

如此系統就會安裝一些常見的 AI cli (OpenAI - Codex CLI, Google - Gemini CLI, Microsoft - Copilot CLI), Openclaw 跟 Docker Desktop 也安裝好了,而 Docker Desktop 需要登入 macOS 上先來個手動啟動,啟動後可以在設定區開啟 Start Docker Desktop when you sign into your computer,而這台 mac mini M4 是 32GB RAM 跟 1TB SSD ,因此可以多善用 Docker 來封裝一些任務做風險管控。

接著就是啟動 openclaw 的部分了,可以在 macos Desktop 啟動,也可以用 ssh 登入啟動,在此用後者:

```
% ssh user@mac-mini.local
user@mac-mini ~ % openclaw onboard

🦞 OpenClaw 2026.3.8 (3caab92)
   I'm not AI-powered, I'm AI-possessed. Big difference.

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██
██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██
██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
                  🦞 OPENCLAW 🦞                    
 
┌  OpenClaw onboarding
│...

```

我們採用 QuickStart ,以及 Copilot (Github + local proxy) ,而 Copilot CLI 認證方式採用 `GitHub Copilot (GitHub device login) (Uses GitHub device flow)`,且模型就挑 `GPT-5 mini` 好了

主因是 Github Copilot 在 2026-03-11 的模型費用:

```
 Search models...

  Claude Sonnet 4.5 (default) ✓                                      1x
  Claude Haiku 4.5                                                0.33x
  Claude Opus 4.6                                                    3x
  Claude Opus 4.6 (fast mode) (Preview) (requires enablement)       30x
  Claude Opus 4.5                                                    3x
  Claude Sonnet 4                                                    1x
  Gemini 3 Pro (Preview)                                             1x
  GPT-5.3-Codex                                                      1x
  GPT-5.2-Codex                                                      1x
  GPT-5.2                                                            1x
  GPT-5.1-Codex-Max                                                  1x
  GPT-5.1-Codex                                                      1x
  GPT-5.1                                                            1x
  GPT-5.1-Codex-Mini (Preview)                                    0.33x
❯ GPT-5 mini                                                         0x
  GPT-4.1                                                            0x
```

若表現太差就換到 `Claude Sonnet 4.5`

接著就是跟龍蝦溝通的方式 `Select channel (QuickStart)`

```
◆  Select channel (QuickStart)
│  ● Telegram (Bot API) (recommended · newcomer-friendly)
│  ○ WhatsApp (QR link)
│  ○ Discord (Bot API)
│  ○ IRC (Server + Nick)
│  ○ Google Chat (Chat API)
│  ○ Slack (Socket Mode)
│  ○ Signal (signal-cli)
│  ○ iMessage (imsg)
│  ○ LINE (Messaging API)
│  ○ Feishu/Lark (飞书)
│  ○ Nostr (NIP-04 DMs)
│  ○ Microsoft Teams (Bot Framework)
│  ○ Mattermost (plugin)
│  ○ Nextcloud Talk (self-hosted)
│  ○ Matrix (plugin)
│  ○ BlueBubbles (macOS app)
│  ○ Zalo (Bot API)
│  ○ Zalo (Personal Account)
│  ○ Synology Chat (Webhook)
│  ○ Tlon (Urbit)
│  ○ Skip for now
```

就是一下 Telegram 吧,設定滿簡單的,只要到 Telegram BotFather 上註冊一個 Bot 即可,過程會給予 HTTP API token ,回 OpenClaw 貼上即可。

接著 Install missing skill dependencies 的部分,就挑一下 macOS 系列: apple-notes, apple-reminders, openai-whisper 等等:

◆  Install missing skill dependencies
│  ◻ Skip for now (Continue without installing dependencies)
│  ◻ 🔐 1password
│  ◼ 📝 apple-notes (Manage Apple Notes via the `memo` CLI on macOS 
│  (create, view, edit, delete, search, move,…)
│  ◼ ⏰ apple-reminders (Manage Apple Reminders via remindctl CLI 
│  (list, add, edit, complete, delete). Supports li…)
│  ◻ 🐻 bear-notes
│  ◻ 📰 blogwatcher
│  ◻ 🫐 blucli
│  ◻ 📸 camsnap
│  ◻ 🧩 clawhub
│  ◻ 🎛️ eightctl
│  ◻ 🧲 gifgrep
│  ◻ 🎮 gog
│  ◻ 📍 goplaces
│  ◻ 📧 himalaya
│  ◻ 📨 imsg
│  ◻ 📦 mcporter
│  ◻ 📊 model-usage
│  ◻ 🍌 nano-banana-pro
│  ◻ 📄 nano-pdf
│  ◻ 💎 obsidian
│  ◼ 🎙️ openai-whisper (Local speech-to-text with the Whisper CLI (no
│   API key). — Install OpenAI Whisper (brew))
│  ◻ 💡 openhue
│  ◻ 🧿 oracle
│  ◻ 🛵 ordercli
│  ◻ 👀 peekaboo
│  ◻ 🗣️ sag
│  ◻ 🌊 songsee
│  ◻ 🔊 sonoscli
│  ◻ 🧾 summarize
│  ◻ ✅ things-mac
│  ◻ 🎞️ video-frames
│  ◻ 📱 wacli
│  ◻ 𝕏 xurl

接著 hooks 就全裝,最後就差不多搞定了。

未來想要打開設定,可以改用 openclaw dashboard 指令,將允許在 http://localhost:12345/ 類似的網址瀏覽。

這邊提一下 telegram 連線有問題的處理方式:
  1. 先在 Telegram BotFather 那邊查看 Bot 的情況,像是用 `/mybots` ,接著可以查看指定 bot 的 api token
  2. 直接在 mac mini 上編輯 ~/.openclaw/openclaw.json 檔案,確認:
    • 查看 channels.telegram 的設定,如 enabled: true, dmPolicy: pairing, 以及可以順便更新一下 botToken 等
  3. 在 mac mini 使用指令 `openclaw gateway` 運行
  4. 在 Telegram Bot 上,打 `/start` 指令
  5. 在 mac mini 使用指令 `openclaw pairing list telegram`
  6. 如果有看到配對碼,就用 `openclaw pairing approve telegram <CODE>` 生效他
如果 mac mini 重啟後,容易 Telegram 沒反應,這時可以用 ssh user@mac-mini.local 試試,若會看到 `System successfully unlocked. You may now use SSH to authenticate normally.` ,大概是因為 FileVault 的關係,可以評估一下是否關閉:

user@mac-mini ~ % fdesetup status
FileVault is On.
user@mac-mini ~ % sudo fdesetup disable
Enter the user name:user
Enter the password for user 'user':
FileVault has been disabled.
user@mac-mini ~ % fdesetup status      
FileVault is Off.

最後,設定一下開機自動執行 openclaw ,這邊單純用 crontab 管理,還有其他更佳的方案,之後再來研究:

```
user@mac-mini ~ % which openclaw
/Users/user/.nvm/versions/node/v22.22.1/bin/openclaw

user@mac-mini ~ % crontab -l
@reboot PATH=$PATH:$HOME/.nvm/versions/node/v22.22.1/bin/ $HOME/.nvm/versions/node/v22.22.1/bin/openclaw gateway >> $HOME/openclaw.log 2>&1
```

2026年3月10日 星期二

[macOS] 使用 macstrap 批次快速設定 Mac Mini M4 與架設 OpenClaw 環境 @ macOS

最近拿到一台 Mac mini M4 32GB/1TB ,之前很習慣用 Notes 貼一下快速安裝的指令,想著想著自己十多年前都在用 ansible 管理百台 Ubuntu servers ,這個年代一直貼指令微遜 XD 就 vibe coding 一下,請 AI 小弟幫忙實現工具,於是乎就長出個 macstrap 工具,其特色就是讓不熟悉 ansible 的人也能快速上手,而安裝途徑是透過 ssh remote command ,這樣搞定一台後,未來有多台 mac mini 要初始化,也可以快速搞定。

首先,先把 Mac mini 開箱後,設定好登入的帳號密碼,接著在 System Settings -> General -> Sharing -> Remote login 打開,這樣就完成很基本的 ssh 可登入機制,然而 macstrap 是基於 python 的工具,所以 Mac mini 本地需要故意打一下 python 指令觸發系統去下載安裝 Python3

接下來就是 macstrap 領域了:

```
% cd /tmp
% python3 -m venv venv
% source /tmp/venv/bin/activate
% pip install macstrap
...
% macstrap --version 
macstrap, version 1.1.0
```

初始化一些範例來用:

```
% macstrap init --exmaples
% tree -L 1 examples
examples
├── ai-cli
├── openclaw
├── php8.3-dev
└── utilities-dev

5 directories, 0 files
```

設置連上 Mac mini 的帳密,假設 Mac mini IP 是 192.168.1.100 (或 mac-mini.local) 登入帳號是 macuser 且擁有 sudo 權限:

```
% macstrap ssh-auth mac-mini.local --user macuser
```

替 192.168.1.100 (或 mac-mini.local) 安裝 AI CLI:

```
% macstrap run --config examples/ai-cli mac-mini.local
...

TASK [nvm : Install global npm packages] *****
ok: [mac-mini.local] => (item=@github/copilot)
ok: [mac-mini.local] => (item=@anthropic-ai/claude-code)
ok: [mac-mini.local] => (item=@openai/codex)
ok: [mac-mini.local] => (item=@google/gemini-cli)

...

```

安裝 OpenClaw:

```
% macstrap run --config examples/openclaw mac-mini.local
...
TASK [nvm : Install global npm packages] *****
ok: [user-macmini.local] => (item=openclaw)
...
```

接著登入 mac-mini.local 後,就可以用 openclaw onboard 啟動他來做設定:

```
% ssh macuser@mac-mini.local
Now using node v22.22.1 (npm v10.9.4)
[env] node: v22.22.1 | npm: 10.9.4 | Python 3.9.6

% openclaw onboard

🦞 OpenClaw 2026.3.8 (3caab92)
   Runs on a Raspberry Pi. Dreams of a rack in Iceland.

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██
██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██
██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
                  🦞 OPENCLAW 🦞                    
 
┌  OpenClaw onboarding
◇  Security ─────────────────────────────────────────────────────────────╮
│                                                                        │
│  Security warning — please read.                                       │
│                                                                        │
│  OpenClaw is a hobby project and still in beta. Expect sharp edges.    │
│  By default, OpenClaw is a personal agent: one trusted operator        │
│  boundary.                                                             │
│  This bot can read files and run actions if tools are enabled.         │
│  A bad prompt can trick it into doing unsafe things.                   │
│                                                                        │
│  OpenClaw is not a hostile multi-tenant boundary by default.           │
│  If multiple users can message one tool-enabled agent, they share      │
│  that delegated tool authority.                                        │
│                                                                        │
│  If you’re not comfortable with security hardening and access          │
│  control, don’t run OpenClaw.                                          │
│  Ask someone experienced to help before enabling tools or exposing it  │
│  to the internet.                                                      │
│                                                                        │
│  Recommended baseline:                                                 │
│  - Pairing/allowlists + mention gating.                                │
│  - Multi-user/shared inbox: split trust boundaries (separate           │
│    gateway/credentials, ideally separate OS users/hosts).              │
│  - Sandbox + least-privilege tools.                                    │
│  - Shared inboxes: isolate DM sessions (`session.dmScope:              │
│    per-channel-peer`) and keep tool access minimal.                    │
│  - Keep secrets out of the agent’s reachable filesystem.               │
│  - Use the strongest available model for any bot with tools or         │
│    untrusted inboxes.                                                  │
│                                                                        │
│  Run regularly:                                                        │
│  openclaw security audit --deep                                        │
│  openclaw security audit --fix                                         │
│                                                                        │
│  Must read: https://docs.openclaw.ai/gateway/security                  │
│                                                                        │
├────────────────────────────────────────────────────────────────────────╯
◆  I understand this is personal-by-default and shared/multi-user use requires
 lock-down. Continue?
│  ○ Yes / ● No

```