Skip to content

Conversation

@elibosley
Copy link
Member

@elibosley elibosley commented Mar 28, 2025

Summary by CodeRabbit

  • New Features

    • The file synchronization tool now requires an explicitly defined destination and offers a new option to remove remote password files before syncing. Additionally, synchronization now omits ownership, group, and permission metadata for smoother transfers.
    • The activation flow has been refined, with legacy authentication modifications removed to deliver a cleaner welcome modal experience.
    • A new variable has been introduced to enhance server state management.
  • Refactor

    • Internal configuration adjustments have been made to enhance component delivery and streamline system actions.
  • Bug Fixes

    • Updated handling of remote user and host parameters in the synchronization script for improved functionality.
    • Simplified the activation code removal process by focusing solely on the .set-password.php file restoration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

Walkthrough

This pull request makes modifications across several areas. In the Unraid API authentication module, an obsolete import is removed and the directory path is updated. The rsync activation script simplifies remote user handling, removes legacy state file logic, and introduces a new flag to delete remote password files before synchronization. Additionally, legacy code for welcome modal injection in the activation code setup script is eliminated, with a comment noting an upcoming relocation of that functionality.

Changes

File(s) Change Summary
api/.../auth-request.modification.ts
plugin/source/dynamix.unraid.net/.../scripts/activation_code_setup
Removed an unused import and legacy authentication injection code. Updated the webComponentsDirectory property to remove the _nuxt subdirectory. Added a comment indicating that the "Auth Request Modification" will be moved to the Unraid API.
plugin/scripts/rsync-activation-dir.sh Updated usage instructions by removing the --remote-user option and adding the --remove-password flag. Remote user is now hardcoded as "root", and legacy state file logic is removed. Additional rsync flags (--no-owner, --no-group, --no-perms) and remote password removal functionality are now included.
plugin/source/dynamix.unraid.net/.../scripts/activation_code_remove Removed code related to restoring the auth-request.php file during activation code removal, focusing solely on the .set-password.php file restoration.
plugin/source/dynamix.unraid.net/.../data/server-state.php Added initialization of a variable $var by parsing a configuration file state/var.ini into an array.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant S as rsync Script
    participant R as Remote Server

    U->>S: Execute script with --remote-host & --remove-password flag
    S->>R: Connect as root to remove /boot/config/passwd
    R-->>S: Return deletion status (success or error)
    S->>R: Execute rsync with flags --no-owner, --no-group, --no-perms
    R-->>S: Send synchronization result
    S->>U: Output success/error message
Loading

Suggested reviewers

  • pujitm
  • mdatelle

Poem

In the code's gentle sway,
Directories trimmed in a crisp display,
Scripts now sing a simpler song,
Errors handled, and flags turned on,
May our pull request shine bright as day!
🚀✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 63a098e and 4201a9e.

📒 Files selected for processing (5)
  • api/src/unraid-api/unraid-file-modifier/modifications/auth-request.modification.ts (1 hunks)
  • plugin/scripts/rsync-activation-dir.sh (3 hunks)
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/data/server-state.php (1 hunks)
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/scripts/activation_code_remove (1 hunks)
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/scripts/activation_code_setup (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/data/server-state.php
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/scripts/activation_code_remove
  • api/src/unraid-api/unraid-file-modifier/modifications/auth-request.modification.ts
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/scripts/activation_code_setup
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build Web App
  • GitHub Check: Build API
  • GitHub Check: Test API
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (7)
plugin/scripts/rsync-activation-dir.sh (7)

5-9: Usage Instructions Updated
The usage message and example usage now correctly reflect the updated parameters (removing --remote-user and introducing --remove-password). This makes the expected invocation clear.


12-12: Initialize REMOVE_PASSWORD Variable
Setting REMOVE_PASSWORD=false by default is clear and properly ensures that password file removal is opt-in.


29-32: New Parameter Parsing for --remove-password
The addition of the --remove-password flag in the parameter parsing is implemented correctly by setting the appropriate variable and shifting the argument list.


47-50: Validate Required Remote Host Parameter
The error message prompting for the --remote-host parameter is clear and consistent with the updated usage.


61-65: Remote Directory Cleaning Without Confirmation
The script unconditionally removes all files in the remote activation directory ($REMOTE_PATH/*) via SSH without asking for confirmation. This approach is potentially destructive and mirrors a concern raised in previous reviews.

If this behavior is intentional for OEM plugin issues, please ensure it is well documented in the usage instructions or consider adding a safety prompt to prevent accidental data loss.


67-82: Conditional Removal of Unraid Password and License Files
The section that handles the removal of Unraid password files (with an additional prompt for license keys) is clear. The implementation ensures that removal only occurs after user confirmation (for license keys) and provides proper error handling for remote operations.


85-85: Enhanced Rsync Command Flags
Including the flags --no-owner, --no-group, and --no-perms in the rsync command aligns with the objectives to control file permission propagation. This adjustment is implemented cleanly.


🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@elibosley elibosley changed the title fix: path to webcomponents incorrect fix: OEM plugin issues Mar 28, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 8af6b8c and 8cfa3b3.

📒 Files selected for processing (2)
  • plugin/scripts/rsync-activation-dir.sh (3 hunks)
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/data/server-state.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build Web App
  • GitHub Check: Build API
  • GitHub Check: Test API
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (5)
plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/data/server-state.php (1)

5-7: Added required dependencies

The inclusion of Wrappers.php and Helpers.php appears to add necessary functionality. The use of extract() with parse_plugin_cfg() imports configuration variables directly into the symbol table.

plugin/scripts/rsync-activation-dir.sh (4)

5-8: Updated usage documentation

The usage instructions have been updated to remove the --remote-user parameter and add the new --remove-password option. The example usage provides a clear reference for users.


12-12: Added password removal option

The new --remove-password flag is properly implemented with a default value of false and appropriate option handling.

Also applies to: 29-32


67-74: Password removal functionality

The implementation to remove password files when the --remove-password flag is set looks good. It handles errors appropriately and provides feedback to the user.

However, consider adding a warning about the potential security implications of removing these files.


77-77: Modified rsync permissions handling

The rsync command has been updated to include --no-owner --no-group --no-perms flags, which prevents permission and ownership changes on the destination.

This is a good change as it allows the destination system to maintain its own file permissions and ownership, preventing potential access issues.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
plugin/scripts/rsync-activation-dir.sh (1)

61-65: ⚠️ Potential issue

Destructive Remote Directory Cleaning

The script unconditionally removes all files in the specified remote directory using rm -rf $REMOTE_PATH/* without any user confirmation. This operation is potentially destructive and could lead to unexpected data loss if users are not aware of its impact.

Consider adding a confirmation prompt before executing this removal command to safeguard against accidental data loss.

🧹 Nitpick comments (1)
plugin/scripts/rsync-activation-dir.sh (1)

67-82: Conditional Removal of License Keys and Password Files

In this block, the script prompts the user before removing Unraid license keys, which is good. However, the removal of the password file (and related sensitive files) is executed without additional confirmation. If these removals could have a significant impact, it might be worth adding a confirmation prompt for the password file deletion as well.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 8cfa3b3 and 36ba0c6.

📒 Files selected for processing (2)
  • plugin/scripts/rsync-activation-dir.sh (3 hunks)
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/data/server-state.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/data/server-state.php
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Test API
  • GitHub Check: Build Web App
  • GitHub Check: Build API
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (5)
plugin/scripts/rsync-activation-dir.sh (5)

5-9: Usage Instructions Updated

The usage message and example have been updated to drop the obsolete --remote-user option and clearly require the --remote-host parameter. This improves clarity for users. Consider verifying if the script name used in the example matches the actual filename for consistency.


12-12: Explicit Initialization of REMOVE_PASSWORD

The default value for REMOVE_PASSWORD is now clearly initialized to false, ensuring that password removal is only triggered when explicitly requested.


29-32: Parsing the --remove-password Flag

The new command-line flag --remove-password is correctly parsed and sets the REMOVE_PASSWORD variable. This change aligns with the updated functionality.


41-50: Parameter Validation for Required Arguments

The validations for required parameters (--local-directory and --remote-host) are implemented well with clear error messages. This ensures the script fails early when necessary parameters are missing.


85-85: Enhanced Rsync Command Flags

Including the --no-owner, --no-group, and --no-perms flags within the rsync command is a sensible choice for maintaining file permission consistency during synchronization. The command is also wrapped with error handling, which is a solid addition.

@zackspear zackspear force-pushed the fix/gridstack-activation-code-setup branch from 63a098e to 4201a9e Compare March 28, 2025 20:17
@github-actions
Copy link
Contributor

This plugin has been deployed to Cloudflare R2 and is available for testing.
Download it at this URL:

https://preview.dl.unraid.net/unraid-api/tag/PR1288/dynamix.unraid.net.plg

@elibosley elibosley merged commit d5a3d0d into main Mar 28, 2025
8 checks passed
@elibosley elibosley deleted the fix/gridstack-activation-code-setup branch March 28, 2025 20:39
elibosley pushed a commit that referenced this pull request Apr 2, 2025
🤖 I have created a release *beep* *boop*
---


## [4.5.0](v4.4.1...v4.5.0)
(2025-04-02)


### Features

* add webgui theme switcher component
([#1304](#1304))
([e2d00dc](e2d00dc))
* api plugin system & offline versioned dependency vendoring
([#1252](#1252))
([9f492bf](9f492bf))
* **api:** add `unraid-api --delete` command
([#1289](#1289))
([2f09445](2f09445))
* basic array controls
([#1291](#1291))
([61fe696](61fe696))
* basic docker controls
([#1292](#1292))
([12eddf8](12eddf8))
* copy to webgui repo script docs + wc build options
([#1285](#1285))
([e54f189](e54f189))


### Bug Fixes

* additional url fixes
([4b2763c](4b2763c))
* **api:** redirect benign pnpm postinstall warning to log file
([#1290](#1290))
([7fb7849](7fb7849))
* **deps:** update dependency chalk to v5
([#1296](#1296))
([6bed638](6bed638))
* **deps:** update dependency diff to v7
([#1297](#1297))
([3c6683c](3c6683c))
* disable all config watchers
([#1306](#1306))
([5c1b435](5c1b435))
* extract callbacks to library
([#1280](#1280))
([2266139](2266139))
* OEM plugin issues ([#1288](#1288))
([d5a3d0d](d5a3d0d))
* replace files lost during pruning
([d0d2ff6](d0d2ff6))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants