Skip to content

Conversation

@pujitm
Copy link
Member

@pujitm pujitm commented Jun 24, 2025

Detect whether Connect is installed using the $API_UTILS script.

If installed, read pertinent config from the corresponding connect.json file instead of the deprecated myservers.cfg.

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection of remote access status by using the Unraid Connect plugin's configuration for more accurate results.
    • Enhanced handling of network names with special characters or spaces.
  • Chores

    • Updated internal configuration sources for remote access checks to use modern plugin settings.

Detect whether Connect is installed using the `$API_UTILS` script.

If installed, read pertinent config from the corresponding `connect.json` file
instead of the deprecated `myservers.cfg`.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Walkthrough

The script in etc/rc.d/rc.nginx is updated to replace legacy remote access detection with a new function, check_remote_access, which utilizes a JSON configuration and an external utility script. Array key expansions in two loops are quoted for robustness. Related variable declarations are updated to reflect these changes.

Changes

File(s) Change Summary
etc/rc.d/rc.nginx Replaced legacy config parsing with check_remote_access using JSON and utility script; updated variable declarations; quoted array key expansions in two loops.

Poem

A hop and a skip, the configs have changed,
From old files to JSON, the logic’s arranged.
With functions and quotes, the script’s now robust,
Remote access checks we now truly trust.
🥕
The rabbit approves, with a twitch of its nose—
Onward to uptime, as nginx flows!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e2a204 and 770a120.

📒 Files selected for processing (1)
  • etc/rc.d/rc.nginx (4 hunks)
🔇 Additional comments (4)
etc/rc.d/rc.nginx (4)

31-32: LGTM - Clean variable declarations for new configuration paths.

The hardcoded paths are appropriate for system-level configuration and follow the expected plugin directory structure.


79-94: Well-structured function with proper error handling.

The check_remote_access function correctly:

  • Validates dependencies before proceeding (API_UTILS file and jq command)
  • Uses proper JSON parsing with error suppression
  • Implements clear return logic for success/failure cases
  • Handles edge cases like null values and empty strings

The implementation is robust and follows bash best practices.


683-683: Excellent improvement - properly quoted array key expansions.

Quoting the array key expansions ("${!NET_FQDN[@]}" and "${!NET_FQDN6[@]}") is a best practice that ensures robust handling of keys containing special characters or spaces. This prevents potential word splitting issues.

Also applies to: 686-686


589-589: To confirm how API_UTILS is defined and ensure the plugin check is wired correctly, let’s inspect its declaration in etc/rc.d/rc.nginx:

#!/bin/bash
# Show where API_UTILS is set in rc.nginx
rg -n "API_UTILS" -A3 -B3 etc/rc.d/rc.nginx

# Search for any other occurrences of API_UTILS in shell scripts
rg -n "API_UTILS=" -g "*.sh"

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ljm42 ljm42 added the 7.2 label Jun 24, 2025
@pujitm pujitm requested a review from limetech June 24, 2025 19:08
pujitm added a commit to unraid/api that referenced this pull request Jun 24, 2025
## Summary

- **New Features**
- Introduced a comprehensive Nginx control script for Unraid OS,
enabling advanced server management, SSL certificate handling, and
dynamic configuration based on system state.
unraid/webgui#2269
- Added a utility function to safely execute code with error handling
support.

- **Improvements**
- Enhanced logging across remote access, WAN access, and settings
services for improved traceability.
- Added initialization and cleanup hooks to remote access and UPnP
services for better lifecycle management.
- Optimized configuration persistence by batching rapid changes for more
efficient updates.
- Refined URL resolution logic for improved configuration retrieval and
error handling.
  - Broadened pattern matching for domain keys in Nginx state parsing.
- Updated remote access settings to reload the network stack after
changes.
- Simplified remote access and WAN port configuration logic for clarity
and accuracy.
- Improved port mapping logic with explicit error handling in UPnP
service.
- Updated UI and form controls for remote access settings to reflect SSL
requirements and access type restrictions.

- **Configuration**
  - Updated the default path for module configuration files.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
pujitm added a commit to unraid/api that referenced this pull request Jun 25, 2025
pujitm added a commit to unraid/api that referenced this pull request Jun 25, 2025
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced remote access detection for nginx using updated configuration
and plugin integration.
- Introduced a comprehensive Nginx management script tailored for Unraid
OS with SSL handling, server lifecycle controls, and dynamic
configuration.
- **Bug Fixes**
- Improved script robustness by fixing shell loop syntax for proper
handling of array keys.
- **Chores**
  - Added compatibility patches for Unraid versions before 7.2.0.
  - Updated test suites to include new nginx script modifications.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@limetech limetech merged commit 6d5af1b into unraid:master Jun 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants