curl -fsSL https://opencode.ai/install | bash
設定使用者名稱與密碼
echo "export OPENCODE_SERVER_USERNAME='jiantw83'" >> ~/.bashrc
echo "export OPENCODE_SERVER_PASSWORD='*%QOSYn3Rcc&r*xuWn&q'" >> ~/.bashrc
以 systemd 管理服務,可開機自動啟動、崩潰時自動重啟。先建立服務設定檔。
nano /etc/systemd/system/opencode.service
服務檔內容如下:
[Unit] Description=OpenCode [Service] Environment=HOME=/root Type=simple WorkingDirectory=/root ExecStart=/root/.opencode/bin/opencode serve --hostname 0.0.0.0 --mdns true --mdns-domain opencode.jsc.idv.me Restart=always User=root [Install] WantedBy=multi-user.target
重新載入 systemd 設定、設為開機自動啟動、啟動服務並檢視狀態。
systemctl daemon-reload && systemctl enable opencode.service && systemctl start opencode.service && systemctl status opencode.service
Deleting the wiki page "Service:OpenCode" cannot be undone. Continue?