Glassworks frame agent
The shared root-side agent core for Glassworks frames Portable POSIX and mksh services that implement the FrameAgent contract once, so each device only brings thin configuration and hardware hooks.
On this page
Glassworks apps never ask for root. On rooted wall panels, privileged tasks run in a small root-side service that implements the frame agent contract: silent app updates, signed frame bundles, time zone persistence, Bluetooth MAC publishing, setup hotspot captive portal routing, resource overlays, and USB ADB key management.
This folder holds the shared POSIX and Android mksh implementation of those services. Instead of duplicating hundreds of lines of shell logic for every new board, each rooted frame supplies a small configuration file (glassworks_frame.sh), its init slot file (glassworks.rc), and a thin agent entrypoint (glassworks_agent.sh) that sources this core and adds any board-specific hooks.
Layout
| File | Role |
|---|---|
glassworks_loader.sh |
Signed frame-bundle loader and slot runner invoked by init (boot, run <slot>, install, check). Enforces Ed25519 signatures, monotonic anti-rollback floors, crash-loop fallback to boot copies, boot animation bind-mounting, and optional boot-time ro.adb.secure=1 hardening. |
glassworks_agent_lib.sh |
Shared shell library sourced by each frame's glassworks_agent.sh. Provides contract property helpers, verified app file hand-off (take_app_file), time zone enforcement, captive portal iptables rules (with automatic IPv6 NAT detection), Magisk RRO module management, Bluetooth MAC publishing, and USB ADB computer management. |
glassworks_update.sh |
Silent APK updater (app-updates). Validates package ownership, copies the staged APK into a root-only directory, installs it via pm install -r -S, verifies that only the frame's configured package bumped its versionCode, and survives mid-install framework restarts. |
glassworks_firstboot.sh |
First-boot provisioning (glassworks_firstboot slot). Authorizes the installer's baked ADB public key, enables USB ADB and Wi-Fi on a fresh panel, and optionally invokes a frame hook before enabling ADB. |
make-bundle.py |
Signed frame-bundle packer and Ed25519 signer (OpenSSL 3). Writes manifest and manifest.sig in the format glassworks_loader.sh verifies. |
verify/ |
Static musl C verifier (glassworks_verify.c, Monocypher 4.0.3 Ed25519 + TOCTOU-safe openat(O_NOFOLLOW) --copy/--move) and reproducible multi-arch Docker builder (armhf and aarch64). |
test/ |
Shared off-device POSIX/mksh test suite covering the loader, updater, first-boot provisioning, GW_DEV override precedence, time zone, captive portal IPv6 NAT detection, RRO overlays, and take_app_file. Bluetooth MAC publishing (bt_publish) and USB ADB approval/removal flows are covered by the per-frame root test suites below. |
Shared capabilities
| Capability | Functions in glassworks_agent_lib.sh |
Behavior |
|---|---|---|
| Property and contract helpers | say, setp, alive, sha256, ipt, gw_prepare_dir, gw_announce_agent |
Safe 91-byte setprop truncation, root-only state directories, and sys.glassworks.agent.* announcements. |
| Verified app file hand-off | take_app_file |
Copies or moves files from the kiosk app's private directory using glassworks_verify (openat with O_NOFOLLOW, UID, regular-file, link-count, and size checks), with an optional pure-shell fallback on boot images without the binary. |
time-zone |
tz_valid, tz_check, tz_start, tz_stop |
Keeps persist.glassworks.timezone applied via AlarmManager.setTimeZone, with configurable (off) handling and optional adoption of a pre-existing zone. |
hotspot-portal |
portal_has_nat6, portal_check, portal_start, portal_stop |
Redirects setup hotspot DNS (udp:53) and HTTP (tcp:80) to the app's local portal sockets (udp:8053, tcp:8098). Automatically detects whether the kernel supports ip6tables -t nat via /proc/net/ip6_tables_names. |
hotspot-name and RRO overlays |
ov_src, ov_apply, hn_say |
Stages and mounts static runtime resource overlay APKs through one Magisk module under a configurable overlay partition path (such as system/product/overlay or system/vendor/overlay), with in-place atomic APK replacement and clean undo. |
bluetooth-address |
bt_valid, bt_publish |
Reads the Bluetooth adapter's real MAC address once Android knows it, rejects placeholders, and writes it atomically to /data/glassworks-pub/bluetooth-address (0644, never logged). |
| USB ADB management | adb_harden, adb_restore, adb_list, adb_request, adb_allow, adb_remove, adb_start, adb_stop, adb_dialog_close |
Powers Manage's Security page: watches AdbDebuggingManager logs from system_server, handles allow/once/remove requests, disables Android's 7-day key timeout, restores non-revoked installer keys, and optionally enforces ro.adb.secure=1 and closes TCP ADB. |
Frame configuration (glassworks_frame.sh)
Every rooted frame ships a small glassworks_frame.sh next to the shared scripts in overlay.d/sbin/ (and as services/frame.sh inside signed frame bundles so existing boot images can update cleanly without reflashing). glassworks_loader.sh, glassworks_update.sh, and glassworks_firstboot.sh source it to configure frame identity and policy:
| Variable / hook | Required | Default | Purpose |
|---|---|---|---|
FRAME_ID |
Yes | — | Frame identifier matching frames/<id>/design/frame.json and signed bundle manifests. |
BOOT_FRAME_VERSION |
Yes | — | Semver version (M.m.p) reported in ro.glassworks.frame.version when running boot copies. |
PKG |
Yes | — | The single Android package ID allowed for silent updates and bundle staging. |
ACTIVITY |
Yes (for updates) | — | Launcher activity restarted after a silent app update (<pkg>/<activity>). |
ANIM_DEFAULT |
No | /system/media/bootanimation.zip |
Stock boot animation path bind-mounted at post-fs-data. |
LONG_SLOTS |
No | agent |
Space-separated long-running service slots supervised with crash-loop fallback. |
ONESHOT_SLOTS |
No | firstboot update |
Space-separated one-shot service slots. |
LOADER_ADB_SECURE |
No | 0 |
Set to 1 on boards with stock ro.adb.secure=0 to seed installer keys and enforce ro.adb.secure=1 via resetprop before adbd starts. |
FIRSTBOOT_OLD_MARK |
No | (empty) | Optional legacy first-boot marker path; if present, first-boot provisioning skips cleanly. |
FIRSTBOOT_REAUTH_ADB |
No | 0 |
Set to 1 to re-authorize ADB keys when the boot image carries a new installer key or the Glassworks app is not installed yet. |
FIRSTBOOT_REPLACE_MTP |
No | 0 |
Set to 1 to replace plain mtp in persist.sys.usb.config with adb; when 0, appends ,adb (mtp,adb) to preserve MTP. |
FIRSTBOOT_USB_BOUNCE |
No | 0 |
Set to 1 to bounce sys.usb.config through none when adb is not active after setting adb_enabled=1. |
frame_firstboot_pre_adb() |
No | (unset) | Optional shell function invoked during first-boot provisioning before enabling ADB while the Glassworks app is not yet installed (for example, stopping a vendor launcher that disables USB debugging). |
Adding a new rooted frame
- Read the frame agent contract and declare your frame's capabilities under
agent.capabilitiesinframes/<id>/design/frame.json. - Create
frames/<id>/tools/root/glassworks_frame.shwith the frame'sFRAME_ID,BOOT_FRAME_VERSION,PKG,ACTIVITY, and any optional flags or hooks. - Create
frames/<id>/tools/root/glassworks.rcdefining theinitservice slots (glassworks_agent,glassworks_firstboot,glassworks_update, plusglassworks_bundleif the frame supports signed frame bundles and any board-specific slots) pointing at${MAGISKTMP}/glassworks_loader.sh. - Create
frames/<id>/tools/root/glassworks_agent.sh: setCONTRACT,DIR,APP_DATA, and any capability knobs (OV_*,HN_*,TZ_*), sourceglassworks_agent_lib.sh, start the shared loops you need (tz_start,portal_start,ov_apply,adb_start, etc.), and run your main loop with any board-specific hardware hooks. - Build your Kiln ramdisk overlay with
frameAgentOverlay()from@glassworks/bootpatchinframes/<id>/installer/src/overlay.ts, passing the shared assets fromkiln/scripts/stage-assets.mjsplus your frame'sglassworks.rc,glassworks_frame.sh,glassworks_agent.sh, and any board-specific extras. Frames that support signed frame bundles must also passverify(glassworks_verify, built byframe-agent/verify/build.sh) andbundlePub(glassworks_bundle.pub); frames that only run boot-image services can omit both. - Add off-device tests under
frames/<id>/tools/root/test/and verify every boot and service change on real hardware before merging.
See the two existing rooted frames for complete references:
- Aqara Panel Hub S1 Plus — full radio agent (Zigbee/Thread, firewall, radio firmware flashing, Aqara egress blocking, and
adbdkey check) built onframe-agent/. - Shelly Wall Display XL — minimal non-radio agent with
/productoverlays and stock ADB hardening.
Running the tests
All scripts target Android's /system/bin/sh (mksh with toybox) and avoid bash-only syntax. Run the shared off-device test suite under mksh or dash:
frame-agent/test/run.sh
Run the per-frame root suites as well when changing shared code (the S1 verifier build and radio suite require host docker, OpenSSL 3, and xxd):
frames/shelly-wall-display-xl/tools/root/test/run.sh
frames/aqara-s1-plus/tools/root/build-verify.sh && frames/aqara-s1-plus/tools/radio/test/run.sh
Off-device tests mock Android's init, property service, pm, settings, iptables, and cmd overlay. Any change to frame-agent/ or a frame's tools/root/ still requires verification on real panels before merge.
License
Code in frame-agent/ is licensed under the MIT License.