mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-11 05:13:01 +00:00
fix: Pass both -y flag and env var to first_time_install.sh for non-interactive mode
Ensure first_time_install.sh runs in non-interactive mode by passing both: 1. The -y command-line flag 2. The LEDMATRIX_ASSUME_YES=1 environment variable This is necessary because first_time_install.sh re-executes itself with sudo if not running as root (line 131), and we need to ensure the non-interactive flag is preserved through the re-execution. Also added debug_install.sh diagnostic script to help troubleshoot installation failures on the Pi.
This commit is contained in:
81
scripts/install/debug_install.sh
Executable file
81
scripts/install/debug_install.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
# Quick diagnostic script to check why first_time_install.sh is failing
|
||||
# Run this on the Pi: bash debug_install.sh
|
||||
|
||||
echo "=== Diagnostic Script for Installation Failure ==="
|
||||
echo ""
|
||||
|
||||
echo "1. Checking if running as root:"
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo " ✓ Running as root (EUID=$EUID)"
|
||||
else
|
||||
echo " ✗ NOT running as root (EUID=$EUID, user=$(whoami))"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "2. Checking if first_time_install.sh exists:"
|
||||
if [ -f "./first_time_install.sh" ]; then
|
||||
echo " ✓ Found ./first_time_install.sh"
|
||||
echo " Checking if executable:"
|
||||
if [ -x "./first_time_install.sh" ]; then
|
||||
echo " ✓ Is executable"
|
||||
else
|
||||
echo " ✗ NOT executable (fix with: chmod +x first_time_install.sh)"
|
||||
fi
|
||||
else
|
||||
echo " ✗ NOT found in current directory"
|
||||
echo " Current directory: $(pwd)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "3. Testing argument passing with -y flag:"
|
||||
echo " Running: bash ./first_time_install.sh -y --help 2>&1 | head -20"
|
||||
if [ -f "./first_time_install.sh" ]; then
|
||||
bash ./first_time_install.sh -y --help 2>&1 | head -20 || echo " ✗ Script failed or not found"
|
||||
else
|
||||
echo " ✗ first_time_install.sh not found"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "4. Checking environment variable:"
|
||||
echo " LEDMATRIX_ASSUME_YES=${LEDMATRIX_ASSUME_YES:-not set}"
|
||||
echo " Testing with env: env LEDMATRIX_ASSUME_YES=1 bash -c 'echo ASSUME_YES would be set'"
|
||||
env LEDMATRIX_ASSUME_YES=1 bash -c 'echo " ASSUME_YES would be: ${LEDMATRIX_ASSUME_YES:-not set}"'
|
||||
echo ""
|
||||
|
||||
echo "5. Testing sudo with arguments:"
|
||||
echo " Command: sudo -E env LEDMATRIX_ASSUME_YES=1 bash ./first_time_install.sh -y --help 2>&1 | head -20"
|
||||
if [ -f "./first_time_install.sh" ]; then
|
||||
sudo -E env LEDMATRIX_ASSUME_YES=1 bash ./first_time_install.sh -y --help 2>&1 | head -20 || echo " ✗ Sudo command failed"
|
||||
else
|
||||
echo " ✗ first_time_install.sh not found"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "6. Checking /tmp permissions:"
|
||||
echo " /tmp is writable: $([ -w /tmp ] && echo 'YES' || echo 'NO')"
|
||||
echo " /tmp permissions: $(stat -c '%a' /tmp 2>/dev/null || echo 'unknown')"
|
||||
echo " TMPDIR: ${TMPDIR:-not set}"
|
||||
echo ""
|
||||
|
||||
echo "7. Checking stdin/TTY:"
|
||||
if [ -t 0 ]; then
|
||||
echo " ✓ stdin is a TTY (interactive)"
|
||||
else
|
||||
echo " ✗ stdin is NOT a TTY (non-interactive/pipe)"
|
||||
echo " This is expected when running via curl | bash"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "8. Latest installation log:"
|
||||
LOG_FILE=$(ls -t /home/ledpi/LEDMatrix/logs/first_time_install_*.log 2>/dev/null | head -1)
|
||||
if [ -n "$LOG_FILE" ]; then
|
||||
echo " Found: $LOG_FILE"
|
||||
echo " Last 30 lines:"
|
||||
tail -30 "$LOG_FILE" | sed 's/^/ /'
|
||||
else
|
||||
echo " No log files found in /home/ledpi/LEDMatrix/logs/"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "=== Diagnostic Complete ==="
|
||||
@@ -273,13 +273,15 @@ main() {
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
chmod 1777 /tmp 2>/dev/null || true
|
||||
export TMPDIR=/tmp
|
||||
# Run in non-interactive mode with ASSUME_YES
|
||||
# Run in non-interactive mode with ASSUME_YES (both -y flag and env var for safety)
|
||||
export LEDMATRIX_ASSUME_YES=1
|
||||
bash ./first_time_install.sh -y
|
||||
else
|
||||
sudo chmod 1777 /tmp 2>/dev/null || true
|
||||
export TMPDIR=/tmp
|
||||
# Pass environment variable for non-interactive mode and preserve TMPDIR
|
||||
sudo -E env TMPDIR=/tmp LEDMATRIX_ASSUME_YES=1 bash ./first_time_install.sh
|
||||
# Pass both -y flag AND environment variable for non-interactive mode
|
||||
# This ensures it works even if the script re-executes itself with sudo
|
||||
sudo -E env TMPDIR=/tmp LEDMATRIX_ASSUME_YES=1 bash ./first_time_install.sh -y
|
||||
fi
|
||||
INSTALL_EXIT_CODE=$?
|
||||
set -e # Re-enable errexit
|
||||
|
||||
Reference in New Issue
Block a user