fix: find ssh-monitor in clone via git checkout and broader search
Restore ssh-monitor from HEAD when missing on disk; try git ls-files and find fallback; log clone root listing on failure.
This commit is contained in:
+49
-10
@@ -488,19 +488,58 @@ sync_sac_client() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
find_remote_ssh_monitor_path() {
|
find_remote_ssh_monitor_path() {
|
||||||
REMOTE_SCRIPT_PATH="$UPDATE_DIR/$SCRIPT_NAME/src/branch/main/$SCRIPT_NAME"
|
local repo="$UPDATE_DIR/$SCRIPT_NAME"
|
||||||
ALT_REMOTE_PATH="$UPDATE_DIR/$SCRIPT_NAME/$SCRIPT_NAME"
|
local candidates=() git_path="" found="" p
|
||||||
if [ -f "$REMOTE_SCRIPT_PATH" ]; then
|
|
||||||
log_action "ssh-monitor в клоне: $REMOTE_SCRIPT_PATH (src/branch/main)"
|
REMOTE_SCRIPT_PATH="$repo/ssh-monitor"
|
||||||
printf '%s\n' "$REMOTE_SCRIPT_PATH"
|
ALT_REMOTE_PATH="$repo/src/branch/main/ssh-monitor"
|
||||||
|
candidates=(
|
||||||
|
"$REMOTE_SCRIPT_PATH"
|
||||||
|
"$ALT_REMOTE_PATH"
|
||||||
|
)
|
||||||
|
|
||||||
|
for p in "${candidates[@]}"; do
|
||||||
|
if [ -f "$p" ]; then
|
||||||
|
log_action "ssh-monitor в клоне: $p"
|
||||||
|
printf '%s\n' "$p"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -d "$repo/.git" ]; then
|
||||||
|
if git -C "$repo" cat-file -e "HEAD:ssh-monitor" 2>/dev/null; then
|
||||||
|
if [ ! -f "$repo/ssh-monitor" ]; then
|
||||||
|
log_action "ssh-monitor есть в git HEAD, но отсутствует на диске — git checkout HEAD -- ssh-monitor"
|
||||||
|
git -C "$repo" checkout HEAD -- ssh-monitor >> "$LOG_FILE" 2>&1 || true
|
||||||
|
fi
|
||||||
|
if [ -f "$repo/ssh-monitor" ]; then
|
||||||
|
log_action "ssh-monitor восстановлен: $repo/ssh-monitor"
|
||||||
|
printf '%s\n' "$repo/ssh-monitor"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
git_path=$(git -C "$repo" ls-files 'ssh-monitor' 2>/dev/null | grep -v '^contrib/' | head -1)
|
||||||
|
if [ -z "$git_path" ]; then
|
||||||
|
git_path=$(git -C "$repo" ls-files 2>/dev/null | grep -E '/ssh-monitor$' | grep -v contrib | grep -v watchdog | head -1)
|
||||||
|
fi
|
||||||
|
if [ -n "$git_path" ] && [ -f "$repo/$git_path" ]; then
|
||||||
|
log_action "ssh-monitor в клоне (git ls-files): $repo/$git_path"
|
||||||
|
printf '%s\n' "$repo/$git_path"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
found=$(find "$repo" -maxdepth 4 -type f -name 'ssh-monitor' ! -path '*/contrib/*' 2>/dev/null | head -1)
|
||||||
|
if [ -n "$found" ] && [ -f "$found" ]; then
|
||||||
|
log_action "ssh-monitor найден поиском: $found"
|
||||||
|
printf '%s\n' "$found"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ -f "$ALT_REMOTE_PATH" ]; then
|
|
||||||
log_action "ssh-monitor в клоне: $ALT_REMOTE_PATH (корень репозитория)"
|
log_action "WARNING: ssh-monitor не найден в $repo"
|
||||||
printf '%s\n' "$ALT_REMOTE_PATH"
|
if [ -d "$repo" ]; then
|
||||||
return 0
|
log_action "корень клона: $(ls -1 "$repo" 2>/dev/null | tr '\n' ' ')"
|
||||||
fi
|
fi
|
||||||
log_action "WARNING: ssh-monitor не найден ни в $REMOTE_SCRIPT_PATH, ни в $ALT_REMOTE_PATH"
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user