Files

2.0 KiB

MikroTik Router Onboarding via Portal

When the user wants an onboarding section for MikroTik routers in the portal, the flow follows a "generate script → run on router → auto-checks in" pattern.

Mockup layout

The mockup page at /root/portal-mockup/onboard-router.html shows:

Left column — form

  • Customer selector — dropdown of existing customers (or create new)
  • Router name/model — optional fields
  • Generate button — produces the registration script
  • Generated script panel — syntax-highlighted RouterOS script with Copy/Download buttons
    • Sets system identity to a standard format (e.g. RTR-CUSTOMER-01)
    • Creates a read-only monitoring user
    • POSTs registration data to the portal API
    • Sets up a 60-second heartbeat scheduler
    • Token scoped to customer + expires in 24 hours

Right column — status + instructions

  • How It Works — three-step explainer: Generate → Run on Router → Auto-Connects
  • Status card — shows "Waiting for first check-in" or "Online" with last heartbeat timestamp
  • Recently Onboarded — list of recently added routers with green dot status indicators

Registration script structure

# IT Pro Partner - Router Registration
/system identity
set name=RTR-CUSTOMER-01

/user add name=itpp-monitor \
  group=read password="$(/tool fetch url=...)"

/tool fetch url="https://portal.itpropartner.com/api/register" \
  http-method=post \
  http-data="{\"identity\":\"RTR-CUSTOMER-01\",\"token\":\"TOKEN\"}"

/system scheduler add name=heartbeat interval=1m \
  on-event="/tool fetch url=.../heartbeat"

Portal-side requirements

  • API endpoint: /api/register — receives registration POST, validates token, stores device identity
  • API endpoint: /api/heartbeat — receives 60-second keepalive, updates last_seen timestamp
  • API endpoint: /api/register/token — generates one-time token per customer, 24h expiry
  • Dashboard shows: device name, customer, last heartbeat time, firmware, public IP