Skip to content

Install v4 and upgrade#1149

Merged
saeedvaziry merged 4 commits into
4.xfrom
install-v4-and-upgrade-g2u5h
Jun 9, 2026
Merged

Install v4 and upgrade#1149
saeedvaziry merged 4 commits into
4.xfrom
install-v4-and-upgrade-g2u5h

Conversation

@saeedvaziry

@saeedvaziry saeedvaziry commented Jun 6, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Intelligent PHP selection (prefers PHP 8.4 when available), automatic enabling/starting of matching PHP-FPM, updated default PHP extensions, Composer and Redis installation, and adjusted PHP-FPM pool user.
  • Bug Fixes

    • Removes stale package sources before installs and improves recovery for config changes and nginx reloads.
  • Chores

    • Harder script failures: stricter shell mode, ownership/cleanup traps, safer upgrade flow, supervisor/start ordering tweaks, and forwarded CLI flags during upgrades.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b48db83-21aa-410e-9b58-66fcda5ca61e

📥 Commits

Reviewing files that changed from the base of the PR and between 7c580fe and f95dd62.

📒 Files selected for processing (2)
  • scripts/install.sh
  • scripts/upgrade-3x-to-4x.sh
💤 Files with no reviewable changes (1)
  • scripts/upgrade-3x-to-4x.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/install.sh

📝 Walkthrough

Walkthrough

Install script now removes stale ondrej/php apt entries, dynamically selects and installs a PHP version and extensions, retargets php-fpm to user vito, adjusts deployment ordering, and installs Composer/redis. Upgrade script tightens execution, prepares a clean repo, safely injects nginx /ws/ with backup/rollback, starts websocket supervisor, and switches to 4.x running update.sh.

Changes

Dynamic PHP Installation

Layer / File(s) Summary
Apt source cleanup and dynamic PHP version selection
scripts/install.sh
Removes stale ondrej/php apt sources, reads distro codename, prefers PHP 8.4 from ondrej/php when available, otherwise detects latest phpX.Y-fpm from repos; installs updated PHP extension set, retargets php-fpm pool to vito, and enables/starts the versioned php-fpm service.
Nginx tweak and post-deploy ordering
scripts/install.sh
Removes an inline nginx ssl_protocols comment, runs php artisan optimize before chown -R vito:vito /home/vito, starts worker:* and websocket via supervisorctl before adding the crontab schedule, and installs Composer and redis-server.

3.x→4.x Upgrade Process Hardening

Layer / File(s) Summary
Safer upgrade preparation and stricter execution
scripts/upgrade-3x-to-4x.sh
Enables strict bash (set -uo pipefail), sets COMPOSER_ALLOW_SUPERUSER=1, verifies VITO_DIR, installs an EXIT ownership-restore trap, and uses git reset --hard + git clean -fd to prepare a clean repo state.
Nginx websocket proxy configuration with error recovery
scripts/upgrade-3x-to-4x.sh
When the nginx vhost exists, creates a backup before inserting a /ws/ proxy block, verifies the insertion, runs nginx -t, restarts on success, and restores the backup on failure; emits a manual-action warning if vhost is missing.
Websocket supervisor startup and 4.x branch switch
scripts/upgrade-3x-to-4x.sh
Attempts to start the websocket supervisor program (tolerant of failures), fetches tags, checks out the 4.x branch with error handling, runs scripts/update.sh forwarding "$@", and prints targeted error or success messages.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 I nibbled stale apt crumbs away,
Picked PHP versions for the day,
Guarded nginx with a careful backup,
Started websockets, then switched the stack up,
Hopped off happy — upgrades cleared the way.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main purpose of the changeset: installing v4 and handling the upgrade process.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch install-v4-and-upgrade-g2u5h

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

@saeedvaziry saeedvaziry changed the base branch from 3.x to 4.x June 6, 2026 14:25
@saeedvaziry saeedvaziry marked this pull request as ready for review June 6, 2026 15:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (1)
scripts/install.sh (1)

124-124: 💤 Low value

Declare and assign separately to avoid masking return values.

If the pipeline fails, the non-zero exit status is masked by export. Split declaration from assignment to preserve the exit status for debugging.

🔧 Suggested fix
-  export V_PHP_VERSION=$(apt-cache search --names-only '^php[0-9]+\.[0-9]+-fpm$' | grep -oE '^php[0-9]+\.[0-9]+-fpm' | grep -oE '[0-9]+\.[0-9]+' | sort -V | tail -n 1)
+  V_PHP_VERSION=$(apt-cache search --names-only '^php[0-9]+\.[0-9]+-fpm$' | grep -oE '^php[0-9]+\.[0-9]+-fpm' | grep -oE '[0-9]+\.[0-9]+' | sort -V | tail -n 1)
+  export V_PHP_VERSION
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/install.sh` at line 124, The current single-line use of export with
command substitution masks the command's exit status; split the steps: run the
pipeline that computes the PHP version into an assignment to V_PHP_VERSION
(using the existing pipeline: apt-cache search ... | grep -oE ... | sort -V |
tail -n 1), then check the command/result (e.g., test exit code or check for
empty string) and handle failure (log and exit non-zero) before exporting
V_PHP_VERSION; ensure you reference the same variable name V_PHP_VERSION so
subsequent code uses the exported value.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/install.sh`:
- Line 136: Replace the non-functional "service php${V_PHP_VERSION}-fpm enable"
invocation in scripts/install.sh with a systemd-based call; specifically locate
the occurrence of the string "service php${V_PHP_VERSION}-fpm enable" and change
it to use "systemctl enable" (or "systemctl enable --now" if you want to enable
and start the unit immediately) for the php${V_PHP_VERSION}-fpm unit so the
service is properly enabled under systemd.

---

Nitpick comments:
In `@scripts/install.sh`:
- Line 124: The current single-line use of export with command substitution
masks the command's exit status; split the steps: run the pipeline that computes
the PHP version into an assignment to V_PHP_VERSION (using the existing
pipeline: apt-cache search ... | grep -oE ... | sort -V | tail -n 1), then check
the command/result (e.g., test exit code or check for empty string) and handle
failure (log and exit non-zero) before exporting V_PHP_VERSION; ensure you
reference the same variable name V_PHP_VERSION so subsequent code uses the
exported value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bfd1d4c8-4099-4bb3-8c43-ce879b6ac663

📥 Commits

Reviewing files that changed from the base of the PR and between 51418db and 443f5b8.

📒 Files selected for processing (2)
  • scripts/install.sh
  • scripts/upgrade-3x-to-4x.sh

Comment thread scripts/install.sh Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
scripts/install.sh (1)

117-125: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don’t treat probe failures as “codename unsupported.”

A transient DNS/TLS/network failure at Line 117 currently takes the same path as a real missing Release file, so the installer can silently fall back to distro PHP on releases where the rest of the repo still expects ondrej/php + 8.4. That turns a temporary outage into a different runtime selection.

🐛 Proposed fix
-if curl -fsSL "https://ppa.launchpadcontent.net/ondrej/php/ubuntu/dists/${V_DISTRO_CODENAME}/Release" -o /dev/null; then
+V_ONDREJ_RELEASE_URL="https://ppa.launchpadcontent.net/ondrej/php/ubuntu/dists/${V_DISTRO_CODENAME}/Release"
+V_ONDREJ_RELEASE_STATUS="$(curl -sS -o /dev/null -w '%{http_code}' --retry 3 "${V_ONDREJ_RELEASE_URL}" || true)"
+
+if [[ "${V_ONDREJ_RELEASE_STATUS}" == "200" ]]; then
   export V_PHP_VERSION="8.4"
   add-apt-repository ppa:ondrej/php -y
   apt update
-else
+elif [[ "${V_ONDREJ_RELEASE_STATUS}" == "404" ]]; then
   echo "ondrej/php has no packages for '${V_DISTRO_CODENAME}'; using the distribution's PHP."
   apt update
   V_PHP_VERSION=$(apt-cache search --names-only '^php[0-9]+\.[0-9]+-fpm$' | grep -oE '^php[0-9]+\.[0-9]+-fpm' | grep -oE '[0-9]+\.[0-9]+' | sort -V | tail -n 1)
   export V_PHP_VERSION
+else
+  echo "Error: failed to probe ondrej/php for '${V_DISTRO_CODENAME}' (HTTP ${V_ONDREJ_RELEASE_STATUS:-connection error})." && exit 1
 fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/install.sh` around lines 117 - 125, The current single curl probe for
ondrej/php using V_DISTRO_CODENAME can treat transient network/DNS/TLS failures
as "unsupported"; replace that probe with a small retry-and-verify check: run
curl in a loop (e.g., 3 attempts with short backoff) using curl -sS -o /dev/null
-w '%{http_code}' (or --head -I) to ensure you get an HTTP 200 before deciding
the PPA exists; only when all retries complete with a non-200 result should you
fall back to computing V_PHP_VERSION from apt. Update the conditional that
currently uses curl -fsSL ... to use this retry+status-check logic and keep
exporting V_PHP_VERSION and calling add-apt-repository/apt update in the success
path, preserving variable names V_DISTRO_CODENAME and V_PHP_VERSION.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@scripts/install.sh`:
- Around line 117-125: The current single curl probe for ondrej/php using
V_DISTRO_CODENAME can treat transient network/DNS/TLS failures as "unsupported";
replace that probe with a small retry-and-verify check: run curl in a loop
(e.g., 3 attempts with short backoff) using curl -sS -o /dev/null -w
'%{http_code}' (or --head -I) to ensure you get an HTTP 200 before deciding the
PPA exists; only when all retries complete with a non-200 result should you fall
back to computing V_PHP_VERSION from apt. Update the conditional that currently
uses curl -fsSL ... to use this retry+status-check logic and keep exporting
V_PHP_VERSION and calling add-apt-repository/apt update in the success path,
preserving variable names V_DISTRO_CODENAME and V_PHP_VERSION.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 74ac68e4-76a5-48e3-96a0-002c1cb715b2

📥 Commits

Reviewing files that changed from the base of the PR and between 443f5b8 and 7c580fe.

📒 Files selected for processing (1)
  • scripts/install.sh

Comment thread scripts/install.sh
# releases may not be published there yet, so fall back to the distribution's own PHP
# (e.g. Ubuntu 26.04 ships PHP 8.5, which Vito also supports).
if curl -fsSL "https://ppa.launchpadcontent.net/ondrej/php/ubuntu/dists/${V_DISTRO_CODENAME}/Release" -o /dev/null; then
export V_PHP_VERSION="8.4"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PHP 8.4 or 8.5?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Wrong comment. PHP 8.4 is the right one

@saeedvaziry saeedvaziry merged commit 829c726 into 4.x Jun 9, 2026
4 checks passed
@saeedvaziry saeedvaziry deleted the install-v4-and-upgrade-g2u5h branch June 9, 2026 06:11
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.

2 participants