Files
memind/scripts/install-baidu-sitemap-push-agent.sh
john f281f15788
Memind CI / Test, build, and release guards (pull_request) Failing after 3m21s
feat(seo): 固化 m.tkmind.cn 百度验证、推送与 sitemap 去重
让 Portal 首页稳定注入站长验证 meta,并提供 sitemap 批量推送脚本与 LaunchAgent 安装入口;sitemap/llms 对同页优先保留 /u/ canonical URL。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 16:28:46 +08:00

70 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
WRAPPER="${MEMIND_BAIDU_PUSH_WRAPPER:-$ROOT/scripts/run-baidu-sitemap-push-prod.sh}"
LABEL="${MEMIND_BAIDU_PUSH_LABEL:-cn.tkmind.memind-baidu-sitemap-push}"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"
LOG="$HOME/Library/Logs/memind-baidu-sitemap-push.log"
GUI="gui/$(id -u)"
HOUR="${MEMIND_BAIDU_PUSH_HOUR:-1}"
MINUTE="${MEMIND_BAIDU_PUSH_MINUTE:-0}"
STATE_FILE="${BAIDU_PUSH_STATE_FILE:-$ROOT/data/baidu-push-state.json}"
mkdir -p "$HOME/Library/LaunchAgents" "$HOME/Library/Logs" "$(dirname "$STATE_FILE")"
if [[ ! -x "$WRAPPER" ]]; then
chmod +x "$WRAPPER"
fi
if [[ ! -f "$WRAPPER" ]]; then
echo "baidu push wrapper not found: $WRAPPER" >&2
exit 1
fi
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>/bin/bash</string>
<string>$WRAPPER</string>
</array>
<key>WorkingDirectory</key>
<string>$ROOT</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>$HOUR</integer>
<key>Minute</key>
<integer>$MINUTE</integer>
</dict>
<key>StandardOutPath</key>
<string>$LOG</string>
<key>StandardErrorPath</key>
<string>$LOG</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/homebrew/bin:/opt/homebrew/opt/node@24/bin:/usr/local/bin:/usr/bin:/bin</string>
<key>BAIDU_PUSH_STATE_FILE</key>
<string>$STATE_FILE</string>
</dict>
</dict>
</plist>
EOF
plutil -lint "$PLIST"
launchctl bootout "$GUI/$LABEL" 2>/dev/null || true
launchctl bootstrap "$GUI" "$PLIST"
launchctl enable "$GUI/$LABEL"
echo "installed $PLIST"
echo "wrapper: $WRAPPER"
echo "schedule: daily ${HOUR}:$(printf '%02d' "$MINUTE") (local time)"
echo "state_file: $STATE_FILE"
echo "log: $LOG"