#!/sbin/openrc-run
# B12R: Wi-Fi LAN router on top of aurora-modem (bearer) + aurora-wifi (AP). Waits for both in the background, then 'aurora-router up'.
# NOT in any runlevel until the cache kernel has nf_tables (7.2.7-aurora-b12); start manually: rc-service aurora-router start
description="Aurora Wi-Fi -> LTE router (nftables NAT + dnsmasq)"
depend() { need aurora-modem aurora-wifi; }
start() {
	ebegin "aurora-router (waits for START OK + AP ENABLED)"
	( i=0; while [ $i -lt 600 ]; do grep -q "=== START OK" /run/aurora-modem/lifecycle.log 2>/dev/null && grep -q "=== AP ENABLED" /run/aurora-wifi/wifi.log 2>/dev/null && break; sleep 2; i=$((i+2)); done
	  /usr/sbin/aurora-router up >> /run/aurora-router.service.log 2>&1 ) &
	eend 0
}
stop() { ebegin "aurora-router down"; /usr/sbin/aurora-router down >> /run/aurora-router.service.log 2>&1; eend $?; }
status() { /usr/sbin/aurora-router status; }
