From 0b9527ede03521a40f1174a5a6e40a943bf27e2d Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 23 Jan 2026 16:25:42 +0000 Subject: Fix Phase 4 scripts to run flawlessly without manual intervention Make scripts fully automatic with no manual intervention needed. Changes: - Add --no-pager to journalctl commands in validate-service.sh - Add service existence validation with helpful error messages - Capture and report journalctl stderr for better error visibility - Improve error handling without failing on empty logs The main issue was missing --no-pager in validate-service.sh which could cause scripts to hang when run non-interactively (e.g., via SSH). Tested locally - scripts run without hanging and produce correct output. --- .../migration-scripts/30-extract-parse-failures.sh | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'docs/how-to/migration-scripts/30-extract-parse-failures.sh') diff --git a/docs/how-to/migration-scripts/30-extract-parse-failures.sh b/docs/how-to/migration-scripts/30-extract-parse-failures.sh index 410fcbc..d4f0ff2 100755 --- a/docs/how-to/migration-scripts/30-extract-parse-failures.sh +++ b/docs/how-to/migration-scripts/30-extract-parse-failures.sh @@ -236,6 +236,19 @@ main() { exit 1 fi + # Validate service exists (check if journalctl can find any logs for it) + # Note: We don't require the service to be running, just that it has logs + if ! journalctl --no-pager -u "$service" -n 1 &>/dev/null; then + log_warn "Could not query logs for service: $service" + log_warn "This may indicate the service doesn't exist or you lack permissions." + log_warn "" + log_warn "To list available ngit-grasp services:" + log_warn " systemctl list-units 'ngit-grasp*' --all" + log_warn " journalctl --list-boots # Check if you have journal access" + log_warn "" + # Continue anyway - the service might exist but have no logs yet + fi + # Build journalctl command local journal_cmd="journalctl -u $service --no-pager -o short-iso" @@ -280,8 +293,20 @@ main() { log_info "Extracting log entries..." # Get raw log lines containing [PARSE_FAIL] - local raw_lines - raw_lines=$(eval "$journal_cmd" 2>/dev/null | grep '\[PARSE_FAIL\]' || true) + # Capture stderr separately to detect journalctl errors + local raw_lines journal_stderr journal_exit + local temp_stderr + temp_stderr=$(mktemp) + + raw_lines=$(eval "$journal_cmd" 2>"$temp_stderr" | grep '\[PARSE_FAIL\]' || true) + journal_exit=$? + journal_stderr=$(cat "$temp_stderr" 2>/dev/null || true) + rm -f "$temp_stderr" + + # Report any journalctl errors (but don't fail - empty logs are valid) + if [[ -n "$journal_stderr" ]]; then + log_warn "journalctl reported: $journal_stderr" + fi if [[ -z "$raw_lines" ]]; then log_warn "No [PARSE_FAIL] entries found in logs." -- cgit v1.2.3