# Boot and Init

## Init System

The rootfs uses BusyBox init via `/etc/inittab`. There is no systemd unit layout in this extraction.

Important `/etc/inittab` behavior:

1. Mounts proc at `/proc`.
2. Creates `/dev/pts` and `/dev/shm`.
3. Runs `mount -a`.
4. Creates `/run/lock/subsys`.
5. Runs `swapon -a`.
6. Links `/dev/fd`, `/dev/stdin`, `/dev/stdout`, and `/dev/stderr` into proc fd paths.
7. Sets hostname from `/etc/hostname`.
8. Runs `/etc/init.d/rcS`.
9. On shutdown, runs `/etc/init.d/rcK`, then `swapoff -a`, then `umount -a -r`.

Console gettys are present but commented out:

- Serial console: `console::respawn:/sbin/getty -L console 0 vt100`
- HDMI console: `tty1::respawn:/sbin/getty -L tty1 0 vt100`

That means the extracted configuration does not spawn an interactive login shell by default.

## rcS Startup Order

`/etc/init.d/rcS` runs all `/etc/init.d/S??*` files in lexical order. For this rootfs:

| Order | Script | Purpose |
| --- | --- | --- |
| 01 | `S01seedrng` | Seed RNG support. Comment references `/data/seedrng`. |
| 01 | `S01syslogd` | Starts syslog daemon. |
| 02 | `S02klogd` | Starts kernel log daemon. |
| 02 | `S02sysctl` | Applies sysctl settings. |
| 10 | `S10udev` | Starts udev. |
| 12 | `S12lvds_panel` | Starts boot display on the LVDS panel. |
| 30 | `S30dbus` | Starts D-Bus. |
| 40 | `S40bluetoothd` | Starts Bluetooth daemon. |
| 40 | `S40network` | Runs `/sbin/ifup -a`. |
| 50 | `S50crond` | Starts cron daemon. No cron job files were present under `/etc/cron*` in this extraction. |
| 55 | `S55spike3` | Spike-specific Bluetooth, audio, and module setup. |
| 95 | `S95game` | Kernel update check, persistent directory setup, core dump policy, monitors, game launch, update scanner. |

## Shutdown Order

`/etc/init.d/rcK` reverses the `/etc/init.d/S??*` list and calls each script with `stop`.

## Spike-specific Boot Actions

`S12lvds_panel`:

- Sources `/etc/init.d/shared`.
- Starts `$BOOT_DISPLAY` in the background.
- `$BOOT_DISPLAY` resolves first to `/games/spike3/bin/boot_display`, falling back to `/usr/local/spike/boot_display`.

`S55spike3`:

- Runs `bluetoothctl power on`.
- Registers a `KeyboardOnly` Bluetooth agent and makes it the default agent.
- Starts BlueALSA as A2DP source: `/usr/bin/bluealsa -p a2dp-source &`.
- Loads `i2c-dev`, `exfat`, and `fuse`.

`S95game`:

- Checks staged kernel update files under `/connectivity/os_update`.
- Runs a previous `/connectivity/os_update/post_install_hook.sh` if present.
- Creates persistent ALSA/Bluetooth directories under `/connectivity`.
- Ensures `/var/lib/alsa`, `/var/lib/bluetooth`, and `/var/lib/bluealsa` point into `/connectivity`.
- Overrides hostname from `/connectivity/hostname` if present.
- Prepares `/connectivity/dump/cores`.
- Sets `ulimit -c unlimited`.
- Sets core pattern to `/connectivity/dump/cores/core.%h.%t`.
- Starts `reboot_monitor`, `conagent_monitor`, and `game_monitor` if `/games/game` exists.
- Starts `/etc/init.d/update` in the background so USB/downloaded `.spk` updates can interrupt the running game.
