Skip to content

Conversation

@rmartinoscar
Copy link
Member

@rmartinoscar rmartinoscar commented Oct 9, 2025

test using sudo bash -c "$(curl -fsSL deploy-preview-169--pelica.netlify.app/updatePanel.sh)"

  • Remove useless maintenance mode.
  • Trim quotes when getting variables from .env
  • Install Composer only once backed up files are restored

Summary by CodeRabbit

  • New Features

    • Clearer, step-by-step update feedback and status messages.
    • Automatic creation of the backup directory with early failure reporting.
    • Improved SQLite handling: normalize database filename, trim quotes, and display chosen path.
    • Dedicated composer run after restore with success/failure messaging.
    • Finalized steps for storage symlinks, migrations/seeding, permissions, and restart with a final "Panel Updated!" confirmation.
  • Bug Fixes

    • Stronger validation and explicit exits to avoid partial updates.
    • Better handling when DB connection is missing, with sensible defaults.
    • Added checks and messages for backup, extraction, and cleanup failures.

@rmartinoscar rmartinoscar self-assigned this Oct 9, 2025
@netlify
Copy link

netlify bot commented Oct 9, 2025

Deploy Preview for pelica ready!

Name Link
🔨 Latest commit 8600031
🔍 Latest deploy log https://app.netlify.com/projects/pelica/deploys/68ebd92b52d03000091c86b9
😎 Deploy Preview https://deploy-preview-169--pelica.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Refactors static/updatePanel.sh to inline exits, add explicit failure handling, create and validate backup directory, normalize SQLite DB handling and messages, move Composer install to after restore, adjust backup/extract logic, and add final migration, permission, and restart steps with a final success exit.

Changes

Cohort / File(s) Summary of Changes
Update script overhaul
static/updatePanel.sh
Removed exitInstall wrapper and inlined exit flows; added explicit backup directory creation and failure checks; trimmed quotes and defaulted DB_CONNECTION/DB_DATABASE (sqlite) with informative echoes; changed backup logic to ensure env/assets/db backups; adjusted tarball extraction and error handling; moved composer install to post-restore with non-interactive flags and explicit success/failure messages; added storage symlink creation, migrations/seeding, permission/ownership adjustments, queue restart, and final "Panel Updated!" exit 0.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant S as static/updatePanel.sh
  participant FS as Filesystem
  participant DB as Database
  participant C as Composer

  U->>S: invoke updatePanel.sh
  S->>FS: ensure/create backup dir
  alt backup dir fail
    S-->>U: echo error + exit 1
  end

  S-->>U: detect DB_CONNECTION & DB_DATABASE (trim/ default sqlite)
  alt sqlite
    S-->>U: echo normalized DB filename
  end

  S->>FS: backup .env, storage assets, DB file(s)
  alt backup fail
    S-->>U: echo failure + exit 1
  end

  S->>FS: extract panel tarball
  alt extract fail
    S-->>U: echo failure + exit 1
  end

  S->>C: run composer install (post-restore, non-interactive)
  alt composer fails
    S-->>U: echo failure + exit 1
  end

  S->>FS: create storage symlink(s), set permissions/ownership
  S->>DB: run migrations and seeders
  alt migration fail
    S-->>U: echo failure + exit 1
  else success
    S-->>U: "Panel Updated!" + exit 0
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • notAreYouScared

Poem

I hop through lines to keep things sound,
Backups safe and tarballs found.
SQLite trimmed and Composer late,
Migrations run — the panel's great!
🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly conveys that the updatePanel script is being cleaned up, which accurately reflects the main focus of the changeset on streamlining and refactoring the updatePanel.sh script.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/updatePanel

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

❤️ Share

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

Copy link

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
static/updatePanel.sh (2)

69-90: Fix sqlite backup path construction

When DB_DATABASE already contains a path (e.g. database/database.sqlite or an absolute /var/www/.../database.sqlite), the current cp -a "$install_dir/database/$db_database" builds an invalid source path by prepending yet another database/. The backup then aborts, which breaks the whole update for a default Laravel sqlite setup. Please resolve by normalizing the sqlite path before copying (detect absolute vs. relative) and generate the backup filename from basename "$db_database".

-  cp -a "$install_dir/database/$db_database" "$backup_dir/$db_database.backup"
+  sqlite_path="$db_database"
+  if [[ "$sqlite_path" != /* ]]; then
+    sqlite_path="$install_dir/$sqlite_path"
+  fi
+  sqlite_filename=$(basename "$sqlite_path")
+
+  cp -a "$sqlite_path" "$backup_dir/$sqlite_filename.backup"

Be sure to reuse the same normalized variables later when restoring the database.


157-164: Restore sqlite using normalized path

After adjusting the backup step to normalize the sqlite path, the restore phase also needs to use the same resolved path/filename. Right now it still assumes $install_dir/database/$db_database, so it will continue to fail for values that include a path. Mirror the backup fix here:

-if [ -f "$backup_dir/$db_database.backup" ]; then
-  echo "Restoring sqlite database"
-  cp -a "$backup_dir/$db_database.backup" "$install_dir/database/$db_database"
+if [ -n "$sqlite_filename" ] && [ -f "$backup_dir/$sqlite_filename.backup" ]; then
+  echo "Restoring sqlite database"
+  cp -a "$backup_dir/$sqlite_filename.backup" "$sqlite_path"

Ensure sqlite_path/sqlite_filename are exported from the sqlite branch so they’re available here.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54d8e32 and 8600031.

📒 Files selected for processing (1)
  • static/updatePanel.sh (5 hunks)
🧰 Additional context used
🪛 Shellcheck (0.11.0)
static/updatePanel.sh

[warning] 166-166: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

(SC2164)

Copy link
Member

@Boy132 Boy132 left a comment

Choose a reason for hiding this comment

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

Can't test it on an actual panel but code wise LGTM.

@notAreYouScared notAreYouScared merged commit d54e15a into main Oct 20, 2025
5 checks passed
@notAreYouScared notAreYouScared deleted the chore/updatePanel branch October 20, 2025 18:16
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.

4 participants