Skip to content

fix(power): activate power-button files in full releases - #2711

Draft
Eli Bosley (elibosley) wants to merge 1 commit into
masterfrom
fix/os-463-power-options-post-boot
Draft

fix(power): activate power-button files in full releases#2711
Eli Bosley (elibosley) wants to merge 1 commit into
masterfrom
fix/os-463-power-options-post-boot

Conversation

@elibosley

@elibosley Eli Bosley (elibosley) commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

The released OS included PR 2671's power-button files under /usr/local/etc, but boot services consume runtime files under /etc. This PR resolves the release layout before acpid and elogind start, while preserving the existing preview-plugin layout.

Why This Exists

The latest full-release QA on DST-139 / OS-463 failed: Larry tested Unraid 7.4.0-beta.0.2 with PR 2671 included and a clean boot, but Do nothing still shut the server down. The UI passed; the stock ACPI handler remained active.

Resolution

A shared boot helper detects the direct /etc preview-plugin layout and the /usr/local/etc full-release layout. It materializes the handler and elogind drop-in into the runtime /etc paths before the services start.

Reviewer Considerations

  • The direct /etc layout remains authoritative when present, so preview-plugin overlays continue to work.
  • Full releases copy only the packaged files that are missing from runtime /etc; no existing runtime override is overwritten.
  • The fix is limited to boot-time file integration. The dispatcher behavior and UI are unchanged.

Behavior Changes

On a clean full-release boot, the configurable ACPI handler is installed and elogind loads the power-key ignore drop-in. The Power Options setting now controls a physical power-button event without requiring a plugin or manual daemon restarts.

Implementation Summary

  • Added shared rc.powerbutton runtime path configuration.
  • Wired rc.acpid and rc.elogind to configure their runtime files before starting.
  • Added a two-layout regression test for full releases and preview plugins.
  • Runs the regression test in the PR-plugin build workflow.

Verification

  • bash tests/power-button-runtime.sh
  • bash -n on the changed shell scripts and PR-plugin generator
  • shellcheck --severity=warning on the new helper and test
  • git diff --check

Risk

Low. The change only adds a fallback copy from the known release packaging location and leaves existing runtime files untouched. A clean full-release QAVM retest is still required.

Summary by CodeRabbit

  • New Features

    • Improved configurable power-button setup across ACPI and elogind environments.
    • Supports multiple runtime layouts and preserves existing elogind configurations.
  • Bug Fixes

    • Ensures ACPI power-button handlers are installed with the required executable permissions.
  • Tests

    • Added runtime coverage for full-release and preview plugin configurations.

Full Unraid releases extract the webgui etc tree under /usr/local, while PR test plugins overlay etc directly under /. Resolve both layouts into the runtime /etc paths before acpid and elogind start.

Refs: https://linear.app/lime-technology/issue/DST-139/configurable-power-button-behavior-acpi-prevent-accidental-shutdowns
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change centralizes ACPI and elogind power-button runtime setup, updates startup scripts to use it, adds runtime coverage for supported layouts, and runs that coverage in the pull-request workflow.

Changes

Power-button runtime configuration

Layer / File(s) Summary
Shared runtime configuration and startup wiring
etc/rc.d/rc.powerbutton, etc/rc.d/rc.acpid, etc/rc.d/rc.elogind
rc.powerbutton configures ACPI and elogind runtime files. The ACPI and elogind startup scripts invoke the shared functions.
Runtime validation and CI wiring
tests/power-button-runtime.sh, .github/workflows/pr-plugin-build.yml
The runtime test checks both source layouts, copied contents, and permissions. The pull-request workflow runs the test when relevant files change.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • unraid/webgui#2671: Introduced the power-button runtime setup that this change refactors into shared functions.

Suggested labels: 7.4.0

Poem

A rabbit hops through runtime paths,
ACPI handlers gain their flags.
Elogind files settle in place,
Tests check each copied trace.
CI nibbles every change—
Power buttons now arrange!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: activating power-button files in full releases.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/os-463-power-options-post-boot

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2026.08.07.1428
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2711/webgui-pr-2711.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates
  • Post-merge behavior: This preview stays available after merge until preview storage expires or it is manually cleaned up

📝 Modified Files:

Click to expand file list
etc/rc.d/rc.acpid
etc/rc.d/rc.elogind
etc/rc.d/rc.powerbutton

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2711, or run:

plugin remove webgui-pr-2711

🤖 This comment is automatically generated and will be updated with each new push to this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/power-button-runtime.sh (1)

34-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the elogind drop-in mode.

The test verifies only the ACPI handler executable bit. Assert mode 0644 for 20-unraid-powerbutton.conf in both layouts. This detects a regression that can prevent elogind from reading the drop-in.

Proposed test update
   [[ -x "$POWERBUTTON_RUNTIME_ROOT/etc/acpi/acpi_handler.sh" ]] || exit 1
+  [[ "$(stat -c '%a' "$POWERBUTTON_RUNTIME_ROOT/etc/elogind/logind.conf.d/20-unraid-powerbutton.conf")" == 644 ]] || exit 1
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/power-button-runtime.sh` around lines 34 - 36, Extend the power-button
runtime assertions after the existing ACPI executable check to validate that
20-unraid-powerbutton.conf has mode 0644 in both the ACPI and elogind layouts.
Use the existing POWERBUTTON_RUNTIME_ROOT paths and fail the test when either
mode does not match.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@etc/rc.d/rc.acpid`:
- Line 14: Update the source logic in etc/rc.d/rc.acpid at line 14 and
etc/rc.d/rc.elogind at line 29 to resolve /etc/rc.d/rc.powerbutton first, then
fall back to /usr/local/etc/rc.d/rc.powerbutton. Ensure both scripts load the
shared powerbutton_configure_acpid and powerbutton_configure_elogind functions
before starting their daemons.

---

Nitpick comments:
In `@tests/power-button-runtime.sh`:
- Around line 34-36: Extend the power-button runtime assertions after the
existing ACPI executable check to validate that 20-unraid-powerbutton.conf has
mode 0644 in both the ACPI and elogind layouts. Use the existing
POWERBUTTON_RUNTIME_ROOT paths and fail the test when either mode does not
match.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 03137fc1-5674-4b38-9f66-89143e40bd95

📥 Commits

Reviewing files that changed from the base of the PR and between 84c8ea7 and bda350c.

📒 Files selected for processing (5)
  • .github/workflows/pr-plugin-build.yml
  • etc/rc.d/rc.acpid
  • etc/rc.d/rc.elogind
  • etc/rc.d/rc.powerbutton
  • tests/power-button-runtime.sh

Comment thread etc/rc.d/rc.acpid

# run & log functions
. /etc/rc.d/rc.runlog
. /etc/rc.d/rc.powerbutton

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Load rc.powerbutton from the full-release path.

The package mapping installs etc/rc.d/rc.powerbutton under /usr/local/etc/rc.d, but both scripts source only /etc/rc.d/rc.powerbutton. In a full release, powerbutton_configure_acpid and powerbutton_configure_elogind are undefined. The power-button files are not configured before either daemon starts.

  • etc/rc.d/rc.acpid#L14-L14: resolve /etc/rc.d/rc.powerbutton first, then fall back to /usr/local/etc/rc.d/rc.powerbutton.
  • etc/rc.d/rc.elogind#L29-L29: use the same resolver and fallback order.
Proposed update
-. /etc/rc.d/rc.powerbutton
+if [[ -r /etc/rc.d/rc.powerbutton ]]; then
+  . /etc/rc.d/rc.powerbutton
+else
+  . /usr/local/etc/rc.d/rc.powerbutton
+fi
📍 Affects 2 files
  • etc/rc.d/rc.acpid#L14-L14 (this comment)
  • etc/rc.d/rc.elogind#L29-L29
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@etc/rc.d/rc.acpid` at line 14, Update the source logic in etc/rc.d/rc.acpid
at line 14 and etc/rc.d/rc.elogind at line 29 to resolve
/etc/rc.d/rc.powerbutton first, then fall back to
/usr/local/etc/rc.d/rc.powerbutton. Ensure both scripts load the shared
powerbutton_configure_acpid and powerbutton_configure_elogind functions before
starting their daemons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant