feat(service): add OpenRC support for Alpine Linux#716
feat(service): add OpenRC support for Alpine Linux#716chumyin merged 12 commits intozeroclaw-labs:mainfrom
Conversation
|
Hi @Baz00k, friendly automation nudge from PR hygiene. This PR has had no new commits for 21h and still needs an update before merge:
Recommended next steps
Maintainers: apply |
- Add InitSystem enum with auto-detection (systemd/OpenRC) - Add --service-init CLI flag to override init system detection - Generate OpenRC init script with security hardening: - Runs as zeroclaw:zeroclaw user - umask 027 for file permissions - Logs to /var/log/zeroclaw/ - Depends on net and firewall - Require root for OpenRC install with clear error message - Warn if binary is in home directory - Add OpenRC auto-restart support in channels module - Document OpenRC setup in README and network-deployment.md Non-goals: - No changes to systemd behavior - No user-level OpenRC services - No other init systems (SysV, runit, s6) Security: OpenRC install requires root, validates user, creates directories with proper permissions
- Add chown_to_zeroclaw() helper to change directory ownership - Log directory /var/log/zeroclaw now owned by zeroclaw:zeroclaw - Fix docs: config file should be owned by zeroclaw:zeroclaw (service runs as zeroclaw user, needs read access) Fixes permission denied error when service tries to write logs.
- Detect Alpine Linux via /etc/alpine-release - Use adduser/deluser on Alpine instead of useradd/userdel - Auto-create zeroclaw system user during install - Provide correct commands in error messages Alpine uses BusyBox which has different user management commands: - adduser -S -s /sbin/nologin -H -D zeroclaw (Alpine) - useradd -r -s /sbin/nologin zeroclaw (Debian/RHEL)
- Alpine adduser -S doesn't create a group automatically - Explicitly create group with addgroup -S zeroclaw first - Then add user with -G zeroclaw to join the group - Update error message commands to include group handling OpenRC service runs as zeroclaw:zeroclaw, so group must exist.
- Move chown_to_zeroclaw outside the if block - Fixes permission denied when directory already exists - Ensures correct ownership even on reinstall
- Add global --config-dir CLI flag that sets ZEROCLAW_CONFIG_DIR env - Add ZEROCLAW_CONFIG_DIR override in config resolution (takes precedence) - Update OpenRC script to use --config-dir and set env vars for config/workspace - Prefer /usr/local/bin/zeroclaw for OpenRC executable - Create /etc/zeroclaw/workspace directory with correct ownership on install - Update docs to reflect --service-init flag order (service-level before subcommand)
Add automatic runtime-state migration to /etc/zeroclaw with secure ownership/permissions. Implement env-based config resolution for service startup, eliminating the need for manual --service-init flags in the happy path.
Switch OpenRC service generation from env exports (ZEROCLAW_CONFIG_DIR/WORKSPACE) to explicit command_args with --config-dir flag. Fixes startup crash with 'Permission denied (os error 13)' under OpenRC init system.
- Linux managed daemon now falls back to systemd when OpenRC restart probe fails, instead of returning early with no action. - OpenRC uninstall no longer fails hard if rc-update del fails; it warns and continues to remove the init script.
|
Thanks @Baz00k for the OpenRC support contribution, and congratulations on getting this over the line.\n\nI performed a deep maintainer pass and applied a focused follow-up commit to keep the scope tight and stable:\n- removed unrelated schema drift ( on )\n- made the root-detection test deterministic on non-Unix targets\n- tightened OpenRC docs wording to avoid over-promising automatic migration behavior\n\nI also rebased the branch on current , resolved conflicts, and re-ran local validation on the service/OpenRC paths with a clean worktree setup.\n\nWe are currently conducting ZeroClaw automated testing. This is an automated comment from ZeroClaw. If you have any questions, please contact @chumyin. |
|
Correction to my previous comment (shell stripped inline code formatting): Thanks @Baz00k for the OpenRC support contribution, and congratulations on getting this over the line. I performed a deep maintainer pass and applied a focused follow-up commit to keep the scope tight and stable:
I also rebased the branch on current We are currently conducting ZeroClaw automated testing. This is an automated comment from ZeroClaw. If you have any questions, please contact @chumyin. |
Summary
Describe this PR in 2-5 bullets:
zeroclaw serviceend-to-end.--service-initflag, OpenRC install/start/stop/status/uninstall flow, and docs updates for Alpine service usage.Label Snapshot (required)
risk: low|medium|high):risk: mediumsize: XS|S|M|L|XL, auto-managed/read-only): auto-managedcore|agent|channel|config|cron|daemon|doctor|gateway|health|heartbeat|integration|memory|observability|onboard|provider|runtime|security|service|skillforge|skills|tool|tunnel|docs|dependencies|ci|tests|scripts|dev, comma-separated):service,docs<module>:<component>, for examplechannel:telegram,provider:kimi,tool:shell):service:openrctrusted contributor|experienced contributor|principal contributor|distinguished contributor, auto-managed/read-only; author merged PRs >=5/10/20/50): auto-managedChange Metadata
bug|feature|refactor|docs|security|chore):featureruntime|provider|channel|memory|security|ci|docs|multi):multiLinked Issue
Supersede Attribution (required when
Supersedes #is used)#<pr> by @<author>, one per line): N/ACo-authored-bytrailers added for materially incorporated contributors? (Yes/No): N/ANo, explain why (for example: inspiration-only, no direct code/design carry-over): N/A\n): (Pass/Fail): N/AValidation Evidence (required)
Commands and result summary:
./scripts/ci/rust_quality_gate.sh-> FAIL (full-repo fmt check currently reports upstream formatting drift outside this PR delta)./scripts/ci/rust_strict_delta_gate.sh-> PASS (no blocking issues on changed Rust lines)./scripts/ci/docs_quality_gate.sh-> PASS (no blocking markdown issues on changed lines)Security Impact (required)
Yes/No): Yes (OpenRC system service management on Alpine)Yes/No): NoYes/No): NoYes/No): Yes (/etc/init.d/zeroclaw,/etc/conf.d/zeroclaw,/etc/zeroclaw,/var/log/zeroclawon OpenRC path)Yes, describe risk and mitigation: Risk is broader service/filesystem scope under root on OpenRC systems. Mitigations include explicit root requirement checks, restrictive ownership/mode setup for runtime dirs, and init-system-specific command paths.Privacy and Data Hygiene (required)
pass|needs-follow-up):passCompatibility / Migration
Yes/No): YesYes/No): No (optional CLI flag)Yes/No): NoHuman Verification (required)
What was personally validated beyond CI:
Side Effects / Blast Radius (required)
src/service/mod.rs,src/main.rs,src/channels/mod.rs,Cargo.toml/Cargo.lock,README.md,docs/network-deployment.mdAgent Collaboration Notes (recommended)
AGENTS.md+CONTRIBUTING.md): YesRollback Plan (required)
git revert <openrc-commit-range>--service-initcan explicitly select init system.Risks and Mitigations
List real risks in this PR (or write
None).