From ca6346428ed41f8bf344a8835c7581cdaa871b91 Mon Sep 17 00:00:00 2001 From: shocknet-justin Date: Tue, 26 Aug 2025 17:44:22 -0400 Subject: [PATCH] better log check --- scripts/extract_nprofile.sh | 29 ++++++++++++++--------------- scripts/install.sh | 1 + 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/extract_nprofile.sh b/scripts/extract_nprofile.sh index 1178c719..58533b66 100644 --- a/scripts/extract_nprofile.sh +++ b/scripts/extract_nprofile.sh @@ -17,31 +17,30 @@ get_log_info() { log "Checking wallet status... This may take a moment." - # Wait for unlocker log file + TIMESTAMP_FILE="/tmp/pub_install_timestamp" + + # Wait for a new unlocker log file to be created while [ $(($(date +%s) - START_TIME)) -lt $MAX_WAIT_TIME ]; do - latest_unlocker_log=$(ls -1t ${LOG_DIR}/components/unlocker_*.log 2>/dev/null | head -n 1) - [ -n "$latest_unlocker_log" ] && break + # Find a log file that is newer than our installation timestamp + latest_unlocker_log=$(find "${LOG_DIR}/components/" -name "unlocker_*.log" -newer "$TIMESTAMP_FILE" -print0 2>/dev/null | xargs -0 ls -1t 2>/dev/null | head -n 1) + if [ -n "$latest_unlocker_log" ]; then + break + fi sleep $WAIT_INTERVAL done if [ -z "$latest_unlocker_log" ]; then - log "Error: No unlocker log file found. Please check the service status." + log "Error: No new unlocker log file found after starting services. Please check the service status." exit 1 fi - # Get the initial file size instead of line count - initial_size=$(stat -c %s "$latest_unlocker_log") - - # Wait for new wallet status in log file + # Now that we have the correct log file, wait for the wallet status message + START_TIME=$(date +%s) while [ $(($(date +%s) - START_TIME)) -lt $MAX_WAIT_TIME ]; do - current_size=$(stat -c %s "$latest_unlocker_log") - if [ $current_size -gt $initial_size ]; then - latest_entry=$(tail -c +$((initial_size + 1)) "$latest_unlocker_log" | grep -E "unlocker >> (the wallet is already unlocked|created wallet with pub:|unlocked wallet with pub)" | tail -n 1) - if [ -n "$latest_entry" ]; then - break - fi + latest_entry=$(grep -E "unlocker >> (the wallet is already unlocked|created wallet with pub:|unlocked wallet with pub)" "$latest_unlocker_log" | tail -n 1) + if [ -n "$latest_entry" ]; then + break fi - initial_size=$current_size sleep $WAIT_INTERVAL done diff --git a/scripts/install.sh b/scripts/install.sh index 66d80416..e7f22303 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -84,6 +84,7 @@ else install_lightning_pub "$REPO_URL" || log_error "Failed to install Lightning.Pub" 1 log "Starting services..." + touch /tmp/pub_install_timestamp start_services $lnd_status $pub_upgrade_status || log_error "Failed to start services" 1 get_log_info || log_error "Failed to get log info" 1