Skip to content

feat: update reset_payram_environment steps for updater removal process#34

Open
aryaman-payram wants to merge 3 commits intomainfrom
hotfix/resetUpdater
Open

feat: update reset_payram_environment steps for updater removal process#34
aryaman-payram wants to merge 3 commits intomainfrom
hotfix/resetUpdater

Conversation

@aryaman-payram
Copy link
Copy Markdown
Contributor

No description provided.

@aryaman-payram aryaman-payram requested review from BuddhaSource and iam-joey and removed request for iam-joey April 1, 2026 17:04
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cdcb6918-fd27-4597-8b8b-4d399205312d

📥 Commits

Reviewing files that changed from the base of the PR and between d40c6e8 and 81738d7.

📒 Files selected for processing (1)
  • setup_payram.sh
✅ Files skipped from review due to trivial changes (1)
  • setup_payram.sh

Summary by CodeRabbit

  • Bug Fixes
    • More reliable environment reset that better removes the updater service, with a fallback cleanup when automated removal fails.
    • Reordered cleanup so updater removal and certificate/cron cleanup complete before application data deletion.
    • Improved verification and reporting when leftover artifacts remain after reset.

Walkthrough

The PayRam reset function was expanded from six to seven steps. A new Step 6 removes the PayRam Updater (remote uninstall script or manual fallback), and PayRam data directory deletion was moved to the final Step 7 after certificate and cron cleanup.

Changes

Cohort / File(s) Summary
PayRam Reset Sequence Update
setup_payram.sh
Introduced Step 6/7 to remove the PayRam Updater: attempts to download/run setup_payram_updater.sh --uninstall --yes --remove-backups from GitHub; on failure performs manual cleanup (detect updater artifacts, stop/disable via systemctl or launchctl, delete updater binaries, service/unit/plist, data/backups, configs), verifies leftovers. Updated step count references 6→7 and moved PayRam data directory removal to Step 7 after updater, cert, and cron cleanup.

Sequence Diagram(s)

sequenceDiagram
    participant Script as setup_payram.sh
    participant GitHub as GitHub/raw
    participant OS as System (systemd / launchd)
    participant FS as Filesystem

    Script->>Script: start reset_payram_environment()
    Script->>Script: run Steps 1–5 (existing cleanup)
    Script->>GitHub: download & run setup_payram_updater.sh (--uninstall --yes --remove-backups)
    alt remote uninstall succeeds
        GitHub-->>Script: script runs and removes updater artifacts
        Script->>OS: ensure service stopped/disabled
        Script->>FS: updater files & backups removed
    else remote uninstall fails
        Script->>OS: detect and stop/disable updater (systemctl or launchctl)
        Script->>FS: delete updater binary, unit/plist, data/backups, configs
        Script->>FS: verify remaining updater artifacts
    end
    Script->>FS: Step 7 — remove PayRam data directory
    Script->>Script: finish reset
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Seven steps now guard the PayRam way,
The updater bows and hops away,
Services quiet, files take flight,
Backups vanish out of sight,
Reset done — a carrot cheer tonight! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether any description content relates to the changeset. Add a pull request description explaining the purpose of the updater removal changes, any context or reasons for the update, and how the new step improves the reset process.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change—adding steps to the reset_payram_environment function for updater removal, which aligns with the AI-generated summary showing a new Step 6/7 for PayRam Updater removal.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 hotfix/resetUpdater

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@setup_payram.sh`:
- Around line 2411-2435: The cleanup conditional currently only checks for
/usr/local/bin/payram-updater and sets updater_removed, so leftover artifacts
like /usr/local/bin/payram-updater-launcher, /etc/payram/updater.env,
/Library/LaunchDaemons/com.payram.updater.plist,
/etc/systemd/system/payram-updater.service, /var/lib/payram(-updater) or backups
can be missed; modify the logic around updater_removed and the initial if-block
to detect any known updater artifacts (check existence of
/usr/local/bin/payram-updater, /usr/local/bin/payram-updater-launcher,
/Library/LaunchDaemons/com.payram.updater.plist,
/etc/systemd/system/payram-updater.service, /var/lib/payram*,
/var/lib/payram/backups, /etc/payram/updater.env) and enter the removal sequence
if any exist, and only print the yellow "not found" message when none of those
paths exist; ensure the same removal commands (service stop/unload, rm -f, rm
-rf, rmdir) run when any artifact is present and set updater_removed=true when
any removal was attempted.
- Around line 2406-2407: The curl pipeline invoking the external updater
uninstall (variable updater_uninstall_url and the line starting with "if curl
-fsSL") needs connection and overall time bounds to avoid hanging; update that
curl invocation to include the same flags used elsewhere (--connect-timeout 10
--max-time 60) so the command becomes curl -fsSL --connect-timeout 10 --max-time
60 "$updater_uninstall_url" 2>/dev/null | bash -s -- --uninstall --yes
--remove-backups 2>/dev/null, preserving the existing redirects and behavior.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54f175d2-683d-4d16-9ac8-fae1219ce92c

📥 Commits

Reviewing files that changed from the base of the PR and between e4310c8 and 0b74909.

📒 Files selected for processing (1)
  • setup_payram.sh

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
setup_payram.sh (2)

2429-2431: macOS launchctl unload is deprecated but acceptable for compatibility.

launchctl unload is deprecated on macOS 10.10+ in favor of launchctl bootout, but it still functions. The || true ensures the script continues gracefully. For broad macOS version compatibility, this approach is acceptable.

♻️ Optional: Use modern launchctl syntax on newer macOS
       elif [[ -f /Library/LaunchDaemons/com.payram.updater.plist ]]; then
-        launchctl unload /Library/LaunchDaemons/com.payram.updater.plist 2>/dev/null || true
+        # bootout is preferred on macOS 10.10+; unload is deprecated but still works
+        launchctl bootout system /Library/LaunchDaemons/com.payram.updater.plist 2>/dev/null \
+          || launchctl unload /Library/LaunchDaemons/com.payram.updater.plist 2>/dev/null \
+          || true
         rm -f /Library/LaunchDaemons/com.payram.updater.plist 2>/dev/null || true
       fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@setup_payram.sh` around lines 2429 - 2431, Replace the deprecated "launchctl
unload /Library/LaunchDaemons/com.payram.updater.plist 2>/dev/null || true" with
logic that prefers the modern "launchctl bootout" when supported: detect whether
"launchctl bootout" is available (or check macOS version), call "launchctl
bootout system /Library/LaunchDaemons/com.payram.updater.plist" when supported,
otherwise fall back to "launchctl unload
/Library/LaunchDaemons/com.payram.updater.plist"; keep the same error
suppression "2>/dev/null || true" and the following "rm -f
/Library/LaunchDaemons/com.payram.updater.plist 2>/dev/null || true" unchanged.

2407-2407: Consider logging curl errors for easier debugging.

The timeouts have been correctly added. However, redirecting stderr to /dev/null hides network errors that could help diagnose why the remote uninstall script failed. Consider logging to $LOG_FILE for better debugging while still keeping the fallback behavior.

♻️ Optional: Log errors instead of discarding
-  if curl -fsSL --connect-timeout 10 --max-time 60 "$updater_uninstall_url" 2>/dev/null | bash -s -- --uninstall --yes --remove-backups 2>/dev/null; then
+  if curl -fsSL --connect-timeout 10 --max-time 60 "$updater_uninstall_url" 2>>"$LOG_FILE" | bash -s -- --uninstall --yes --remove-backups 2>>"$LOG_FILE"; then
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@setup_payram.sh` at line 2407, Replace the stderr redirections that discard
errors with redirections that append errors to the log file so network/script
errors are preserved; specifically, change the curl call that uses
updater_uninstall_url from "curl -fsSL --connect-timeout 10 --max-time 60
\"$updater_uninstall_url\" 2>/dev/null | bash -s -- --uninstall --yes
--remove-backups 2>/dev/null" to redirect curl stderr and the piped bash stderr
to "$LOG_FILE" (e.g., curl ... 2>>"$LOG_FILE" | bash -s -- --uninstall --yes
--remove-backups 2>>"$LOG_FILE"), ensuring LOG_FILE is defined and used
consistently so errors are logged while keeping the same success/failure
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@setup_payram.sh`:
- Around line 2429-2431: Replace the deprecated "launchctl unload
/Library/LaunchDaemons/com.payram.updater.plist 2>/dev/null || true" with logic
that prefers the modern "launchctl bootout" when supported: detect whether
"launchctl bootout" is available (or check macOS version), call "launchctl
bootout system /Library/LaunchDaemons/com.payram.updater.plist" when supported,
otherwise fall back to "launchctl unload
/Library/LaunchDaemons/com.payram.updater.plist"; keep the same error
suppression "2>/dev/null || true" and the following "rm -f
/Library/LaunchDaemons/com.payram.updater.plist 2>/dev/null || true" unchanged.
- Line 2407: Replace the stderr redirections that discard errors with
redirections that append errors to the log file so network/script errors are
preserved; specifically, change the curl call that uses updater_uninstall_url
from "curl -fsSL --connect-timeout 10 --max-time 60 \"$updater_uninstall_url\"
2>/dev/null | bash -s -- --uninstall --yes --remove-backups 2>/dev/null" to
redirect curl stderr and the piped bash stderr to "$LOG_FILE" (e.g., curl ...
2>>"$LOG_FILE" | bash -s -- --uninstall --yes --remove-backups 2>>"$LOG_FILE"),
ensuring LOG_FILE is defined and used consistently so errors are logged while
keeping the same success/failure behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6c9e5173-bb2f-49bf-a94b-499931dc2cf4

📥 Commits

Reviewing files that changed from the base of the PR and between 0b74909 and d40c6e8.

📒 Files selected for processing (1)
  • setup_payram.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants