38 lines
2.0 KiB
Bash
38 lines
2.0 KiB
Bash
#!/bin/bash
|
||
# sync_profile_scripts.sh — 把 deploy/profile-scripts 全部硬链接到 profile scripts 目录
|
||
# 每次部署(scp/git)后必须跑:scp替换文件会破坏硬链接(inode变更),导致cron跑旧版本。
|
||
set -e
|
||
SRC="/home/hmo/MoFin/deploy/profile-scripts"
|
||
DST="/home/hmo/.hermes/profiles/position-analyst/scripts"
|
||
count=0
|
||
for f in "$SRC"/*.py; do
|
||
name=$(basename "$f")
|
||
ln -f "$f" "$DST/$name"
|
||
count=$((count+1))
|
||
done
|
||
ln -f "$SRC/sync_profile_scripts.sh" "$DST/sync_profile_scripts.sh" 2>/dev/null || true
|
||
|
||
# ── 库文件 SSOT:canonical 在 MoFin 根目录,其他位置只许硬链(红线#6)──
|
||
# git checkout/merge 会重写文件破坏硬链,这里强制恢复
|
||
ROOT="/home/hmo/MoFin"
|
||
for lib in mofin_db.py mo_data.py; do
|
||
if [ -f "$ROOT/$lib" ]; then
|
||
ln -f "$ROOT/$lib" "$ROOT/deploy/profile-scripts/$lib" 2>/dev/null || true
|
||
ln -f "$ROOT/$lib" "$ROOT/scripts/$lib" 2>/dev/null || true
|
||
ln -f "$ROOT/$lib" "/home/hmo/web-dashboard/$lib" 2>/dev/null || true
|
||
ln -f "$ROOT/$lib" "$DST/$lib" 2>/dev/null || true
|
||
fi
|
||
done
|
||
|
||
# ── cron 脚本分叉副本(scripts/ 旧副本)→ 硬链到 deploy/profile-scripts canonical ──
|
||
for f in verify_reassess_pipeline.py batch_reassess.py stale_detector.py fix_gateway_port.py morning_health_check.py candidate_filter.py per_stock_reassess.py; do
|
||
[ -f "$SRC/$f" ] && ln -f "$SRC/$f" "$ROOT/scripts/$f" 2>/dev/null || true
|
||
done
|
||
# price_monitor 还有 root 和 web-dashboard 两个副本
|
||
[ -f "$SRC/price_monitor.py" ] && ln -f "$SRC/price_monitor.py" "$ROOT/scripts/price_monitor.py" 2>/dev/null || true
|
||
[ -f "$SRC/price_monitor.py" ] && ln -f "$SRC/price_monitor.py" "$ROOT/price_monitor.py" 2>/dev/null || true
|
||
[ -f "$SRC/price_monitor.py" ] && ln -f "$SRC/price_monitor.py" "/home/hmo/web-dashboard/price_monitor.py" 2>/dev/null || true
|
||
|
||
echo "synced $count scripts (hardlink)"
|
||
mkdir -p /home/hmo/MoFin/gateway/logs
|
||
echo "$(date '+%F %T') synced $count scripts" >> /home/hmo/MoFin/gateway/logs/link_sync.log |