-
Notifications
You must be signed in to change notification settings - Fork 16
feat: native slackware package #1381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis update overhauls the Unraid plugin build and installation system, introducing versioned packaging, robust Node.js dependency management, and modularized shell scripts for setup, cleanup, and verification. It refactors the build process to use explicit API versions, simplifies plugin manifest logic, adds new system scripts for service control and shutdown, and removes legacy and redundant files. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Installer
participant SetupScript
participant DependencyScript
participant ServiceScript
User->>Installer: Run plugin install
Installer->>SetupScript: Execute setup_api.sh
SetupScript->>DependencyScript: Ensure Node.js dependencies (ensure)
DependencyScript->>DependencyScript: Restore or download vendor archive
SetupScript->>ServiceScript: Start unraid-api service
ServiceScript->>ServiceScript: Ensure dependencies
ServiceScript->>ServiceScript: Start API binary
Possibly related PRs
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Nitpick comments (15)
plugin/source/dynamix.unraid.net/install/scripts/verify_install.sh (2)
5-6: Consider addingset -ufor better error handlingThe script currently uses
set -eto exit on errors, but addingset -uwould help catch unbound variables as well.# Exit on errors set -e +set -u
96-108: Quote variables in the if conditionVariables in the if condition should be quoted to handle empty values correctly.
-if [ $EXEC_ERRORS -eq 0 ] && [ $DIR_ERRORS -eq 0 ]; then +if [ "$EXEC_ERRORS" -eq 0 ] && [ "$DIR_ERRORS" -eq 0 ]; thenplugin/builder/utils/nodejs-helper.ts (2)
39-41: Use absolute path for NODE_FILENAMEThe code checks if
NODE_FILENAMEexists, but doesn't specify a full path, which might lead to checking in the wrong directory.- if (!existsSync(NODE_FILENAME)) { - await fetchFile(NODE_URL, NODE_FILENAME); + const nodeFilePath = join(startingDir, NODE_FILENAME); + if (!existsSync(nodeFilePath)) { + await fetchFile(NODE_URL, nodeFilePath);
42-43: Add error handling for the tar extractionThe tar command execution should include error handling to manage potential extraction failures.
- await $`tar --strip-components=1 -xf ${NODE_FILENAME} -C ${NODE_DEST}`; + try { + await $`tar --strip-components=1 -xf ${NODE_FILENAME} -C ${NODE_DEST}`; + } catch (error) { + console.error(`Failed to extract Node.js: ${error.message}`); + throw error; + }.cursor/rules/plugin-migration-to-slackware-package.mdc (1)
6-11: Consider expanding migration guidelinesWhile the file establishes the migration goal, it would benefit from more detailed migration steps or resources.
Consider expanding this section with:
- Links to Slackware package documentation
- Specific migration steps or a checklist
- Examples of correctly migrated components
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh (3)
7-7: Remove or use the UNRAID_BINARY_PATH variableThe UNRAID_BINARY_PATH variable is defined but never used in the script.
Either remove this unused variable or utilize it in the script where appropriate.
🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 7-7: UNRAID_BINARY_PATH appears unused. Verify use (or export if used externally).
(SC2034)
18-23: Add error handling for symlink creationThe symlink creation process lacks error handling and doesn't verify successful operations.
Consider adding error checking for the symlink creation:
if [ -f usr/local/unraid-api/dist/cli.js ]; then - ln -sf usr/local/unraid-api/dist/cli.js usr/local/bin/unraid-api - ln -sf usr/local/bin/unraid-api usr/local/sbin/unraid-api - ln -sf usr/local/bin/unraid-api usr/bin/unraid-api + if ! ln -sf usr/local/unraid-api/dist/cli.js usr/local/bin/unraid-api; then + echo "Warning: Failed to create symlink in usr/local/bin" >&2 + fi + if ! ln -sf usr/local/bin/unraid-api usr/local/sbin/unraid-api; then + echo "Warning: Failed to create symlink in usr/local/sbin" >&2 + fi + if ! ln -sf usr/local/bin/unraid-api usr/bin/unraid-api; then + echo "Warning: Failed to create symlink in usr/bin" >&2 + fi fi
35-46: Simplify flash backup configuration logicThe flash backup configuration has multiple nested if statements and could be simplified for better readability.
Consider consolidating the directory creation and symlink creation:
# Configure flash backup to stop when the system starts shutting down -if [ ! -d etc/rc.d/rc6.d ]; then - mkdir -p etc/rc.d/rc6.d -fi - -if [ ! -h etc/rc.d/rc0.d ]; then - ln -sf etc/rc.d/rc6.d etc/rc.d/rc0.d -fi - -if [ ! -h etc/rc.d/rc6.d/K10_flash_backup ] && [ -f etc/rc.d/rc.flash_backup ]; then - ln -sf etc/rc.d/rc.flash_backup etc/rc.d/rc6.d/K10_flash_backup -fi +# Ensure rc6.d directory exists +mkdir -p etc/rc.d/rc6.d + +# Link rc0.d to rc6.d if needed +[ ! -h etc/rc.d/rc0.d ] && ln -sf etc/rc.d/rc6.d etc/rc.d/rc0.d + +# Create flash backup shutdown script link if needed +if [ ! -h etc/rc.d/rc6.d/K10_flash_backup ] && [ -f etc/rc.d/rc.flash_backup ]; then + ln -sf etc/rc.d/rc.flash_backup etc/rc.d/rc6.d/K10_flash_backup +fiplugin/source/dynamix.unraid.net/install/scripts/file_patches.sh (1)
4-13: Add error handling for nginx configuration patchingThe nginx configuration patching lacks error handling and doesn't verify the success of the sed operation.
Add error handling to verify the sed command execution:
# Patch nginx config if needed NGINX_CHANGED=0 FILE=/etc/nginx/nginx.conf if grep -q "SAMEORIGIN" "${FILE}" >/dev/null 2>&1; then cp "$FILE" "$FILE-" OLD="add_header X-Frame-Options 'SAMEORIGIN';" NEW="add_header Content-Security-Policy \"frame-ancestors 'self' https://connect.myunraid.net/\";" - sed -i "s#${OLD}#${NEW}#" "${FILE}" + if sed -i "s#${OLD}#${NEW}#" "${FILE}"; then + NGINX_CHANGED=1 + echo "Updated nginx config: replaced X-Frame-Options with Content-Security-Policy" + else + echo "Failed to update nginx config" >&2 + cp "$FILE-" "$FILE" # Restore from backup + fi - NGINX_CHANGED=1 fiplugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api (2)
61-66: Improve restart function to ensure service is fully stoppedThe restart function uses a fixed sleep duration which might not be sufficient for all scenarios.
Implement a more robust restart mechanism:
restart() { stop - sleep 2 + # Wait for service to fully stop (up to 10 seconds) + local max_wait=10 + local count=0 + while [ $count -lt $max_wait ]; do + if ! "$unraid_binary_path" service status &>/dev/null; then + # Service is stopped + break + fi + sleep 1 + count=$((count + 1)) + done + + # If service is still running after max wait, force stop + if [ $count -eq $max_wait ] && "$unraid_binary_path" service status &>/dev/null; then + echo "Warning: Service did not stop gracefully, forcing stop..." + killall -9 node 2>/dev/null || true + sleep 1 + fi + start }
27-31: Add optimization for dependency restorationThe dependency restoration check could be optimized to avoid unnecessary file operations.
Add a check for an empty node_modules directory:
# Check if node modules need restoration -if [ ! -d "${dependencies_dir}" ] && [ -f "${vendor_archive}" ]; then +if { [ ! -d "${dependencies_dir}" ] || [ -z "$(ls -A "${dependencies_dir}" 2>/dev/null)" ]; } && [ -f "${vendor_archive}" ]; then echo "Restoring node modules from vendor archive..." restore_dependencies "${vendor_archive}" fiplugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/file_patches.sh (1)
1-3: Add defensive shell options for safer executionConsider enabling
set -euo pipefail(or at leastset -e) right after the she-bang.
This makes the script abort on the first failing command or on an undefined variable, preventing half-applied patches that can leave the system in an inconsistent state.#!/bin/sh +# Abort on error/unset vars, fail on pipe errors +set -euo pipefail # Script to handle file patchesplugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh (1)
66-70:echo "\n…": ANSI escape not interpreted
echo(BusyBox/GNU) will print the literal “\n”. Useprintf '\n…'orechowith-e(GNU-only) for portable newlines.-echo "\n**********************************" +printf '\n**********************************\n'plugin/plugins/dynamix.unraid.net.plg (2)
33-55: Disk-space check: make failure explicit & POSIX-portable
df -mfails on systems where-mis unsupported (BusyBox). Usedf -Pand convert.exit 0on success is redundant (the script already exits 0).- Surplus blank lines can be trimmed.
115-120: Service start should tolerate missing rc functionalitySome users disable init scripts. Consider testing
/etc/rc.d/rc.unraid-api status || truebefore starting, or at least capturing failure to aid debugging.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (14)
.cursor/rules/plugin-migration-to-slackware-package.mdc(1 hunks)plugin/builder/build-txz.ts(2 hunks)plugin/builder/utils/nodejs-helper.ts(1 hunks)plugin/docs/README.md(0 hunks)plugin/docs/migration/progress.md(1 hunks)plugin/plugins/dynamix.unraid.net.plg(4 hunks)plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api(3 hunks)plugin/source/dynamix.unraid.net/install/scripts/file_patches.sh(1 hunks)plugin/source/dynamix.unraid.net/install/scripts/verify_install.sh(1 hunks)plugin/source/dynamix.unraid.net/install/slack-desc(1 hunks)plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/scripts/cleanup_operations.php(0 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/file_patches.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh(1 hunks)
💤 Files with no reviewable changes (2)
- plugin/docs/README.md
- plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/scripts/cleanup_operations.php
🧰 Additional context used
🧬 Code Graph Analysis (2)
plugin/builder/build-txz.ts (1)
plugin/builder/utils/nodejs-helper.ts (1)
ensureNodeJs(32-45)
plugin/builder/utils/nodejs-helper.ts (1)
plugin/builder/utils/consts.ts (1)
startingDir(6-6)
🪛 Shellcheck (0.10.0)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
[warning] 7-7: UNRAID_BINARY_PATH appears unused. Verify use (or export if used externally).
(SC2034)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh
[warning] 135-135: Quote this to prevent word splitting.
(SC2046)
⏰ 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 (12)
plugin/source/dynamix.unraid.net/install/scripts/verify_install.sh (4)
16-23: Good use of POSIX-compliant approachThe use of multi-line strings rather than arrays for the critical files list ensures better compatibility across shell environments.
31-42: Well-structured executable check functionThe function provides clear status codes and colored output for different states (executable, exists but not executable, missing).
73-87: Good verification of init script symlinksThe script properly checks for the presence of startup (S99) and shutdown (K01) symlinks, which are essential for proper service management in Slackware.
106-107: Good approach for verification script exit codeExiting with success (0) is appropriate since this is a verification tool, not an enforcement mechanism.
plugin/builder/utils/nodejs-helper.ts (2)
1-11: Good approach to reading Node.js version from .nvmrcThe code properly reads the Node.js version from a standard
.nvmrcfile and constructs the download URL dynamically.
17-30: Well-implemented file download with proper error handlingThe
fetchFilefunction handles both HTTP status errors and stream errors appropriately.plugin/builder/build-txz.ts (2)
6-6: Good integration of Node.js dependency handlingThe import of the
ensureNodeJsfunction follows good modular design principles.
95-95: Good placement of Node.js verificationThe
ensureNodeJs()call is strategically placed after source directory validation and before packaging begins..cursor/rules/plugin-migration-to-slackware-package.mdc (1)
1-5: Good metadata structureThe metadata header correctly defines the file glob pattern and application settings.
plugin/source/dynamix.unraid.net/install/slack-desc (1)
1-18: Package description follows Slackware standardsThe slack-desc file properly follows Slackware package formatting requirements with exactly 11 lines and appropriate spacing after colons. The description clearly explains the package's purpose and features.
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/file_patches.sh (1)
60-64: Reload might fail silently
/etc/rc.d/rc.nginx statusreturns non-zero on “running but pidfile missing”; in that case the subsequent reload is skipped although nginx is alive.
Suggest falling back topgrep -f nginxor always attemptreloadand ignore the exit code.plugin/docs/migration/progress.md (1)
52-58: Minor spelling: “identical functionality while ensuring /bin/sh compatibility”No change needed, just 👍 for the thorough notes.
plugin/source/dynamix.unraid.net/install/scripts/file_patches.sh
Outdated
Show resolved
Hide resolved
...source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/file_patches.sh
Show resolved
Hide resolved
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh
Outdated
Show resolved
Hide resolved
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh
Outdated
Show resolved
Hide resolved
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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 (3)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh (2)
8-62: Consider refactoring the long file-list for maintainability
The inlinefor FILE in \ …block works, but as the list grows it will be harder to update and review. You could extract the paths into a here-document or an external variable/file, for example:perform_file_restoration() { - for FILE in \ - "/usr/local/emhttp/plugins/…/DisplaySettings.page" \ - … - do + # List of files to restore + set -- \ + "/usr/local/emhttp/plugins/…/DisplaySettings.page" \ + … + # Iterate over backups + for FILE; do [ -f "$FILE-" ] && mv -f "$FILE-" "$FILE" doneThis keeps the function body lean and the file list easy to manage.
176-178: Combinesedinvocations for conciseness
You’re already removing two patterns fromrc.nginx. You can merge them:-sed -i '/scripts\/makestate/d' /etc/rc.d/rc.nginx -sed -i '/#robots.txt any origin/d' /etc/rc.d/rc.nginx +sed -i -e '/scripts\/makestate/d' \ + -e '/#robots.txt any origin/d' /etc/rc.d/rc.nginxThis reduces disk writes and keeps the intent clear.
plugin/docs/migration/progress.md (1)
19-27: Fix nested list indentation under “Installation Scripts”
The sub-items for modularized scripts should be indented further to clearly denote hierarchy. For example:- - Modularized the installation logic into separate scripts for better maintainability: - - `setup_api.sh`: Handles API setup, symlinks, and service startup - - `file_patches.sh`: Manages file patches and system configurations - - `cleanup.sh`: Performs uninstallation and cleanup operations + - Modularized the installation logic into separate scripts for better maintainability: + - `setup_api.sh`: Handles API setup, symlinks, and service startup + - `file_patches.sh`: Manages file patches and system configurations + - `cleanup.sh`: Performs uninstallation and cleanup operationsThis makes the nesting level unambiguous in Markdown renderers.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (3)
plugin/docs/migration/progress.md(1 hunks)plugin/source/dynamix.unraid.net/install/scripts/file_patches.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- plugin/source/dynamix.unraid.net/install/scripts/file_patches.sh
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build API
- GitHub Check: Test API
- GitHub Check: Build Web App
- GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh (2)
1-6: Shebang and mode parsing look solid
The use of#!/bin/shand the defaultMODE="${1:-cleanup}"is POSIX-compliant and clear.
185-200: Main execution flow is clear and robust
Thecasestatement correctly handlesrestorevscleanupmodes and falls back to a usage message. Nicely done.plugin/docs/migration/progress.md (1)
1-5: Overview section is concise and clear
The title and summary lines set the stage nicely for readers. No changes needed here.
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh
Show resolved
Hide resolved
There was a problem hiding this 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
🧹 Nitpick comments (4)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh (2)
5-8: Remove or use the unusedUNRAID_BINARY_PATHvariableThe
UNRAID_BINARY_PATHconstant is defined but never referenced. To reduce confusion and maintainability overhead, either remove this variable or leverage it in your symlink creation instead of hard-coding paths.🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 7-7: UNRAID_BINARY_PATH appears unused. Verify use (or export if used externally).
(SC2034)
36-62: Hardenconfigure_scriptagainst unquoted expansions and improve insertion logic
- The
grep -q "$2 $4" "$1"check may misfire if$2or$4contain spaces or regex metacharacters; consider quoting or escaping these arguments.- The
sed -i "10i…"insertion always targets line 10, which could be out of bounds for short files; you may want to insert immediately after the shebang (line 1) or detect the first executable section.plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh (2)
13-45: Make Firefox profile restoration dynamicThe hard-coded path
"/usr/share/mozilla/firefox/9n35r0i1.default/user.js"may not exist on all systems. Consider detecting the active profile directory under
~/.mozilla/firefox/*.default*at runtime or parameterizing this path to ensure restoration works across Unraid versions.
1-4: Consider enabling strict error handlingAdding at the top:
set -euwould catch typos and unset variables early. If you prefer to continue on individual command failures, selectively trap errors instead.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (5)
plugin/docs/migration/progress.md(1 hunks)plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api(3 hunks)plugin/source/dynamix.unraid.net/install/scripts/verify_install.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/cleanup.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- plugin/source/dynamix.unraid.net/install/scripts/verify_install.sh
- plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api
🧰 Additional context used
🪛 Shellcheck (0.10.0)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
[warning] 7-7: UNRAID_BINARY_PATH appears unused. Verify use (or export if used externally).
(SC2034)
⏰ 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 (1)
plugin/docs/migration/progress.md (1)
78-81: Update progress note about runlevel handling—scripts already use file-based initThe note claims we still need to update scripts because “rc.0 and rc.6 are files, not directories.” However,
setup_api.sh’sconfigure_scriptalready treats/etc/rc.d/rc.0and/etc/rc.d/rc.6as files. Please revise or remove this pending-task entry for accuracy.Likely an incorrect or invalid review comment.
There was a problem hiding this 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
🧹 Nitpick comments (18)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.sh (6)
1-3: Enable strict error handling
To catch unexpected failures and undefined variables, add strict mode after the shebang:#!/bin/sh +set -euo pipefail # Test script to validate setup_api.sh functionality
7-11: Consolidate and quote path variables
You declareRC_SCRIPTon line 9 but never use it. Either remove it or reference it in your RC checks. Also, consistently quote all path variables to avoid word-splitting issues:-SETUP_SCRIPT="/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh" -BINARY_PATH="/usr/local/bin/unraid-api" -RC_SCRIPT="/etc/rc.d/rc.unraid-api" -ENV_FILE="/boot/config/plugins/dynamix.my.servers/env" +SETUP_SCRIPT="/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh" +BINARY_PATH="/usr/local/bin/unraid-api" -# RC_SCRIPT is unused – consider removing +ENV_FILE="/boot/config/plugins/dynamix.my.servers/env"🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 9-9: RC_SCRIPT appears unused. Verify use (or export if used externally).
(SC2034)
21-27: Handle non-executable script more robustly
You auto-chmod the setup script if it’s not executable. It may be better to fail the test rather than modify system state in a validation tool. Alternatively, log to a separate file instead of printing to stdout.
30-32: Quote and log the setup script invocation
Wrap the variable in quotes and redirect output to a log for post-mortem analysis:-echo "Running setup_api.sh..." -"$SETUP_SCRIPT" +echo "Running setup_api.sh..." | tee -a /tmp/test-setup-api.log +"$SETUP_SCRIPT" 2>&1 | tee -a /tmp/test-setup-api.log
37-53: DRY up symlink checks
You repeat the same block three times. Consider looping over an array of target paths to reduce duplication:-# Check symlinks -if [ -L "$BINARY_PATH" ]; then - echo "✓ Symlink created: $BINARY_PATH -> $(readlink $BINARY_PATH)" -else - echo "✗ Symlink not created: $BINARY_PATH" -fi - -if [ -L "/usr/local/sbin/unraid-api" ]; then - echo "✓ Symlink created: /usr/local/sbin/unraid-api -> $(readlink /usr/local/sbin/unraid-api)" -else - echo "✗ Symlink not created: /usr/local/sbin/unraid-api" -fi - -if [ -L "/usr/bin/unraid-api" ]; then - echo "✓ Symlink created: /usr/bin/unraid-api -> $(readlink /usr/bin/unraid-api)" -else - echo "✗ Symlink not created: /usr/bin/unraid-api" -fi +for link in "$BINARY_PATH" "/usr/local/sbin/unraid-api" "/usr/bin/unraid-api"; do + if [ -L "$link" ]; then + echo "✓ Symlink created: $link -> $(readlink "$link")" + else + echo "✗ Symlink not created: $link" + fi +done
70-76: Use RC_SCRIPT variable in runlevel checks
You declaredRC_SCRIPTbut used a hardcoded list. Replace the list with a reference to$RC_SCRIPTor remove the unused variable.plugin/source/dynamix.unraid.net/install/doinst.sh (11)
1-4: Add strict mode for robust failure detection
Enabling strict shell options helps catch errors early:#!/bin/sh +set -euo pipefail # Main installation script for dynamix.unraid.net package # This script calls specialized external scripts to handle different aspects of installation
6-9: Quote variable expansions
Wrap$1and$SCRIPTS_DIRin quotes when referenced to prevent word splitting:-INSTALL_MODE="${1:-install}" +INSTALL_MODE="${1:-install}" SCRIPTS_DIR="/usr/local/share/dynamix.unraid.net/install/scripts"Also, use
"$SCRIPTS_DIR"in downstream tests.
10-15: Redirect all output to log file
Instead of manually echoing to$LOGFILE, consider redirecting stdout and stderr at the top:-date > "$LOGFILE" -echo "Starting installation with mode: $INSTALL_MODE" >> "$LOGFILE" -echo "Script directory: $SCRIPTS_DIR" >> "$LOGFILE" +exec > >(tee "$LOGFILE") 2>&1 +echo "Starting installation with mode: $INSTALL_MODE" +echo "Script directory: $SCRIPTS_DIR"This captures every command’s output automatically.
17-24: Quote paths and check after chmod
Always quote variables in tests and commands:-if [ -d $SCRIPTS_DIR ]; then - chmod +x $SCRIPTS_DIR/*.sh +if [ -d "$SCRIPTS_DIR" ]; then + chmod +x "$SCRIPTS_DIR"/*.shOptionally verify that
chmodsucceeded.
27-35: Fail fast when cleanup.sh is missing
Currently you log an error but continue. Ifcleanup.shis required, exit with non-zero:-else - echo "ERROR: cleanup.sh not found or not executable" >> "$LOGFILE" +else + echo "ERROR: cleanup.sh not found or not executable" >> "$LOGFILE" + exit 1
38-44: Validate installation mode
Handle unexpected modes explicitly to avoid silent no-ops:-elif [ "$INSTALL_MODE" = "remove" ]; then +else + echo "ERROR: Unknown mode '$INSTALL_MODE'. Supported: install, upgrade, remove." >> "$LOGFILE" + exit 1 +fi +elif [ "$INSTALL_MODE" = "remove" ]; then
42-49: Quote and error-check file_patches.sh
Wrap the path in quotes and bail on failure if it’s critical:-if [ -x $SCRIPTS_DIR/file_patches.sh ]; then +if [ -x "$SCRIPTS_DIR/file_patches.sh" ]; then echo "Applying system patches and configurations..." echo "Running file_patches.sh" >> "$LOGFILE" - $SCRIPTS_DIR/file_patches.sh + "$SCRIPTS_DIR/file_patches.sh" || { echo "file_patches.sh failed" >> "$LOGFILE"; exit 1; }
51-73: DRY and harden setup_api.sh invocation
You repeat manual symlink fallback logic. Extract it into a function and reuse. Also quote all paths:- if [ -L "/usr/local/bin/unraid-api" ]; then - echo "Symlink created successfully" >> "$LOGFILE" - else - echo "ERROR: Symlink not created, attempting to create manually" >> "$LOGFILE" - # Create the symlink manually as fallback - if [ -f "/usr/local/unraid-api/dist/cli.js" ]; then - ln -sf "/usr/local/unraid-api/dist/cli.js" "/usr/local/bin/unraid-api" - …Refactor into:
create_symlinks() { local src="/usr/local/unraid-api/dist/cli.js" for dst in "/usr/local/bin/unraid-api" "/usr/local/sbin/unraid-api" "/usr/bin/unraid-api"; do ln -sf "$src" "$dst" done } … if [ -x "$SCRIPTS_DIR/setup_api.sh" ]; then "$SCRIPTS_DIR/setup_api.sh" if [ ! -L "$BINARY_PATH" ]; then echo "ERROR: Symlink missing, running fallback" >> "$LOGFILE" create_symlinks fi
92-98: Quote and bail on verify_install.sh failure
For consistent error handling:-if [ -x $SCRIPTS_DIR/verify_install.sh ]; then - echo "Running verify_install.sh" >> "$LOGFILE" - $SCRIPTS_DIR/verify_install.sh +if [ -x "$SCRIPTS_DIR/verify_install.sh" ]; then + echo "Running verify_install.sh" >> "$LOGFILE" + "$SCRIPTS_DIR/verify_install.sh" || { echo "verify_install.sh failed" >> "$LOGFILE"; exit 1; }
103-133: Capture and propagate test script exit status
Instead of parsing output for failures only, check the actual exit code oftest-setup-api.shand fail the installation if critical tests fail:- test_output=$($SCRIPTS_DIR/test-setup-api.sh) + if ! test_output=$("$SCRIPTS_DIR/test-setup-api.sh"); then + echo "ERROR: test-setup-api.sh returned non-zero status" >> "$LOGFILE" + echo "$test_output" >> "$LOGFILE" + exit 1 + fiThis gives you a deterministic way to detect test failures.
139-145: Quote cleanup.sh in removal branch
Ensure paths are quoted and handle cleanup errors:-if [ -x $SCRIPTS_DIR/cleanup.sh ]; then +if [ -x "$SCRIPTS_DIR/cleanup.sh" ]; then "$SCRIPTS_DIR/cleanup.sh" cleanup + || { echo "cleanup.sh cleanup failed" >> "$LOGFILE"; exit 1; }plugin/docs/migration/progress.md (1)
61-67: Mentiontest-setup-api.shin verification section
The docs describeverify_install.shunder “Verification and TAG Handling” but omit the newtest-setup-api.shtest script. For completeness, add a bullet:- `test-setup-api.sh`: Validates setup_api.sh by checking symlinks, environment files, and init script entries.This ensures readers know about both verification tools.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (5)
plugin/.gitignore(0 hunks)plugin/docs/migration/progress.md(1 hunks)plugin/source/dynamix.unraid.net/install/doinst.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.sh(1 hunks)
💤 Files with no reviewable changes (1)
- plugin/.gitignore
🚧 Files skipped from review as they are similar to previous changes (1)
- plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
🧰 Additional context used
🪛 Shellcheck (0.10.0)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.sh
[warning] 9-9: RC_SCRIPT appears unused. Verify use (or export if used externally).
(SC2034)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build API
- GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.sh (5)
4-5: The introductory echo is straightforward and requires no changes.
56-60: Quote environment file check
Ensure consistent quoting and consider treating missing env file as a failure:-if [ -f "$ENV_FILE" ]; then +if [ -f "$ENV_FILE" ]; then
63-67: Quote log directory check
Similarly, quote the path in the directory test to avoid issues if the path ever contains spaces:-if [ -d "/var/log/unraid-api" ]; then +if [ -d "/var/log/unraid-api" ]; then
78-81: Final summary prints are clear and need no adjustments.
13-18:Details
✅ Verification successful
Fail fast if setup script is missing
Currently youexit 1only when the script is missing, which is good. Consider capturing the failure in a flag so the script can still report other missing items in one run, or deliberately bail out early if this is a blocker.Run this after cloning to confirm there are no other early exits:
🏁 Script executed:
rg -n "exit 1" plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.shLength of output: 130
Only one early exit confirmed
I ranrg -n 'exit 1' plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.shand found a singleexit 1at line 17. The script currently fails fast only when the setup script is missing.• If you plan to add further checks later, you might accumulate failures in a flag and report them all at once.
• Otherwise, this early-exit on a missing setup script is appropriate.plugin/source/dynamix.unraid.net/install/doinst.sh (1)
75-83:⚠️ Potential issueFix missing slash in rc script path
You testetc/rc.d/rc.unraid-apiwithout a leading/, causing a false negative. Apply:-if [ -f etc/rc.d/rc.unraid-api ]; then +if [ -f "/etc/rc.d/rc.unraid-api" ]; then chmod 755 etc/rc.d/rc.unraid-api + chmod 755 "/etc/rc.d/rc.unraid-api"This correction ensures you reference the absolute path.
Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (2)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh (1)
159-173: Consider adding execution permissions check for rc.unraid-apiThe script checks if the file exists but should also verify it has execution permissions before attempting to add it to the startup scripts.
-if [ -f "/etc/rc.d/rc.unraid-api" ]; then +if [ -x "/etc/rc.d/rc.unraid-api" ]; then echo "Configuring startup for unraid-api" >> "$LOGFILE" # Configure for runlevel 3 (multi-user mode, standard Slackware default) # Slackware uses rc.M for runlevel 3 (multi-user mode) configure_script "/etc/rc.d/rc.M" "/etc/rc.d/rc.unraid-api" "Start Unraid API service" "start" "multi-user startup" # Also add to rc.local as a fallback configure_script "/etc/rc.d/rc.local" "/etc/rc.d/rc.unraid-api" "Start Unraid API service" "start" "local startup" # Configure unraid-api shutdown in rc.0 and rc.6 configure_script "/etc/rc.d/rc.0" "/etc/rc.d/rc.unraid-api" "Stop Unraid API service" "stop" "shutdown" configure_script "/etc/rc.d/rc.6" "/etc/rc.d/rc.unraid-api" "Stop Unraid API service" "stop" "reboot" else - echo "ERROR: rc.unraid-api not found" >> "$LOGFILE" + echo "ERROR: rc.unraid-api not found or not executable" >> "$LOGFILE" fiplugin/docker-compose.yml (1)
23-23: Add newline at end of fileThe file is missing a newline character at the end, which is a common convention for text files in Unix-based systems.
- CI=${CI:-false} - TAG=${TAG} - API_VERSION=${API_VERSION} +🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 23-23: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (14)
.github/workflows/build-plugin.yml(1 hunks)plugin/builder/build-plugin.ts(4 hunks)plugin/builder/build-txz.ts(2 hunks)plugin/builder/cli/setup-plugin-environment.ts(3 hunks)plugin/builder/utils/bucket-urls.ts(2 hunks)plugin/builder/utils/consts.ts(1 hunks)plugin/builder/utils/nodejs-helper.ts(1 hunks)plugin/docker-compose.yml(2 hunks)plugin/docs/migration/progress.md(1 hunks)plugin/package.json(1 hunks)plugin/plugins/dynamix.unraid.net.plg(3 hunks)plugin/scripts/dc.sh(2 hunks)plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api(3 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- plugin/package.json
🚧 Files skipped from review as they are similar to previous changes (4)
- plugin/builder/build-txz.ts
- plugin/builder/utils/nodejs-helper.ts
- plugin/docs/migration/progress.md
- plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api
🧰 Additional context used
🧬 Code Graph Analysis (2)
plugin/builder/utils/bucket-urls.ts (1)
plugin/builder/utils/consts.ts (3)
getTxzName(9-10)defaultArch(5-5)defaultBuild(6-6)
plugin/builder/build-plugin.ts (3)
plugin/builder/cli/setup-plugin-environment.ts (1)
PluginEnv(31-31)plugin/builder/utils/paths.ts (1)
getRootPluginPath(33-35)plugin/builder/utils/consts.ts (3)
pluginName(1-1)defaultArch(5-5)defaultBuild(6-6)
🪛 GitHub Actions: CI - Main (API)
plugin/builder/build-plugin.ts
[error] 44-44: Error: Entity api_version not found in XML at updateEntityValue function.
[error] Command failed with exit code 1.
🪛 YAMLlint (1.35.1)
plugin/docker-compose.yml
[error] 23-23: no new line character at the end of file
(new-line-at-end-of-file)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Cloudflare Pages
🔇 Additional comments (19)
.github/workflows/build-plugin.yml (1)
117-117: LGTM: API version parameter added correctlyThe build script now correctly passes the API version, which is essential for generating Slackware-style package names.
plugin/docker-compose.yml (1)
10-10: LGTM: .nvmrc volume mountingCorrectly mounts the Node.js version specification file from the host to the container.
plugin/builder/utils/bucket-urls.ts (1)
1-1: LGTM: Architecture and build parameters added correctlyThe code now properly incorporates Slackware package naming conventions by including architecture and build number in the TXZ filename.
Also applies to: 50-50
plugin/scripts/dc.sh (2)
20-22: Robust API version detection implemented.The script now dynamically determines the API version based on git tags and package.json, providing a standardized version format that follows semantic versioning conventions (simple version for tagged commits, version+SHA for development builds).
34-34: Good integration of API_VERSION with Docker environment.The API_VERSION is correctly passed to the Docker container, ensuring consistent versioning throughout the build process.
plugin/builder/cli/setup-plugin-environment.ts (3)
12-12: Added apiVersion to safe parse schema.Correctly added as an optional string in the initial schema.
28-28: Properly enforced apiVersion requirement.The apiVersion is correctly required in the extended schema with an appropriate error message.
110-114: Added required API version CLI option.The CLI interface is appropriately configured to require the API version with proper defaults from environment variables, maintaining consistency with other options.
plugin/builder/utils/consts.ts (2)
4-7: Added Slackware package constants.Good addition of default architecture and build constants for Slackware packaging standards.
8-10: Updated getTxzName for Slackware naming convention.The function now follows Slackware package naming convention (name-version-arch-build.txz) while maintaining backward compatibility.
plugin/builder/build-plugin.ts (3)
5-5: Updated imports for Slackware packaging.Correctly imported the default architecture and build constants.
🧰 Tools
🪛 GitHub Actions: CI - Main (API)
[error] Command failed with exit code 1.
29-32: Improved function parameter approach.Refactored to use object destructuring for better maintainability and type safety.
🧰 Tools
🪛 GitHub Actions: CI - Main (API)
[error] Command failed with exit code 1.
53-56: Added API version parameter and logging.The buildPlugin function now accepts and logs the API version parameter.
🧰 Tools
🪛 GitHub Actions: CI - Main (API)
[error] Command failed with exit code 1.
plugin/plugins/dynamix.unraid.net.plg (6)
33-55: Disk space check looks goodThis pre-installation check ensures at least 300MB free space on /usr before proceeding, which is a sensible safeguard for the new Slackware package approach.
80-86: PHP version check now allows installation with warningsThe compatibility check has been changed from failing the installation to only warning the user when running on unsupported Unraid versions (< 6.12.0 or 6.12.0-beta/rc). This allows installation on incompatible versions with a warning.
While this provides flexibility, please verify that the plugin can still function with minimal issues on older versions.
97-107: Package removal implementation looks goodThe uninstall process now properly uses Slackware package management with a fallback mechanism. It first tries to find any installed dynamix.unraid.net package in the Slackware package logs before falling back to the basic package name.
136-139: Improved installation completion messageThe success message clearly indicates when it's safe for the user to close the installation window, improving user experience.
145-156: Uninstall cleanup message is appropriateThe script provides a clear indication to users when the uninstallation process has completed successfully.
118-130: 🛠️ Refactor suggestionPackage installation implementation
The installation process now uses Slackware's
upgradepkgand includes a service startup via the rc script. This aligns well with the native Slackware package approach.However, there's a potential issue on line 124: if the file check fails, it displays an error message but doesn't exit the script despite the warning comment indicating it should result in a broken install.
Consider updating line 124 to:
-[[ ! -f /usr/local/emhttp/plugins/dynamix.my.servers/scripts/gitflash_log ]] && echo "⚠️ files missing from main txz" && exit 1 +if [[ ! -f /usr/local/emhttp/plugins/dynamix.my.servers/scripts/gitflash_log ]]; then + echo "⚠️ files missing from main txz" + exit 1 +fiThis makes the intention clearer and ensures the script will properly exit on failure.
Likely an incorrect or invalid review comment.
...in/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
Outdated
Show resolved
Hide resolved
...in/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
Show resolved
Hide resolved
There was a problem hiding this 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
🧹 Nitpick comments (1)
plugin/plugins/dynamix.unraid.net.plg (1)
98-108: Enhanced package removal logic with dynamic detectionThe updated removal script now correctly detects the installed package name from Slackware package logs before removal, with a proper fallback to the basic package name. This is more robust than hardcoding the package name.
Consider adding error handling for the
removepkgcommand to detect and report any failures during package removal:echo "Removing package: $pkg_basename" - removepkg --terse "$pkg_basename" + if ! removepkg --terse "$pkg_basename"; then + echo "Error: Failed to remove package $pkg_basename" + exit 1 + fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (4)
plugin/builder/build-txz.ts(3 hunks)plugin/docs/migration/progress.md(1 hunks)plugin/plugins/dynamix.unraid.net.plg(4 hunks)unraid-ui/package.json(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- unraid-ui/package.json
🚧 Files skipped from review as they are similar to previous changes (2)
- plugin/builder/build-txz.ts
- plugin/docs/migration/progress.md
⏰ 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 (7)
plugin/plugins/dynamix.unraid.net.plg (7)
10-10: Added API version entity with empty valueThe new API version entity is correctly added to support the plugin build system that now includes an explicit
apiVersionparameter, but the value is currently empty. Ensure this value is properly populated during the build process.
34-55: Well-implemented disk space verificationThe disk space check before installation is appropriately implemented to ensure there's at least 300MB free space on
/usr, which is important for preventing installation failures due to insufficient space. Good error handling and user-friendly messages are included.
67-91: Improved Unraid version compatibility checkThe compatibility check properly verifies the Unraid version is 6.12.0 or higher and isn't a beta/rc version. The improved output messages in lines 81, 85-86 are more informative, clearly indicating supported status or warning about potential issues on unsupported versions.
119-126: Streamlined package installation with verificationThe installation process is properly simplified to use the Slackware
upgradepkgcommand and includes an essential verification step to confirm the expected files exist after installation.
127-130: Proper Slackware service initializationThe implementation correctly starts the Unraid API service using the Slackware-style rc script after installation, checking for script existence and executability before running it.
137-139: Clear installation completion messageThe improved completion message clearly indicates when the installation is complete and that it's safe to close the window.
146-157: Clean uninstall completion messageThe uninstall completion message provides clear feedback to the user when the uninstallation process is complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (7)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.sh (3)
9-9: VariableRC_SCRIPTis defined but never usedThe
RC_SCRIPTvariable is defined but not referenced anywhere else in the script. Either use it or remove it to avoid confusion.-RC_SCRIPT="/etc/rc.d/rc.unraid-api"🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 9-9: RC_SCRIPT appears unused. Verify use (or export if used externally).
(SC2034)
29-32: Consider checking the return code of setup_api.shThe script runs
setup_api.shwithout checking its return code. This could lead to continuing with validation even if the setup script failed.# Run the setup script echo "Running setup_api.sh..." "$SETUP_SCRIPT" +SETUP_RESULT=$? +if [ $SETUP_RESULT -ne 0 ]; then + echo "✗ Setup script failed with exit code: $SETUP_RESULT" + exit 1 +fi
69-76: Add specific messages for each rc file checkThe current implementation uses the same success/failure message for all rc files, but they serve different purposes - rc.M/rc.local are for startup while rc.0/rc.6 are for shutdown.
# Check if startup/shutdown configurations were added for RCFILE in "/etc/rc.d/rc.M" "/etc/rc.d/rc.local" "/etc/rc.d/rc.0" "/etc/rc.d/rc.6"; do if [ -f "$RCFILE" ] && grep -q "rc.unraid-api" "$RCFILE"; then - echo "✓ rc.unraid-api entry found in $RCFILE" + case "$RCFILE" in + "/etc/rc.d/rc.M"|"/etc/rc.d/rc.local") + echo "✓ rc.unraid-api startup entry found in $RCFILE" + ;; + "/etc/rc.d/rc.0"|"/etc/rc.d/rc.6") + echo "✓ rc.unraid-api shutdown entry found in $RCFILE" + ;; + esac else - echo "✗ rc.unraid-api entry not found in $RCFILE" + case "$RCFILE" in + "/etc/rc.d/rc.M"|"/etc/rc.d/rc.local") + echo "✗ rc.unraid-api startup entry not found in $RCFILE" + ;; + "/etc/rc.d/rc.0"|"/etc/rc.d/rc.6") + echo "✗ rc.unraid-api shutdown entry not found in $RCFILE" + ;; + esac fi doneplugin/docs/migration/progress.md (1)
5-5: Incomplete date in progress reportThe date "2024-05-XX" should be updated with the actual completion date.
-### 2024-05-XX +### 2024-05-15plugin/plugins/dynamix.unraid.net.plg (3)
108-109: Use consistent XML entity referencesTAG="&tag;" directly references the XML entity inline, which is inconsistent with how XML entities are typically used in this file.
- TAG="&tag;" MAINTXZ="&source;.txz" - VENDOR_ARCHIVE="/boot/config/plugins/dynamix.my.servers/&vendor_store_filename;" + TAG="&tag;" + MAINTXZ="&source;.txz" + VENDOR_ARCHIVE="/boot/config/plugins/dynamix.my.servers/&vendor_store_filename;"
117-117: Improve error message clarityThe error message "files missing from main txz" doesn't clearly indicate which specific file is missing.
-[[ ! -f /usr/local/emhttp/plugins/dynamix.my.servers/scripts/gitflash_log ]] && echo "⚠️ files missing from main txz" && exit 1 +[[ ! -f /usr/local/emhttp/plugins/dynamix.my.servers/scripts/gitflash_log ]] && echo "⚠️ Critical file missing: /usr/local/emhttp/plugins/dynamix.my.servers/scripts/gitflash_log" && exit 1
120-122: Add error handling for service start operationThe script starts the unraid-api service but doesn't check if it started successfully.
# Start the Unraid API service using the rc script if [[ -x /etc/rc.d/rc.unraid-api ]]; then /etc/rc.d/rc.unraid-api start + if [ $? -ne 0 ]; then + echo "⚠️ Warning: Failed to start the Unraid API service" + # Continue installation despite service start failure + else + echo "✅ Unraid API service started successfully" + fi fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (11)
.gitignore(1 hunks)plugin/.gitignore(1 hunks)plugin/builder/build-plugin.ts(4 hunks)plugin/builder/build-txz.ts(3 hunks)plugin/builder/utils/nodejs-helper.ts(1 hunks)plugin/docs/migration/progress.md(1 hunks)plugin/plugins/dynamix.unraid.net.plg(3 hunks)plugin/source/dynamix.unraid.net/install/doinst.sh(1 hunks)plugin/source/dynamix.unraid.net/install/scripts/file_patches.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.sh(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- .gitignore
🚧 Files skipped from review as they are similar to previous changes (6)
- plugin/builder/build-txz.ts
- plugin/source/dynamix.unraid.net/install/scripts/file_patches.sh
- plugin/.gitignore
- plugin/builder/utils/nodejs-helper.ts
- plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
- plugin/builder/build-plugin.ts
🧰 Additional context used
🪛 Shellcheck (0.10.0)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/test-setup-api.sh
[warning] 9-9: RC_SCRIPT appears unused. Verify use (or export if used externally).
(SC2034)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build API
- GitHub Check: Build Web App
- GitHub Check: Test API
- GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
plugin/source/dynamix.unraid.net/install/doinst.sh (1)
80-87: Consider implementing one of the suggested service startup optionsThe comment indicates several options for proper Slackware service integration, but notes that you're temporarily using the .plg file. You should create an issue to track this so it doesn't remain as a temporary solution.
Could you search for any existing issues tracking the implementation of proper Slackware service startup for rc.unraid-api? If not, please consider creating one to track this task.
plugin/docs/migration/progress.md (1)
1-126: Well-structured migration documentationThis documentation clearly outlines completed tasks, pending tasks, and next steps for the Slackware package migration. The detailed API build process section is particularly helpful. Keep updating this as progress continues.
plugin/plugins/dynamix.unraid.net.plg (2)
7-15: Good job standardizing entity naming conventionsThe consistent lowercase naming for entities and the addition of architecture and build entities align well with Slackware package conventions.
91-100: Well-implemented package detection for removalThe script now intelligently detects the installed package from logs before removal, with a good fallback mechanism.
There was a problem hiding this 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
🧹 Nitpick comments (6)
plugin/source/dynamix.unraid.net/install/doinst.sh (2)
76-79: Quote absolute path for rc.unraid-api check
The absolute path/etc/rc.d/rc.unraid-apiis unquoted in both the test and thechmodinvocation. To prevent word-splitting or globbing on unusual directory names, wrap the literal path in quotes.Proposed diff:
- if [ -f /etc/rc.d/rc.unraid-api ]; then - chmod 755 /etc/rc.d/rc.unraid-api + if [ -f "/etc/rc.d/rc.unraid-api" ]; then + chmod 755 "/etc/rc.d/rc.unraid-api"
1-13: Consider enforcing strict error handling
Addingset -euo pipefailnear the top (after the shebang) would cause the script to exit on failures, undefined variables, or pipeline errors. This can help catch errors early and avoid silent failures in later steps.Example addition:
#!/bin/sh +set -euo pipefail # Main installation script for dynamix.unraid.net packageplugin/docs/migration/progress.md (4)
5-9: Replace placeholder date with actual date
The header### 2024-05-XXstill contains a placeholder. Please update it to the correct date of the completed tasks to maintain accurate historical records.
54-67: Remove duplicate Next Steps and Progress sections
The document has two## Next Stepsand two high-level migration progress headings (## Next Stepsat line 54 and again at line 126;# Plugin Migration to Slackware Packageat line 113). Consolidate these to avoid redundancy and improve readability.
71-93: Unify API Build Process headings
You have both## Building the API Packageand## API Build Processcovering the same content. Merging these into a single heading will streamline the section and prevent confusion.
7-13: Standardize bullet list indentation and style
Nested lists currently mix single-space indentation and inconsistent list markers. For clarity, use two-space indents for sub-bullets and choose either-or1.style uniformly.Also applies to: 30-37
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (2)
plugin/docs/migration/progress.md(1 hunks)plugin/source/dynamix.unraid.net/install/doinst.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build Web App
- GitHub Check: Test API
- GitHub Check: Build API
- GitHub Check: Cloudflare Pages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (1)
plugin/plugins/dynamix.unraid.net.plg(3 hunks)
⏰ 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 (7)
plugin/plugins/dynamix.unraid.net.plg (7)
3-16: Simplified entity definitions align with Slackware packaging approachThe entity definitions have been updated to support native Slackware packaging with new architecture and build number entities. Several placeholders are intentionally empty as they'll be populated during the build process.
19-20: LGTM: Plugin declaration updated to reference new entitiesThe plugin declaration correctly references the updated entities while maintaining the minimum Unraid version requirement.
27-48: Disk space verification is appropriate for package installationThe 300MB free space check on /usr is a good safeguard before installation. The error handling and messaging are clear.
50-58: Package download section uses placeholder entitiesThis section will download the vendor store file and main package using the placeholders defined in the entity section. The SHA256 verification adds security to the download process.
60-84: Version compatibility check changed from blocker to warningThe PHP version check now only warns users about incompatible versions rather than preventing installation. This is more user-friendly but might lead to unexpected behavior on unsupported systems.
Consider adding more specific information about what functionality might not work on unsupported versions to help users make informed decisions.
86-104: Dynamic package detection for uninstallation looks robustThe uninstall script now dynamically detects the installed package from /var/log/packages/, which is more flexible than using a hardcoded package name. The fallback to the basic package name is a good safety measure.
139-150: LGTM: Clean uninstall completion messageThe uninstall completion message is concise and clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (3)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh (3)
107-115: Fix plugin environment file path
The script checks/boot/config/plugins/dynamix.my.servers/envbut should targetdynamix.unraid.net.Suggested patch:
@@ -107,1 +107,1 @@ ENV_FILE="/boot/config/plugins/dynamix.my.servers/env" -ENV_FILE="/boot/config/plugins/dynamix.my.servers/env" +ENV_FILE="/boot/config/plugins/dynamix.unraid.net/env"
122-131: Correct shutdown script name for flash_backup
Checks/etc/rc.d/rc.flash_backup(underscore) but the actual script uses a dash.Suggested patch:
@@ -124,1 +124,1 @@ if [ -f "/etc/rc.d/rc.flash_backup" ]; then -if [ -f "/etc/rc.d/rc.flash_backup" ]; then +if [ -f "/etc/rc.d/rc.flash-backup" ]; then
17-22:⚠️ Potential issueIncorrect plugin path in CRITICAL_FILES
Paths referencedynamix.my.serversinstead ofdynamix.unraid.net, causing false negatives.Apply this patch:
@@ -19,1 +19,1 @@ CRITICAL_FILES="/usr/local/bin/unraid-api -/usr/local/emhttp/plugins/dynamix.my.servers/scripts/gitflash_log +/usr/local/emhttp/plugins/dynamix.unraid.net/scripts/gitflash_log
🧹 Nitpick comments (3)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh (3)
6-6: Reconsiderset -efor a diagnostic script
Globalset -ewill exit on any unexpected non-zero status outside conditionals, which may prematurely terminate this verification. Since the script handles errors explicitly and always exits 0, consider removingset -eto avoid unintended exits.
161-167: Consider treating missing log file as an error
Currently, absence of the log file only warns without incrementingTOTAL_ERRORS. For consistency, you may want to count it as an error.
178-188: Exit code always zero; may not integrate with CI
Script exits with 0 even when errors are found. If this will be used in automated tests, consider exiting non-zero onTOTAL_ERRORS > 0.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (1)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build Web App
- GitHub Check: Test API
- GitHub Check: Build API
- GitHub Check: Cloudflare Pages
🔇 Additional comments (11)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh (11)
9-12: Color code definitions are clear and POSIX-compliant
The ANSI codes are well-defined and used consistently for output messages.
14-14: Introductory echo message is informative
The startup message clearly indicates the verification process.
41-52: Executable check function is robust
The function correctly distinguishes between executable, non-executable, and missing files with clear output.
55-63: Directory check function is straightforward
check_diraccurately reports existing and missing directories.
66-74: Symlink check implementation is solid
The function cleanly reports symlink existence and target resolution.
77-83: Executable files loop is implemented correctly
Iterating over$CRITICAL_FILESand accumulating errors is logical.
87-93: Directory verification loop is accurate
Checks each critical directory and tallies errors as expected.
97-103: Symlink verification loop is correct
Properly iterates through$CRITICAL_SYMLINKSand tracks failures.
133-139: Shutdown check forunraid-apiis correct
VerifiesK20unraid-apiexists and is executable inrc6.d.
141-149:rc0.dsymlink or directory check is comprehensive
Handles both symlink and directory cases cleanly.
153-159:unraid-apiPATH check is valid
Usingcommand -vwithin anifavoids exiting early underset -eand correctly flags absence.
...urce/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh
Show resolved
Hide resolved
There was a problem hiding this 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
♻️ Duplicate comments (2)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh (2)
100-110:⚠️ Potential issueFix plugin environment file path
The script checks/boot/config/plugins/dynamix.my.servers/env, but your plugin usesdynamix.unraid.net. UpdateENV_FILEaccordingly.@@ -101,1 +101,1 @@ ENV_FILE="/boot/config/plugins/dynamix.my.servers/env" -ENV_FILE="/boot/config/plugins/dynamix.my.servers/env" +ENV_FILE="/boot/config/plugins/dynamix.unraid.net/env"
19-24: 🛠️ Refactor suggestionRemove outdated CRITICAL_DIRS entry
The directory/usr/local/emhttp/plugins/dynamix.my.serversis not part of this plugin. Please remove or update it to/usr/local/emhttp/plugins/dynamix.unraid.net.@@ -21,1 +21,0 @@ CRITICAL_DIRS="/usr/local/unraid-api -/usr/local/emhttp/plugins/dynamix.my.servers + # removed outdated plugin directory
🧹 Nitpick comments (3)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh (3)
6-7: Consider usingbashand runningshellcheck
Switching the shebang to#!/usr/bin/env bashcan improve portability (e.g., consistent behavior of built-ins likereadlink) and enable the use of more robust Bash features. Running shellcheck will also catch potential pitfalls early.
155-160: Treat missing installation log as an error
Currently a missing log file only triggers a warning without incrementingTOTAL_ERRORS. Counting it as an error ensures that log creation is validated.@@ -158,3 +158,4 @@ if [ -f "/var/log/unraid-api/dynamix-unraid-install.log" ]; then - printf '✓ Installation log file exists\n' + printf '✓ Installation log file exists\n' else - printf '⚠ Installation log file not found\n' + printf '✗ Installation log file not found\n' + TOTAL_ERRORS=$((TOTAL_ERRORS + 1)) fi
172-182: Exit non-zero on failures for CI integration
Since this is a verification script, you may want a non-zero exit code when errors are detected to integrate with automated pipelines.@@ -174,2 +174,8 @@ else echo "Installation verification completed with issues." - # We don't exit with error as this is just a verification script - exit 0 + echo "See log file for details: /var/log/unraid-api/dynamix-unraid-install.log" + # Exit with failure to signal issues in CI + exit 1 fi
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (1)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Build and Deploy Plugin / Build and Deploy Plugin
- GitHub Check: Cloudflare Pages
...urce/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh
Show resolved
Hide resolved
...urce/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/verify_install.sh
Show resolved
Hide resolved
There was a problem hiding this comment.
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 (2)
plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api (2)
77-81: Consider adding error handling in restart function.While functionally correct, the restart function doesn't check the return code from stop before attempting to start.
restart() { - stop + if ! stop; then + echo "Warning: Error stopping service, attempting to start anyway" + fi sleep 2 start }
28-64: Consider checking for log directory creation errors.The script creates a log directory but doesn't verify success.
# Create log directory if it doesn't exist -mkdir -p /var/log/unraid-api +mkdir -p /var/log/unraid-api || { + echo "Warning: Failed to create log directory" +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (3)
plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/file_patches.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/file_patches.sh
- plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/install/scripts/setup_api.sh
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build Web App
- GitHub Check: Test API
- GitHub Check: Build API
- GitHub Check: Cloudflare Pages
🔇 Additional comments (7)
plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api (7)
11-13: Clear base directory definitions improve maintainability.The addition of centralized path variables makes the script more maintainable and easier to update if locations change.
14-17: Good addition of script permission handling.Ensuring all scripts in the directory are executable prevents permission-related failures when executing dependencies.sh and other scripts.
28-64: Well-structured start function with proper error handling.The start function properly handles dependencies, environment setup, and service initialization. It correctly bubbles up dependency-install failures as suggested in previous reviews.
66-75: Clean implementation of stop function.The stop function appropriately checks for binary existence and propagates the return code from the binary.
83-91: Status function implementation is correct.The status function properly checks binary existence and propagates the return code.
112-119: Consider using return instead of exit in the ensure case.Using exit within a function terminates the entire script, while return would only exit the function. However, in this case statement context, either approach works.
128-140: Good parameter validation for redownload-vendor-archive.The script correctly validates required parameters before calling the dependencies script.
| if [ -x "/etc/rc.d/rc.flash_backup" ]; then | ||
| echo "Starting flash backup service..." | ||
| /etc/rc.d/rc.flash_backup start | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
❓ Verification inconclusive
Consider stopping flash backup service in stop function.
The start function launches the flash backup service but the stop function doesn't stop it, which might leave it running after API shutdown.
Run this to check if the flash backup is stopped elsewhere:
🏁 Script executed:
#!/bin/bash
# Check if the flash backup service is stopped elsewhere
grep -r "rc.flash_backup stop" /etc/rc.d/ | grep -v "rc.unraid-api"Length of output: 111
#!/bin/bash
# Search for rc.flash_backup stop invocation in the plugin’s rc.d directory
grep -R "rc.flash_backup stop" plugin/source/dynamix.unraid.net/etc/rc.d/ || echo "No stop call found"
# Extract the stop() function from rc.unraid-api to confirm current behavior
awk '/^stop *\(\)/,/^}/' plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api#!/bin/bash
# Extract stop() function from rc.unraid-api
sed -n '/^stop *()/,/^}/!d' plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api || echo "stop function not found"
# Search for any rc.flash_backup stop invocations in the rc.d directory
grep -R "rc.flash_backup stop" plugin/source/dynamix.unraid.net/etc/rc.d/ || echo "No rc.flash_backup stop calls found"#!/bin/bash
# Display the stop() function in rc.unraid-api
awk '/^stop *\(\)/,/^}/' plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api || echo "stop() not found"
# Search for any rc.flash_backup stop calls in the plugin directory
grep -R "rc.flash_backup stop" plugin/source/dynamix.unraid.net/ || echo "No rc.flash_backup stop invocation found"Stop flash backup service in stop()
The stop() function in rc.unraid-api doesn’t currently shut down the flash backup service, so it may remain running after API teardown. Please add a stop invocation:
stop() {
# existing teardown steps…
+ if [ -x "/etc/rc.d/rc.flash_backup" ]; then
+ echo "Stopping flash backup service..."
+ /etc/rc.d/rc.flash_backup stop
+ fi
exit 0
}• File: plugin/source/dynamix.unraid.net/etc/rc.d/rc.unraid-api – inside the stop() function
• Ensures the flash backup service is cleanly stopped on API shutdown.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [ -x "/etc/rc.d/rc.flash_backup" ]; then | |
| echo "Starting flash backup service..." | |
| /etc/rc.d/rc.flash_backup start | |
| fi | |
| stop() { | |
| # existing teardown steps… | |
| if [ -x "/etc/rc.d/rc.flash_backup" ]; then | |
| echo "Stopping flash backup service..." | |
| /etc/rc.d/rc.flash_backup stop | |
| fi | |
| exit 0 | |
| } |
There was a problem hiding this comment.
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 (7)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/dependencies.sh (7)
10-12: Allow overriding the dependencies directory
MakeDEPENDENCIES_DIRconfigurable via environment variable, falling back to the default.-DEPENDENCIES_DIR="/usr/local/unraid-api/node_modules" +: "${DEPENDENCIES_DIR:=/usr/local/unraid-api/node_modules}"
16-49: Enhance download reliability with retries and timeouts
Adding retry logic and a timeout tocurlhelps mitigate transient network failures.# Attempt to download the vendor archive echo "Downloading vendor archive from $vendor_store_url to $vendor_store_path" - if curl -f -L "$vendor_store_url" -o "$vendor_store_path"; then + if curl -f -L --retry 3 --retry-delay 5 --max-time 60 \ + "$vendor_store_url" -o "$vendor_store_path"; then echo "Successfully downloaded vendor archive to $vendor_store_path" # Return the path to the downloaded archive echo "$vendor_store_path" return 0
54-90: Unify logging destinations for info vs. errors
Currently informational messages are mixed between stdout and stderr. Reserve stderr only for errors.- echo "Looking for vendor archive at $vendor_store_path" >&2 + echo "Looking for vendor archive at $vendor_store_path" # Check if the expected archive exists
98-137: Localize the backup file variable in restore_dependencies
Prevent unintended global variable leakage by declaringbackup_fileaslocal.restore_dependencies() { - backup_file="$1" + local backup_file="$1" # Check if backup file exists if [ ! -f "$backup_file" ]; then
139-182: Preserve ownership when archiving dependencies
Ensure the archive retains root ownership metadata by adding--ownerand--groupflags totar.- if XZ_OPT=-5 tar -cJf "$archive_file" -C "$(dirname "$source_dir")" "$(basename "$source_dir")"; then + if XZ_OPT=-5 tar --owner=0 --group=0 \ + -cJf "$archive_file" \ + -C "$(dirname "$source_dir")" "$(basename "$source_dir")"; then echo "node_modules archive created successfully." return 0
184-210: Error out if provided archive path is invalid
Currently,ensuresilently falls back when the user passes a non-existent archive. Fail early to surface mis-typed paths.ensure() { - if [ -n "$1" ] && [ -f "$1" ]; then - echo "Using provided vendor archive: $1" - restore_dependencies "$1" - return $? + if [ -n "$1" ]; then + if [ -f "$1" ]; then + echo "Using provided vendor archive: $1" + restore_dependencies "$1" + return $? + else + echo "Error: Provided archive '$1' not found." >&2 + return 1 + fi fi
212-245: Redirect usage help to stderr and remove trailing whitespace
Usage messages should go to stderr to distinguish them from valid script output, and avoid stray spaces.*) - echo "Usage: $0 {restore|archive|ensure|redownload}" + echo "Usage: $0 {restore|archive|ensure|redownload}" >&2 exit 1 ;; esac
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (3)
plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/api_utils.sh(1 hunks)plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/dependencies.sh(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/api_utils.sh
🧰 Additional context used
🧬 Code Graph Analysis (1)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/dependencies.sh (1)
plugin/source/dynamix.unraid.net/usr/local/share/dynamix.unraid.net/scripts/api_utils.sh (1)
get_archive_information(28-70)
⏰ 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 (2)
plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/state.php (2)
149-151: Improved plugin detection approachThe change simplifies the plugin detection logic by checking for the existence of a single file (
/usr/local/bin/unraid-api) instead of searching through package directories. This is a cleaner approach that aligns with the standardized installation structure introduced in this PR.
158-159: Good centralization of version detection logicUsing the
api_utils.shscript to retrieve the API version centralizes this functionality and improves maintainability. The fallback to 'unknown' when the version can't be retrieved is a sensible default that prevents potential issues.
| #!/bin/bash | ||
| # Dependency management functions | ||
| # This script provides functions to manage node.js dependencies and vendor archives | ||
|
|
||
| # Source shared utilities | ||
| SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" | ||
| # shellcheck source=./api_utils.sh | ||
| source "${SCRIPT_DIR}/api_utils.sh" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add stricter Bash options for robustness
To fail fast on errors and unset variables, enable strict mode at the top of the script.
#!/bin/bash
+set -euo pipefail
+IFS=$'\n\t'
# Dependency management functions
# This script provides functions to manage node.js dependencies and vendor archives
# Source shared utilities📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #!/bin/bash | |
| # Dependency management functions | |
| # This script provides functions to manage node.js dependencies and vendor archives | |
| # Source shared utilities | |
| SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" | |
| # shellcheck source=./api_utils.sh | |
| source "${SCRIPT_DIR}/api_utils.sh" | |
| #!/bin/bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| # Dependency management functions | |
| # This script provides functions to manage node.js dependencies and vendor archives | |
| # Source shared utilities | |
| SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" | |
| # shellcheck source=./api_utils.sh | |
| source "${SCRIPT_DIR}/api_utils.sh" |
zackspear
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not seeing any issues after installing on a 7.1.1 server.
Just some nitpicks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
plugin/builder/build-vendor-store.ts (1)
59-61: Good implementation of directory creation guard.This properly addresses the previous review comment by ensuring the deploy directory exists before attempting to write files to it.
🧹 Nitpick comments (2)
plugin/builder/build-vendor-store.ts (2)
22-24: Consider adding directory existence check.The function correctly builds the path, but it would be more robust to verify that the vendor store directory exists before returning the path.
export function getVendorFullPath(version: string): string { + // Ensure the directory exists + if (!existsSync(vendorStorePath)) { + mkdirSync(vendorStorePath, { recursive: true }); + } return join(vendorStorePath, getVendorBundleName(version)); }
30-46: Potential fragility in API node_modules path resolution.The function assumes a specific directory structure relative to the current working directory, which might be brittle if the directory structure changes.
Consider making the API directory path configurable or using a more robust discovery mechanism:
async function createNodeModulesTarball(outputPath: string): Promise<void> { console.log(`Creating node_modules tarball at ${outputPath}`); try { - // Create a tarball of the node_modules directly from the API directory - const apiNodeModules = join(process.cwd(), "..", "api", "node_modules"); + // Use a configurable path or environment variable for API location + const apiDir = process.env.API_DIR || join(process.cwd(), "..", "api"); + const apiNodeModules = join(apiDir, "node_modules"); if (existsSync(apiNodeModules)) { console.log(`Found API node_modules at ${apiNodeModules}, creating tarball...`); - execSync(`tar -cJf "${outputPath}" -C "${join(process.cwd(), "..", "api")}" node_modules`); + execSync(`tar -cJf "${outputPath}" -C "${apiDir}" node_modules`); console.log(`Successfully created node_modules tarball at ${outputPath}`); return; } throw new Error(`API node_modules not found at ${apiNodeModules}`); } catch (error) { console.error(`Failed to create node_modules tarball: ${error}`); throw error; } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)
📒 Files selected for processing (5)
api/scripts/build.ts(2 hunks)plugin/builder/build-txz.ts(4 hunks)plugin/builder/build-vendor-store.ts(1 hunks)plugin/builder/cli/common-environment.ts(1 hunks)plugin/builder/utils/paths.ts(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- plugin/builder/utils/paths.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- api/scripts/build.ts
- plugin/builder/build-txz.ts
- plugin/builder/cli/common-environment.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
plugin/builder/build-vendor-store.ts (2)
plugin/builder/utils/paths.ts (2)
vendorStorePath(28-28)deployDir(17-17)plugin/builder/utils/consts.ts (1)
startingDir(11-11)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build Web App
- GitHub Check: Test API
- GitHub Check: Build API
- GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
plugin/builder/build-vendor-store.ts (3)
1-6: Good import organization with necessary imports for filesystem operations.The imports now include all the required modules for filesystem operations, error handling, and command execution.
13-15: Well-designed versioned naming function.This function provides a clear and consistent way to generate versioned filenames for the node_modules bundle.
58-94: Robust multi-location archive discovery with excellent error handling.The implementation properly checks multiple possible locations for the node modules archive with thorough error handling and logging.
| if (!foundArchive) { | ||
| console.log("Could not find existing node_modules archive, attempting to create one"); | ||
| // Create a temporary archive in the deploy directory | ||
| const tempArchivePath = join(deployDir, "temp-node-modules.tar.xz"); | ||
| await createNodeModulesTarball(tempArchivePath); | ||
| await copyFile(tempArchivePath, vendorStoreTarPath); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Missing cleanup of temporary archive file.
After creating and copying the temporary archive, there's no cleanup step to remove the temporary file.
if (!foundArchive) {
console.log("Could not find existing node_modules archive, attempting to create one");
// Create a temporary archive in the deploy directory
const tempArchivePath = join(deployDir, "temp-node-modules.tar.xz");
await createNodeModulesTarball(tempArchivePath);
await copyFile(tempArchivePath, vendorStoreTarPath);
+ // Clean up the temporary file
+ try {
+ await unlink(tempArchivePath);
+ console.log(`Removed temporary archive ${tempArchivePath}`);
+ } catch (error) {
+ console.warn(`Failed to remove temporary archive ${tempArchivePath}: ${error}`);
+ }
}Don't forget to add the import for unlink:
-import { copyFile, stat } from "node:fs/promises";
+import { copyFile, stat, unlink } from "node:fs/promises";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!foundArchive) { | |
| console.log("Could not find existing node_modules archive, attempting to create one"); | |
| // Create a temporary archive in the deploy directory | |
| const tempArchivePath = join(deployDir, "temp-node-modules.tar.xz"); | |
| await createNodeModulesTarball(tempArchivePath); | |
| await copyFile(tempArchivePath, vendorStoreTarPath); | |
| } | |
| // plugin/builder/build-vendor-store.ts | |
| // … other imports … | |
| -import { copyFile, stat } from "node:fs/promises"; | |
| +import { copyFile, stat, unlink } from "node:fs/promises"; | |
| export async function bundleVendorStore(apiVersion: string): Promise<void> { | |
| // … earlier code … | |
| if (!foundArchive) { | |
| console.log("Could not find existing node_modules archive, attempting to create one"); | |
| // Create a temporary archive in the deploy directory | |
| const tempArchivePath = join(deployDir, "temp-node-modules.tar.xz"); | |
| await createNodeModulesTarball(tempArchivePath); | |
| await copyFile(tempArchivePath, vendorStoreTarPath); | |
| // Clean up the temporary file | |
| try { | |
| await unlink(tempArchivePath); | |
| console.log(`Removed temporary archive ${tempArchivePath}`); | |
| } catch (error) { | |
| console.warn(`Failed to remove temporary archive ${tempArchivePath}: ${error}`); | |
| } | |
| } | |
| // … remaining code … | |
| } |
|
This plugin has been deployed to Cloudflare R2 and is available for testing. |
🤖 I have created a release *beep* *boop* --- ## [4.9.0](v4.8.0...v4.9.0) (2025-07-08) ### Features * add graphql resource for API plugins ([#1420](#1420)) ([642a220](642a220)) * add management page for API keys ([#1408](#1408)) ([0788756](0788756)) * add rclone ([#1362](#1362)) ([5517e75](5517e75)) * API key management ([#1407](#1407)) ([d37dc3b](d37dc3b)) * api plugin management via CLI ([#1416](#1416)) ([3dcbfbe](3dcbfbe)) * build out docker components ([#1427](#1427)) ([711cc9a](711cc9a)) * docker and info resolver issues ([#1423](#1423)) ([9901039](9901039)) * fix shading in UPC to be less severe ([#1438](#1438)) ([b7c2407](b7c2407)) * info resolver cleanup ([#1425](#1425)) ([1b279bb](1b279bb)) * initial codeql setup ([#1390](#1390)) ([2ade7eb](2ade7eb)) * initialize claude code in codebse ([#1418](#1418)) ([b6c4ee6](b6c4ee6)) * move api key fetching to use api key service ([#1439](#1439)) ([86bea56](86bea56)) * move to cron v4 ([#1428](#1428)) ([b8035c2](b8035c2)) * move to iframe for changelog ([#1388](#1388)) ([fcd6fbc](fcd6fbc)) * native slackware package ([#1381](#1381)) ([4f63b4c](4f63b4c)) * send active unraid theme to docs ([#1400](#1400)) ([f71943b](f71943b)) * slightly better watch mode ([#1398](#1398)) ([881f1e0](881f1e0)) * upgrade nuxt-custom-elements ([#1461](#1461)) ([345e83b](345e83b)) * use bigint instead of long ([#1403](#1403)) ([574d572](574d572)) ### Bug Fixes * activation indicator removed ([5edfd82](5edfd82)) * alignment of settings on ManagementAccess settings page ([#1421](#1421)) ([70c790f](70c790f)) * allow rclone to fail to initialize ([#1453](#1453)) ([7c6f02a](7c6f02a)) * always download 7.1 versioned files for patching ([edc0d15](edc0d15)) * api `pnpm type-check` ([#1442](#1442)) ([3122bdb](3122bdb)) * **api:** connect config `email` validation ([#1454](#1454)) ([b9a1b9b](b9a1b9b)) * backport unraid/webgui[#2269](https://github.com/unraid/api/issues/2269) rc.nginx update ([#1436](#1436)) ([a7ef06e](a7ef06e)) * bigint ([e54d27a](e54d27a)) * config migration from `myservers.cfg` ([#1440](#1440)) ([c4c9984](c4c9984)) * **connect:** fatal race-condition in websocket disposal ([#1462](#1462)) ([0ec0de9](0ec0de9)) * **connect:** mothership connection ([#1464](#1464)) ([7be8bc8](7be8bc8)) * console hidden ([9b85e00](9b85e00)) * debounce is too long ([#1426](#1426)) ([f12d231](f12d231)) * delete legacy connect keys and ensure description ([22fe91c](22fe91c)) * **deps:** pin dependencies ([#1465](#1465)) ([ba75a40](ba75a40)) * **deps:** pin dependencies ([#1470](#1470)) ([412b329](412b329)) * **deps:** storybook v9 ([#1476](#1476)) ([45bb49b](45bb49b)) * **deps:** update all non-major dependencies ([#1366](#1366)) ([291ee47](291ee47)) * **deps:** update all non-major dependencies ([#1379](#1379)) ([8f70326](8f70326)) * **deps:** update all non-major dependencies ([#1389](#1389)) ([cb43f95](cb43f95)) * **deps:** update all non-major dependencies ([#1399](#1399)) ([68df344](68df344)) * **deps:** update dependency @types/diff to v8 ([#1393](#1393)) ([00da27d](00da27d)) * **deps:** update dependency cache-manager to v7 ([#1413](#1413)) ([9492c2a](9492c2a)) * **deps:** update dependency commander to v14 ([#1394](#1394)) ([106ea09](106ea09)) * **deps:** update dependency diff to v8 ([#1386](#1386)) ([e580f64](e580f64)) * **deps:** update dependency dotenv to v17 ([#1474](#1474)) ([d613bfa](d613bfa)) * **deps:** update dependency lucide-vue-next to ^0.509.0 ([#1383](#1383)) ([469333a](469333a)) * **deps:** update dependency marked to v16 ([#1444](#1444)) ([453a5b2](453a5b2)) * **deps:** update dependency shadcn-vue to v2 ([#1302](#1302)) ([26ecf77](26ecf77)) * **deps:** update dependency vue-sonner to v2 ([#1401](#1401)) ([53ca414](53ca414)) * disable file changes on Unraid 7.2 ([#1382](#1382)) ([02de89d](02de89d)) * do not start API with doinst.sh ([7d88b33](7d88b33)) * do not uninstall fully on 7.2 ([#1484](#1484)) ([2263881](2263881)) * drop console with terser ([a87d455](a87d455)) * error logs from `cloud` query when connect is not installed ([#1450](#1450)) ([719f460](719f460)) * flash backup integration with Unraid Connect config ([#1448](#1448)) ([038c582](038c582)) * header padding regression ([#1477](#1477)) ([e791cc6](e791cc6)) * incorrect state merging in redux store ([#1437](#1437)) ([17b7428](17b7428)) * lanip copy button not present ([#1459](#1459)) ([a280786](a280786)) * move to bigint scalar ([b625227](b625227)) * node_modules dir removed on plugin update ([#1406](#1406)) ([7b005cb](7b005cb)) * omit Connect actions in UPC when plugin is not installed ([#1417](#1417)) ([8c8a527](8c8a527)) * parsing of `ssoEnabled` in state.php ([#1455](#1455)) ([f542c8e](f542c8e)) * pin ranges ([#1460](#1460)) ([f88400e](f88400e)) * pr plugin promotion workflow ([#1456](#1456)) ([13bd9bb](13bd9bb)) * proper fallback if missing paths config modules ([7067e9e](7067e9e)) * rc.unraid-api now cleans up older dependencies ([#1404](#1404)) ([83076bb](83076bb)) * remote access lifecycle during boot & shutdown ([#1422](#1422)) ([7bc583b](7bc583b)) * sign out correctly on error ([#1452](#1452)) ([d08fc94](d08fc94)) * simplify usb listing ([#1402](#1402)) ([5355115](5355115)) * theme issues when sent from graph ([#1424](#1424)) ([75ad838](75ad838)) * **ui:** notifications positioning regression ([#1445](#1445)) ([f73e5e0](f73e5e0)) * use some instead of every for connect detection ([9ce2fee](9ce2fee)) ### Reverts * revert package.json dependency updates from commit 711cc9a for api and packages/* ([94420e4](94420e4)) --- 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>
Summary by CodeRabbit
New Features
Bug Fixes
Chores