Skip to main content

Manual Deployment (SSH)

Use this guide to install all monitoring scripts, crontab, configuration, and perform registration manually over SSH without using mac-deploy.sh.

Prerequisites

Before you begin:

  • SSH access to the router as root (or an admin with equivalent permissions)
  • A machine with scp and ssh
  • From this repository, have these local files available from router-files/files/:
    • scripts/ directory (all *.sh scripts)
    • crontab
    • supabase_config.env
    • VERSION (in router-files/files/VERSION)

Note: All scripts install to /root/scripts on the router.

1) Connect to the Router

# Replace with your router IP/hostname and user
ssh [email protected]

Verify you have write access to /root:

mkdir -p /root && echo OK

2) Create Directories

On the router:

mkdir -p /root/scripts

3) Copy Files to the Router

From your local machine (in the repo root router-files/files/):

# Copy all monitoring scripts
scp -r scripts/*.sh [email protected]:/root/scripts/

# Copy Supabase configuration
scp supabase_config.env [email protected]:/root/supabase_config.env

# Copy crontab definition
scp crontab [email protected]:/tmp/crontab_new

# Copy deployment version (optional but recommended)
scp VERSION [email protected]:/root/scripts/version.txt

Then on the router, make scripts executable:

chmod +x /root/scripts/*.sh

4) Package Dependencies (Router)

These scripts rely on the following tools being available on the router:

  • curl
  • nmap
  • tar
  • sha256sum (often via coreutils-sha256sum)
  • a modem AT command utility providing at-cmd (vendor/tooling dependent)

5) Install Crontab

Apply the provided crontab:

crontab /tmp/crontab_new && rm -f /tmp/crontab_new
crontab -l

This schedules the monitoring scripts and auto-update routines as defined in crontab.

5.5) Install Init Script

Copy and enable the startup detection script:

# Copy init script
scp router-detect [email protected]:/etc/init.d/

# On router, make executable and enable
chmod +x /etc/init.d/router-detect
/etc/init.d/router-detect enable

This replaces the @reboot cron entry and handles router identity detection on boot. The init script will run 5 minutes after system startup to ensure all services are ready before detecting the router identity.

6) Configure Supabase

Copy the prepared config file from the repo to the router (already shown in step 3):

scp supabase_config.env [email protected]:/root/supabase_config.env

If you maintain per-environment values, provide the correct supabase_config.env for that environment before copying. No in-router editing is required.

7) Detect Router Identity and Register

Run the identity detection script which triggers registration:

cd /root/scripts
./detect_router_identity.sh

This will:

  • Detect the router IMEI and cache it (e.g., in /etc/router_imei)
  • Call register_router.sh to create/update the router record in the router_versions table

If needed, you can run registration directly:

./register_router.sh

8) Verify Deployment

Run these checks on the router:

# 1) Scripts present and executable
ls -la /root/scripts/*.sh

# 2) Crontab installed
crontab -l

# 3) Supabase config present
test -f /root/supabase_config.env && echo "supabase_config.env OK"

# 4) Version file present
test -f /root/scripts/version.txt && echo "version.txt OK" && cat /root/scripts/version.txt

9) Test Deployment

Run the bundled test runner on the router:

/root/scripts/test_deployment.sh

It will execute each script and report PASS/FAIL with a summary.

10) Next Steps

  • Confirm data arrives in your Supabase tables shortly after crontab runs
  • In the web UI, verify the router appears and update status reflects correctly
  • Adjust schedules or thresholds by editing /root/scripts or the crontab

Troubleshooting

  • Missing tools: ensure curl, nmap, tar, sha256sum, and any modem utilities are available
  • Network issues: verify router has internet access (ping 1.1.1.1, curl https://api.ipify.org)
  • Permissions: ensure all scripts are executable (chmod +x /root/scripts/*.sh)
  • Supabase credentials: confirm /root/supabase_config.env values are correct

Reference

  • Scripts install path: /root/scripts/
  • Config file: /root/supabase_config.env
  • Version file: /root/scripts/version.txt
  • Logs: use logread and dmesg on OpenWrt for runtime diagnostics