Skip to content

fix: clean up downloaded helper scripts after install#46

Merged
mrrobot47 merged 1 commit into
masterfrom
fix/cleanup-downloaded-scripts
Jun 20, 2026
Merged

fix: clean up downloaded helper scripts after install#46
mrrobot47 merged 1 commit into
masterfrom
fix/cleanup-downloaded-scripts

Conversation

@mrrobot47

Copy link
Copy Markdown
Member

Closes #15.

After a successful install the installer left two downloaded helper scripts on disk. This cleans both up.

ee installer script

The canonical install (wget -qO ee https://rt.cx/ee4 && sudo bash ee) leaves the ee file in the user's working directory. setup.sh now removes itself once the install succeeds.

Guards:

  • Self-deletes only when executed directlyBASH_SOURCE[0] equals $0 when the script is run with bash ee, differs when it is sourced (e.g. remote-migrate sources the installer over SSH), and is empty when piped (curl ... | bash). So sourced and piped runs delete nothing. Using BASH_SOURCE[0] instead of $0 also avoids the pipe case wrongly matching a file literally named bash in the current directory.
  • Absolute path resolved at capture time, so a later cd can't leave it behind.
  • Opt-out via EE_KEEP_INSTALLER=1 (useful when running a checkout in place).
  • Runs only on the success path; on failure set -e exits earlier and the file is left for a retry.

docker-setup.sh

setup_docker() downloaded get.docker.com to docker-setup.sh in the current directory and never removed it. It now downloads into TMP_WORK_DIR, so the existing EXIT trap in setup.sh cleans it up on every exit path — including download/install failures.

Testing

Verified in an ubuntu:24.04 container (bash 5.2.21):

  • bash ee → removes itself; curl | bash → removes nothing (even with a bash file in CWD); sourced run → file kept; EE_KEEP_INSTALLER=1 → kept; cd before delete → still removes the right file.
  • Docker helper cleaned up on both success and simulated failure paths; no docker-setup.sh left in CWD.

The installer left two helper scripts on disk after a successful run: the
downloaded `ee` script (from `wget -qO ee https://rt.cx/ee4 && bash ee`)
and `docker-setup.sh` fetched during Docker installation.

setup.sh now removes itself on success. It self-deletes only when executed
directly (BASH_SOURCE[0] == $0), so a sourced run (e.g. remote-migrate) or a
piped `curl ... | bash` removes nothing; the path is resolved to an absolute
form so a later chdir can't strand it, and EE_KEEP_INSTALLER=1 opts out.

setup_docker downloads the Docker helper into TMP_WORK_DIR so the existing
EXIT trap removes it on every exit path, including failures.

Closes #15
@mrrobot47 mrrobot47 requested a review from Copilot June 20, 2026 16:45
@mrrobot47 mrrobot47 merged commit 6110499 into master Jun 20, 2026
2 checks passed
@mrrobot47 mrrobot47 deleted the fix/cleanup-downloaded-scripts branch June 20, 2026 16:48

Copilot AI 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.

Pull request overview

This PR addresses issue #15 by ensuring the installer no longer leaves behind downloaded helper scripts after installation completes successfully.

Changes:

  • Add “self-delete on success” behavior to setup.sh when executed directly (with opt-out via EE_KEEP_INSTALLER=1 and safeguards for sourced/piped execution).
  • Download the Docker install helper into TMP_WORK_DIR so it is cleaned up automatically by the existing EXIT trap.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
setup.sh Captures the installer’s absolute path (when executed directly) and removes it after a successful install.
functions Downloads the Docker installer script into TMP_WORK_DIR instead of the current working directory to ensure cleanup via the existing trap.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread functions
sh docker-setup.sh
# Download into TMP_WORK_DIR so setup.sh's EXIT trap cleans it up on any
# exit path, instead of leaving docker-setup.sh behind in the CWD.
wget --quiet get.docker.com -O "$TMP_WORK_DIR/docker-setup"
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.

Installer script should cleanup itself

2 participants