Files
memind/scripts/install-goose-v149-canary-103.sh
T
john 96176ff280 feat(goose-v149): add 103 canary install and Portal routing scripts
Install v1.49 on loopback :18015 beside stable native pool and toggle TKMIND_GOOSE_CANARY on production .env for user-scoped cutover.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-10 15:27:48 +08:00

140 lines
4.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install Goose v1.49 canary on 103 loopback :18015 (does not touch stable 18006-18014).
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
NATIVE_ROOT="${GOOSE_NATIVE_ROOT:-/Users/john/Project/tkmind_go-native}"
GOOSED_V149_ROOT="${GOOSE_V149_ROOT:-/Users/john/Project/tkmind_go-v149}"
PORT="${GOOSE_V149_CANARY_PORT:-18015}"
LABEL="${GOOSE_V149_CANARY_LABEL:-cn.tkmind.goose-v149-canary}"
LAUNCHD_DIR="${HOME}/Library/LaunchAgents"
PLIST="${LAUNCHD_DIR}/${LABEL}.plist"
GUI="gui/$(id -u)"
STAMP="${GOOSE_V149_RELEASE_STAMP:-$(date +%Y%m%d-v149-m1)}"
RELEASE_BIN="${NATIVE_ROOT}/releases/goose-${STAMP}"
RUN_SCRIPT="${NATIVE_ROOT}/run-goose-v149-${PORT}.sh"
ENV_FILE="${NATIVE_ROOT}/.env.${PORT}"
SOURCE_ENV="${NATIVE_ROOT}/.env.18006"
usage() {
cat <<EOF
Usage:
bash scripts/install-goose-v149-canary-103.sh
bash scripts/install-goose-v149-canary-103.sh --uninstall
Installs Goose v1.49 on https://127.0.0.1:${PORT} beside stable native 1.41 pool.
Requires: ${GOOSED_V149_ROOT}/target/release/goose (build on 103 first).
After install:
bash scripts/switch-goose-v149-canary-103.sh on users
launchctl kickstart -k ${GUI}/cn.tkmind.memind-portal
EOF
}
uninstall() {
launchctl bootout "${GUI}/${LABEL}" 2>/dev/null || true
rm -f "${PLIST}" "${RUN_SCRIPT}" "${ENV_FILE}"
echo "[goose-v149-canary-103] uninstalled ${LABEL} on :${PORT}"
}
if [[ "${1:-}" == "--uninstall" ]]; then
uninstall
exit 0
fi
if [[ ! -x "${GOOSED_V149_ROOT}/target/release/goose" ]]; then
echo "[goose-v149-canary-103] missing binary: ${GOOSED_V149_ROOT}/target/release/goose" >&2
echo "Build on 103: cd Memind-git && GOOSE_V149_BUILD_MODE=codemode bash scripts/build-goosed-v149-local.sh" >&2
exit 1
fi
if [[ ! -f "${SOURCE_ENV}" ]]; then
echo "[goose-v149-canary-103] missing ${SOURCE_ENV}" >&2
exit 1
fi
for blocked in 18006 18007 18008 18009 18010 18011 18012 18013 18014 8081; do
if [[ "${PORT}" == "${blocked}" ]]; then
echo "[goose-v149-canary-103] refusing stable/production port ${PORT}" >&2
exit 1
fi
done
mkdir -p "${NATIVE_ROOT}/releases" "${NATIVE_ROOT}/state/${PORT}"/{config,data,state,cache}
install -m 755 "${GOOSED_V149_ROOT}/target/release/goose" "${RELEASE_BIN}"
cp "${SOURCE_ENV}" "${ENV_FILE}"
{
echo ""
echo "# goose-v149-canary-${PORT} overrides ($(date -u +%Y-%m-%dT%H:%M:%SZ))"
echo "GOOSE_PORT=${PORT}"
echo "GOOSE_BIN=${RELEASE_BIN}"
echo "XDG_CONFIG_HOME=${NATIVE_ROOT}/state/${PORT}/config"
echo "XDG_DATA_HOME=${NATIVE_ROOT}/state/${PORT}/data"
echo "XDG_STATE_HOME=${NATIVE_ROOT}/state/${PORT}/state"
echo "XDG_CACHE_HOME=${NATIVE_ROOT}/state/${PORT}/cache"
echo "MEMORY_BACKEND=legacy"
echo "MEMORY_VECTOR_ENABLED=0"
echo "MEMORY_AGENT_INJECTION_MODE=off"
echo "MEMORY_LIFECYCLE_ENABLED=0"
echo "MEMORY_CANDIDATE_ENABLED=0"
} >> "${ENV_FILE}"
cat > "${RUN_SCRIPT}" <<'RUNEOF'
#!/usr/bin/env bash
set -euo pipefail
export PATH="/opt/homebrew/opt/node@24/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
PORT="__PORT__"
ROOT="__NATIVE_ROOT__"
cd "${ROOT}"
set -a
# shellcheck source=/dev/null
source "${ROOT}/.env.${PORT}"
set +a
exec env "CUSTOM_DEEPSEEK-CP_API_KEY=${DEEPSEEK_API_KEY:-}" \
"${GOOSE_BIN:?missing GOOSE_BIN}" serve \
--host "${GOOSE_HOST:-127.0.0.1}" \
--port "${PORT}" \
--tls
RUNEOF
sed -i '' "s|__PORT__|${PORT}|g; s|__NATIVE_ROOT__|${NATIVE_ROOT}|g" "${RUN_SCRIPT}"
chmod +x "${RUN_SCRIPT}"
cat > "${PLIST}" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>${LABEL}</string>
<key>ProgramArguments</key>
<array>
<string>${RUN_SCRIPT}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>${NATIVE_ROOT}/state/${PORT}/goose-v149-canary.log</string>
<key>StandardErrorPath</key>
<string>${NATIVE_ROOT}/state/${PORT}/goose-v149-canary.err.log</string>
</dict>
</plist>
EOF
launchctl bootout "${GUI}/${LABEL}" 2>/dev/null || true
launchctl bootstrap "${GUI}" "${PLIST}"
launchctl enable "${GUI}/${LABEL}" 2>/dev/null || true
sleep 2
if curl -kfsS --connect-timeout 5 "https://127.0.0.1:${PORT}/status" >/dev/null; then
echo "[goose-v149-canary-103] ok https://127.0.0.1:${PORT}/status"
else
echo "[goose-v149-canary-103] WARN: /status not ready; check ${NATIVE_ROOT}/state/${PORT}/goose-v149-canary.err.log" >&2
exit 1
fi
"${RELEASE_BIN}" --version | head -1
echo "[goose-v149-canary-103] release=${RELEASE_BIN} label=${LABEL}"