Skip to main content

Testing Auto-Update Script

This guide shows you how to test the auto-update script in a Docker container that simulates the router environment.

Quick Start

Run the automated test script from the router-files directory:

cd router-files
./docker/test-in-docker.sh

This will:

  1. Build a Docker image with the router environment
  2. Run the auto-update script inside the container
  3. Display all the logging output

What's Simulated

The Docker container creates:

  • /root/scripts/auto-update.sh - The auto-update script
  • /root/supabase_config.env - Supabase configuration
  • /etc/router_imei - Test IMEI: 863141055240095
  • /root/scripts/version.txt - Initial version: v2.1.0
  • /var/log/auto-update.log - Log file

Expected Output

The script will:

  1. Connect to Supabase to check for updates
  2. Download the update package if a newer version is available
  3. Verify the checksum
  4. Extract and install the update
  5. Test the updated scripts

Manual Testing

To test interactively:

# Build the image
docker build -t router-test -f docker/Dockerfile.test router-files

# Run interactively
docker run --rm -it router-test /bin/sh

# Inside container
cd /root/scripts
./auto-update.sh

Rebuilding

After modifying the script, rebuild:

./docker/test-in-docker.sh

Or manually:

docker build -t router-test -f docker/Dockerfile.test router-files

Debugging

All logs are written to both the console and /var/log/auto-update.log inside the container.

The script includes extensive logging to help identify issues at each step:

  • Before curl: Shows URL, IMEI, and API key presence
  • After curl: Shows exit code and HTTP status
  • Response processing: Shows response length and preview
  • JSON parsing: Shows each parsing step
  • Update process: Shows download, verify, install, and test status