#!/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. # # EACH MUTATION IS GUARDED ON ITS OWN CURRENT STATE, and that is what makes the # "Runs from EITHER boot shape" promise above survivable. Under guest-root the # C init has ALREADY configured both by the time this runs (guestroot-init # net_up(), step 3), and it gets away with re-applying them because its ioctls # are idempotent by construction: SIOCSIFADDR is a SET, so re-setting the same # address is a no-op, and SIOCADDRT explicitly tolerates EEXIST. busybox's `ip` # is not that shape — it speaks netlink with NLM_F_EXCL, so on an # already-configured machine both `add` commands answered # # RTNETLINK answers: File exists # # on EVERY boot. That is worth removing not because it is untidy but because it # is indistinguishable from a real failure: the one line the operator must be # able to trust for "the network did not come up" was being printed by healthy # machines, every time. # # WHAT IS DELIBERATELY *NOT* DONE HERE: the `add` commands are not silenced. # `2>/dev/null` on them would have removed the same noise in one character and # taken every genuine netlink refusal with it — no carrier, a bad prefix, a # device that vanished between the guard and the add. Only the PROBES are # redirected (the same convention as the `ip link show` guard above); the # mutations keep stderr, so a failure that is not "already configured" is still # exactly as loud as it was before. if ip link show eth0 >/dev/null 2>&1; then ip link set eth0 up ip addr show dev eth0 2>/dev/null | grep -q 'inet 10\.0\.2\.15/24' || ip addr add 10.0.2.15/24 dev eth0 ip route show 2>/dev/null | grep -q '^default ' || ip route add default via 10.0.2.2 else echo "brintos rcS: no eth0 (virtio-net absent) — network not configured" fi