35 lines
1.6 KiB
Bash
35 lines
1.6 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 "$SRC"/*.sh; do
|
||
[ -e "$f" ] || continue
|
||
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/ 不养副本!──
|
||
# 2026-07-22 起:影子副本一律归档(archive/YYYYMMDD-*),sync 不再创建任何
|
||
# scripts/ 下的 cron 脚本副本。cron 只跑 profile-scripts 目录(本脚本维护的硬链)。
|
||
# 库文件(被 import 的 mofin_db/mo_data)例外——按红线#6 维护根目录 canonical 的硬链:
|
||
|
||
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 |