upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-01-23 16:25:42 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-01-27 20:38:05 +0000
commit0b9527ede03521a40f1174a5a6e40a943bf27e2d (patch)
tree851d0b8a4dfb0d73f3964a473548cdb4c526a59c /docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh
parent2b21b807bdf6c0bab548ffceb5c41eee0902890c (diff)
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.
Diffstat (limited to 'docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh')
-rwxr-xr-xdocs/how-to/migration-scripts/31-extract-purgatory-expiry.sh29
1 files changed, 27 insertions, 2 deletions
diff --git a/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh b/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh
index a20780e..a603a1e 100755
--- a/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh
+++ b/docs/how-to/migration-scripts/31-extract-purgatory-expiry.sh
@@ -243,6 +243,19 @@ main() {
243 exit 1 243 exit 1
244 fi 244 fi
245 245
246 # Validate service exists (check if journalctl can find any logs for it)
247 # Note: We don't require the service to be running, just that it has logs
248 if ! journalctl --no-pager -u "$service" -n 1 &>/dev/null; then
249 log_warn "Could not query logs for service: $service"
250 log_warn "This may indicate the service doesn't exist or you lack permissions."
251 log_warn ""
252 log_warn "To list available ngit-grasp services:"
253 log_warn " systemctl list-units 'ngit-grasp*' --all"
254 log_warn " journalctl --list-boots # Check if you have journal access"
255 log_warn ""
256 # Continue anyway - the service might exist but have no logs yet
257 fi
258
246 # Build journalctl command 259 # Build journalctl command
247 local journal_cmd="journalctl -u $service --no-pager -o short-iso" 260 local journal_cmd="journalctl -u $service --no-pager -o short-iso"
248 261
@@ -287,8 +300,20 @@ main() {
287 log_info "Extracting log entries..." 300 log_info "Extracting log entries..."
288 301
289 # Get raw log lines containing [PURGATORY_EXPIRED] 302 # Get raw log lines containing [PURGATORY_EXPIRED]
290 local raw_lines 303 # Capture stderr separately to detect journalctl errors
291 raw_lines=$(eval "$journal_cmd" 2>/dev/null | grep '\[PURGATORY_EXPIRED\]' || true) 304 local raw_lines journal_stderr journal_exit
305 local temp_stderr
306 temp_stderr=$(mktemp)
307
308 raw_lines=$(eval "$journal_cmd" 2>"$temp_stderr" | grep '\[PURGATORY_EXPIRED\]' || true)
309 journal_exit=$?
310 journal_stderr=$(cat "$temp_stderr" 2>/dev/null || true)
311 rm -f "$temp_stderr"
312
313 # Report any journalctl errors (but don't fail - empty logs are valid)
314 if [[ -n "$journal_stderr" ]]; then
315 log_warn "journalctl reported: $journal_stderr"
316 fi
292 317
293 if [[ -z "$raw_lines" ]]; then 318 if [[ -z "$raw_lines" ]]; then
294 log_warn "No [PURGATORY_EXPIRED] entries found in logs." 319 log_warn "No [PURGATORY_EXPIRED] entries found in logs."