#!/bin/sh
# /etc/init.d/rcS — brintOS busybox machine one-shot bring-up (HWJS-C-2.b).
#
# Static eth0 configuration. udhcpc is OFF on this machine (no DHCP server
# behind the browser NIC); the wasm32 virtio-net device (device 2) sits on a
# slirp-style 10.0.2.0/24 with the HardwareJS host answering as the 10.0.2.2
# gateway. For C-2.b the host side is the minimal ARP + ICMP/UDP echo TEST
# backend (hardwarejs/src/devices/virtio_net.ts); the HWJS-C-2.c MITM shim
# (fetch mapping / DNS / key gate) replaces it host-side — this guest config
# is already the final shape.
#
# Runs from EITHER boot shape, exactly once:
#   - busybox init (the live machine's /init): the ::sysinit inittab entry.
#   - init=/bin/sh (gate topologies): /etc/brintos-rc's pid-1 guard block.
# Guarded on eth0 existing so a kernel booted without wasm_virtnet= (or a
# pre-C-2.b kernel) degrades loudly, not with an `ip` error cascade.
# Loopback is NOT configured here (issue #76): the wasm32 kernel boot path
# (arch_kernel_init_pre_run_init) brings lo UP itself — devinet auto-assigns
# 127.0.0.1/8 — because images with no network init at all (user dev
# machines) had an unaddressed lo. The rc block issue #51 added here owned
# it historically; ownership moved to the kernel, one point for ALL images.

if ip link show eth0 >/dev/null 2>&1; then
	ip link set eth0 up
	ip addr add 10.0.2.15/24 dev eth0
	ip route add default via 10.0.2.2
else
	echo "brintos rcS: no eth0 (virtio-net absent) — network not configured"
fi
