Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ set_tests_properties(npu_repack_path PROPERTIES SKIP_RETURN_CODE 77)
# layouts: no root, no mounts, no device, no VM.
add_test(NAME one_bit_update_slots
COMMAND sh ${CMAKE_SOURCE_DIR}/tests/one_bit_update_slots_test.sh ${CMAKE_SOURCE_DIR})
add_test(NAME one_bit_network_conf
COMMAND sh ${CMAKE_SOURCE_DIR}/tests/one_bit_network_conf_test.sh ${CMAKE_SOURCE_DIR})
add_test(NAME npu_import_contract
COMMAND ${CMAKE_SOURCE_DIR}/tests/npu_import_contract.sh ${CMAKE_SOURCE_DIR})
set_tests_properties(npu_import_contract PROPERTIES SKIP_RETURN_CODE 77)
Expand Down
9 changes: 4 additions & 5 deletions docs/os-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,10 @@ named here as what they are:
| logging | `06onboard-logs` keeps the boot's logs on `/data/logs` — the partition, not the filesystem that the next appliance replaces | `/data/logs` non-empty on the installed boot |
| packages and services | `apt` works and its packages land in the save layer; the appliance's own services are `/etc/init.d` scripts, which is what `rc.services` runs (there is no systemd here, and nothing pretends there is) | — |

**Not present, and named:** a **persisted static address**. The console's "set a static address" is *session only* on
purpose — a wrong one on a headless box is a walk to the machine — and the persistent form is not a one-line change: on
this base connman owns the interface, so it has to be a connman service config, with the console (or the install
screen, #710) as its recovery path. That is the remaining piece of engine#712's third item, and it is a product decision
rather than a row to add to a gate.
| an optional static address | `1bit-network set-static <addr/prefix> [gateway] [dns…]` writes **`/data/net.conf`** — on the data partition, so it outlives an appliance update — and `/etc/init.d/14onboard-net` applies it at boot through **connman's own CLI** (`connmanctl config <service> --ipv4 manual …`), with `ip` only as the fallback for a link connman has no service for yet. The console's static action stays session-only, because a wrong address on a headless box is a walk to the machine; this one is persistent **and reversible in one command**: `1bit-network reset` deletes the file and hands the interface back to DHCP. An unparsable or unusable file is not applied at all — the boot leaves the link on DHCP and says so in `/var/log/1bit-network.log` | `tests/one_bit_network_conf_test.sh` (the address and file validation, 26 arms, no root or interface needed) and the installed boot's `1bit-network` rows |

**Recovery, stated where someone under pressure will look:** `1bit-network reset` on tty1, the serial console, or the
console menu's bash item. The file is `/data/net.conf`; deleting it is the same thing.

## The Ubuntu plan (history, not a target)

Expand Down
1 change: 1 addition & 0 deletions os/v3/puppy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ this recipe ships are:
| `05onboard-data` | finds `1BIT-DATA` (`1bit.data=` on the boot line, else the label), mounts it at `/data`, creates the contract dirs, points `/etc/1bit/lemond.conf` at `/data/lemonade/lemond.conf`, copies `/data/ssh/authorized_keys` and links the host key from `/data/ssh`, and registers `/data/models` in Lemonade's `user_models.json` |
| `10lemonade` | starts `/opt/1bit-package/lemond-onebit`, binds `0.0.0.0:13305`, logs to `/var/log/lemond-onebit.log`. **No key by default** (cycle 20, the owner's "blank key": the appliance ships like stock Lemonade). A key is opt-in and lives in `/etc/1bit/lemond.conf` (mode 600, a symlink onto `/data`) — console menu item 1 mints one, removes it, and restarts this service so lemond comes up in the other mode; nothing else in the image holds it |
| `07onboard-user` | **the installed machine's normal account** (engine#712): on an installed boot only (`/data` mounted with `1bit-install`'s `.installed` on it) it creates `onebit` — home, bash, **locked password** so a key is the only way in — installs `/data/ssh/authorized_keys` as its `0600` key file (re-applied at every installed boot, exactly as `20onboard-ssh` does for root), and appends **one** sudo rule, `onebit ALL=(ALL) NOPASSWD: ALL`, backed up and proved with `sudo -n true` as that user, rolled back if it fails. A live stick exits without touching anything: a machine that forgets stays root-only |
| `14onboard-net` + `usr/local/bin/1bit-network` | **the persistent network identity** (engine#712): `1bit-network set-static <addr/prefix> [gateway] [dns…]` validates the answer, writes `/data/net.conf` (data partition, so it survives an appliance update) and applies it now through connman's own CLI; `14onboard-net` applies the same file at every boot, and does nothing at all when the file is absent or does not validate (a bad file leaves the link on DHCP rather than half-applying). `1bit-network reset` is the whole recovery path: it deletes the file and gives the interface back to DHCP. The console's own static action stays session-only on purpose |
| `20onboard-ssh` | `ssh-keygen -A`, `/root/.ssh` 700 + `authorized_keys` 600, then sshd. An image with no key provisions no listener |
| `21serial-console` | a root shell on `/dev/ttyS0`, only when the command line carries `1bit.serial=1` (that shell has no password, so it is opt-in) |
| `26onboard-board` | `os/mini/board.sh` as `/usr/sbin/1bit-board` (the path release-check's `fans` row reads): EC fan curve, power profile and the detached boost loop, on a board whose DMI it knows; on any other machine it writes nothing and says so |
Expand Down
5 changes: 4 additions & 1 deletion os/v3/puppy/container-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ if [ -n "${PAYLOAD:-}" ]; then
install -D -m 755 /recipe/embed/usr/local/bin/1bit-logs "$skeleton/usr/local/bin/1bit-logs"
# engine#712: the installed machine's OS-level update (the other slot plus one GRUB default flip)
install -D -m 755 /recipe/embed/usr/local/bin/1bit-update "$skeleton/usr/local/bin/1bit-update"
# engine#712: the persistent network identity (a static address on /data, applied at boot, one command to forget)
install -D -m 755 /recipe/embed/usr/local/bin/1bit-network "$skeleton/usr/local/bin/1bit-network"
install -D -m 755 /recipe/embed/etc/init.d/06onboard-logs "$skeleton/etc/init.d/06onboard-logs"
install -D -m 755 /recipe/embed/etc/init.d/08onboard-presets "$skeleton/etc/init.d/08onboard-presets"
install -D -m 755 /recipe/embed/root/Startup/1bit-lemonade-webapp \
Expand Down Expand Up @@ -357,7 +359,7 @@ if [ -n "${PAYLOAD:-}" ]; then
chmod 0755 "$skeleton/usr/local/bin/1bit-tty1"
chmod 0755 "$skeleton"/etc/init.d/03onboard-efivars "$skeleton"/etc/init.d/05onboard-data \
"$skeleton"/etc/init.d/06onboard-logs "$skeleton"/etc/init.d/07onboard-user \
"$skeleton"/etc/init.d/08onboard-presets \
"$skeleton"/etc/init.d/08onboard-presets "$skeleton"/etc/init.d/14onboard-net \
"$skeleton"/etc/init.d/10lemonade \
"$skeleton"/etc/init.d/18onboard-mdns \
"$skeleton"/etc/init.d/20onboard-ssh "$skeleton"/etc/init.d/21serial-console \
Expand Down Expand Up @@ -648,6 +650,7 @@ if [ -n "${PAYLOAD:-}" ]; then
usr/local/bin/1bit-record usr/local/bin/1bit-lemonade-webapp \
usr/local/bin/1bit-webapp-proxy usr/local/bin/1bit-desktop usr/local/bin/1bit-logs \
etc/init.d/06onboard-logs etc/init.d/07onboard-user etc/init.d/08onboard-presets \
etc/init.d/14onboard-net usr/local/bin/1bit-network \
root/Startup/1bit-lemonade-webapp \
etc/personal_settings_popup_disabled etc/1bit/palemoon-prefs.js \
etc/init.d/24onboard-webapp opt/1bit/webapp/index.html \
Expand Down
99 changes: 99 additions & 0 deletions os/v3/puppy/embed/etc/init.d/14onboard-net
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/sh
# Copyright 2026 bong-water-water-bong
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# /etc/init.d/14onboard-net - apply the persistent network identity, if an install has one (engine#712).
#
# `/data/net.conf` is written by `1bit-network set-static` and lives on the DATA partition, so it survives an appliance
# update (nothing the OS set carries is touched). This runs after 05onboard-data has mounted /data and before the
# services that talk to the network; with no file, or a file that does not validate, it does NOTHING and says so - a
# machine that cannot reach the LAN is worse than one on DHCP, and the repair path has to stay obvious:
#
# recovery: 1bit-network reset (tty1, the serial console, or the console menu's bash item)
#
# It never writes the file, never guesses an address, and never leaves the interface without one: connman is asked for
# the manual configuration first (it owns the link on this base), and `ip` is only the fallback for a boot where connman
# has no service for that interface yet.
set -u

# shellcheck disable=SC2154 # iface/static/gateway/dns are set by read_conf, sourced from 1bit-network below
iface=''; static=''; gateway=''; dns='' # set by read_conf; defined here for `set -u`
DATA=/data
CONF=$DATA/net.conf
LOG=/var/log/1bit-network.log
log() { printf '%s\n' "$*" | tee -a "$LOG"; }

[ "${1:-start}" = "stop" ] && exit 0
mkdir -p /tmp 2> /dev/null
: >> "$LOG" 2> /dev/null || LOG=/dev/null

[ -f "$CONF" ] || { log "14onboard-net: no $CONF: the interface stays on DHCP (connman)"; exit 0; }

# the same parse and validation as 1bit-network, sourced rather than copied: one definition of "a usable net.conf"
NETWORK=/usr/local/bin/1bit-network
if [ -r "$NETWORK" ]; then
# shellcheck disable=SC1090 # the path is the image's own, and this is the point: one definition of the format
ONEBIT_NETWORK_LIB=1 . "$NETWORK"
fi
if ! command -v read_conf > /dev/null 2>&1 || ! command -v conf_ok > /dev/null 2>&1; then
log "14onboard-net: cannot load the parser from $NETWORK: leaving the network alone (recovery: 1bit-network reset)"
exit 0
fi

read_conf "$CONF"
if ! why=$(conf_ok 2>&1); then
log "14onboard-net: $CONF is not usable ($why): leaving the network on DHCP. Recovery: 1bit-network reset"
exit 0
fi

# wait for the interface to exist: on a cold boot the driver may still be binding when rc.services starts
i=0
while [ ! -e "/sys/class/net/$iface" ] && [ $i -lt 20 ]; do sleep 1; i=$((i + 1)); done
if [ ! -e "/sys/class/net/$iface" ]; then
log "14onboard-net: $iface did not appear in 20 s: leaving the network alone"
exit 0
fi

applied=no
if command -v connmanctl > /dev/null 2>&1; then
# the service connman has for this interface: "<type>_<mac>_<name>", looked up by the service list rather than
# guessed, and only the connected one (`*` marker) is reconfigured
svc=$(connmanctl services 2> /dev/null | awk -v i="$iface" '/^\*/ { print $2; exit }')
if [ -n "$svc" ]; then
if [ -n "$gateway" ]; then
connmanctl config "$svc" --ipv4 manual "$static" "$gateway" $dns >> "$LOG" 2>&1
else
connmanctl config "$svc" --ipv4 manual "$static" >> "$LOG" 2>&1
fi
[ $? -eq 0 ] && applied=yes
fi
fi

if [ "$applied" = no ]; then
# connman has no service for it (a boot before connman settled, or a bare interface): put it on with ip, which
# connman leaves alone for as long as it has no service of its own for that link
if ip addr add "$static" dev "$iface" >> "$LOG" 2>&1; then
[ -n "$gateway" ] && ip route replace default via "$gateway" dev "$iface" >> "$LOG" 2>&1
applied=yes
fi
fi

if [ "$applied" = yes ]; then
log "14onboard-net: $iface carries $static${gateway:+ via $gateway} from $CONF"
exit 0
fi
log "14onboard-net: could not apply $static to $iface (see $LOG); the link keeps whatever DHCP gave it." \
"Recovery: 1bit-network reset"
exit 0
Loading
Loading