Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

2.3 KB
Raw Blame
#!/bin/sh
case "${1:-}" in
    install|upgrade|rollback)
        /usr/bin/hn-os _require-pc-system || exit "$?"
        ;;
esac
if [ "${1:-}" = hardware ]; then
    shift
    exec /usr/bin/python3 /usr/lib/harness-os/hardware.py report "$@"
fi
if [ "${1:-}" = install ]; then
    shift
    if [ "$#" = 0 ] && [ "$(id -u)" != 0 ]; then
        exec /usr/lib/harness-os/open-install
    fi
    exec /usr/bin/python3 /usr/lib/harness-os/install.py "$@"
fi
if [ "${1:-}" = upgrade ]; then
    shift
    if [ "$#" = 0 ]; then
        exec /usr/bin/python3 /usr/lib/harness-os/release_update.py apply
    fi
    exec /usr/bin/python3 /usr/lib/harness-os/runtime_update.py apply "$@"
fi
if [ "${1:-}" = rollback ]; then
    shift
    exec /usr/bin/python3 /usr/lib/harness-os/runtime_update.py rollback "$@"
fi
if [ "${1:-}" = factory-reset ]; then
    # As just installed: off its account, everything in /home/me gone (projects, sign-ins, harnesses,
    # the hn/CLI updates it downloaded), Wi-Fi forgotten, SSH off, the installation's password again,
    # the setup hotspot open for a phone. At the computer only (a phone signs it out instead), and
    # later its reset button. Not `harness reset`, the CLI's own.
    shift
    [ "$(id -u)" = 0 ] && exec /usr/bin/python3 /usr/lib/harness-os/setup.py reset "$@"
    exec sudo /usr/bin/python3 /usr/lib/harness-os/setup.py reset "$@"
fi
if [ "${1:-}" = update ]; then
    # Everything Super+u updates, from a terminal: the OS package, hn, the CLI and its daemon.
    # The CLI's own self-update would only race the OS's activation (ADAPTER_UPDATE_DISABLE below).
    shift
    exec /usr/bin/python3 /usr/lib/harness-os/live_update.py update "$@"
fi
if [ "${1:-}" = updates ]; then
    shift
    if [ -t 0 ] && [ -z "${SSH_CONNECTION:-}${SSH_TTY:-}" ] &&
       { [ "$#" = 0 ] || { [ "$#" = 1 ] && [ "$1" = screen ]; }; }; then
        /usr/lib/harness-os/open-updates --view
        updates_status=$?
        # No hn client (or SSH): retain the ordinary terminal inspection.
        [ "$updates_status" = 3 ] || exit "$updates_status"
    fi
    exec /usr/bin/python3 /usr/lib/harness-os/live_update.py "$@"
fi
. /usr/lib/harness-os/runtime-path
# The OS owns activation so an update cannot race its systemd supervisor.
export ADAPTER_UPDATE_DISABLE=true
exec /usr/bin/node "$harness_runtime/cli.mjs" "$@"