Controller: add help.sh to the Maintenance Scripts.

A new wrolpi-help-script.service oneshot runs /opt/wrolpi/help.sh so the
Controller UI can run system diagnostics and show the output from the
journal.  The confirmation modal hides the warnings block for scripts
with no warnings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-07-09 15:29:01 -06:00 • committed by lrnselfreliance
parent d6b019c24e
commit e42e4ed06e
4 changed files with 29 additions and 1 deletions

View file

@ -21,6 +21,14 @@ logger = logging.getLogger(__name__)
# - type: "branch" (auto-populates with current git branch) or "text"
# - required: Whether the parameter must have a value
AVAILABLE_SCRIPTS = {
"help": {
"name": "help",
"display_name": "System Diagnostics",
"description": "Runs help.sh which checks WROLPi services, certificates, database, and dependencies."
" Read-only; changes nothing.",
"service_name": "wrolpi-help-script.service",
"warnings": [],
},
"repair": {
"name": "repair",
"display_name": "Repair WROLPi",

View file

@ -2070,6 +2070,7 @@
const warningsList = document.getElementById('script-warnings-list');
warningsList.innerHTML = script.warnings.map(w => `<li>${w}</li>`).join('');
document.getElementById('script-confirm-warnings').style.display = script.warnings.length ? '' : 'none';
// Generate parameter inputs dynamically
const paramsContainer = document.getElementById('script-params-container');

View file

@ -35,6 +35,14 @@ class TestAvailableScripts:
repair = AVAILABLE_SCRIPTS["repair"]
assert len(repair["warnings"]) > 0
def test_help_script_exists(self):
"""Should have a help (diagnostics) script defined."""
assert "help" in AVAILABLE_SCRIPTS
help_script = AVAILABLE_SCRIPTS["help"]
assert help_script["service_name"] == "wrolpi-help-script.service"
# help.sh is read-only, so it needs no warnings.
assert help_script["warnings"] == []
class TestListAvailableScripts:
"""Tests for list_available_scripts function."""
@ -112,7 +120,8 @@ class TestGetScriptStatus:
with mock.patch("controller.lib.scripts._get_service_timing", return_value=(None, None)):
result = get_script_status()
assert result["running"] is True
assert result["script_name"] == "repair"
# The first script checked reports as running because every systemctl call is mocked.
assert result["script_name"] == next(iter(AVAILABLE_SCRIPTS))
def test_returns_not_running_when_service_inactive(self):
"""Should return not running when service is inactive."""

View file

@ -0,0 +1,10 @@
[Unit]
Description=WROLPi Help Script (system diagnostics)
After=network.target
[Service]
Type=oneshot
ExecStart=/opt/wrolpi/help.sh
User=root
StandardOutput=journal
StandardError=journal