Uninstaller Script Breakdown
Relevant source files
The following files were used as context for generating this wiki page:
The uninstall.sh script is a utility designed to revert the changes made by the ollacc installer. Its primary responsibilities include removing shell aliases from various configuration files and providing an option to delete the application's configuration directory, which contains sensitive data such as the Ollama Cloud API key.
The script is designed to be safe for execution even if the project was installed via the one-liner method or direct repository cloning. It ensures that user environment files are cleaned up without leaving orphaned aliases or markers behind.
Sources: uninstall.sh:1-6, README.md:143-147
User and Environment Discovery
Before performing any cleanup operations, the script must identify the correct user and home directory to target. This is particularly important when the script is executed via sudo, as it must resolve the underlying user's environment rather than the root user's.
| Variable | Description | Source |
|---|---|---|
REAL_USER | The actual username, retrieved via $SUDO_USER or id -un. | uninstall.sh:11-16 |
REAL_HOME | The home directory of the REAL_USER, retrieved via getent or shell expansion. | uninstall.sh:11-16 |
INSTALL_DIR | The location of the ollacc configuration and binaries (~/.ollacc). | uninstall.sh:18 |
MARKER | The specific comment string used to identify ollacc blocks in shell RC files. | uninstall.sh:19 |
The following diagram illustrates the environment resolution and initial logic flow of the uninstaller:
Sources: uninstall.sh:10-21
Shell Alias Removal
The script targets specific shell configuration files to remove the ollacc alias. The installer typically adds a marker comment # ollacc: alias followed by the alias definition. The uninstaller uses awk to parse these files and remove the marker, the following alias line, and any preceding blank lines to maintain file tidiness.
Targeted RC Files
The script iterates through the following files in the user's home directory:
.zshrc.bashrc.bash_profile.profile
Sources: uninstall.sh:22-23, install.sh:65-71
Removal Logic
For each file found, the script performs an awk operation that creates a temporary file excluding the ollacc block. If the script is running as root (under sudo), it explicitly restores ownership of the modified RC files to the REAL_USER.
Sources: uninstall.sh:25-54
Configuration and Data Cleanup
After cleaning shell environment files, the script prompts the user to delete the application directory (~/.ollacc/). This directory contains:
- The
ollacclauncher binary. - The
configfile containing theANTHROPIC_AUTH_TOKEN. - The
lib/directory containing supporting scripts.
The user must explicitly confirm with y or Y to remove this directory. If they decline, the configuration remains, allowing for a re-installation without re-entering the API key.
Sources: uninstall.sh:57-73, install.sh:25-52
Configuration Key Management
While uninstall.sh handles full removal, the project also provides mechanisms via lib/flags.sh to clear specific parts of the configuration without a full uninstall.
| Command | Action | Source |
|---|---|---|
ollacc --model-clear | Removes OLLAMA_CLAUDE_DEFAULT_MODEL from config using config_unset. | lib/flags.sh:12-21 |
ollacc --key-clear | Removes ANTHROPIC_AUTH_TOKEN from config using config_unset. | lib/flags.sh:22-31 |
The config_unset function in lib/config.sh uses awk to safely remove lines matching a specific key while preserving comments and other settings.
Sources: lib/config.sh:71-83, lib/flags.sh:10-34
Summary and Verification
Upon completion, the script prints a summary of actions taken, specifically listing which shell configuration files were modified. It advises the user to reload their shell or open a new terminal for the alias removal to take effect.
Sources: uninstall.sh:75-83
The uninstaller provides a clean exit path for users, ensuring that the system state is returned to its original condition while respecting user data by offering a choice regarding the deletion of configuration files.
Sources: README.md:143-147, uninstall.sh:68-71