This script provides a convenient way to install or uninstall Elastic Agent on macOS systems. It automates the process of downloading, extracting, and setting up the Elastic Agent, as well as cleanly removing it when no longer needed.
2.0.0
Austin Songer
- Automated Installation: Downloads and installs Elastic Agent version
8.9.2
. - Easy Uninstallation: Removes Elastic Agent and associated files.
- Error Handling: Includes basic error handling for a smoother user experience.
- User Choice: Allows the user to choose between installation and uninstallation.
- macOS system
- Bash shell
- Internet connection for downloading the Elastic Agent
- Sufficient permissions to execute
sudo
commands
- Download the Script: Clone or download the script to your local system.
- Make the Script Executable: Run
chmod +x elastic-install.sh
to make the script executable. - Run the Script: Execute the script using
./elastic-install.sh
. - Choose an Option:
- Enter
1
to install the Elastic Agent. - Enter
2
to uninstall the Elastic Agent.
- Enter
- Follow the On-Screen Instructions: The script will guide you through the rest of the process.
The installation process involves the following steps:
- Downloading the Elastic Agent tarball from the specified URL.
- Extracting the downloaded tarball.
- Installing the Elastic Agent using the provided URL and enrollment token.
The uninstallation process involves:
- Stopping the Elastic Agent service using
launchctl
. - Removing the Elastic Agent's launch daemon file.
- Deleting the Elastic Agent installation directory.
- Ensure that you have the necessary permissions to run the script and perform installation or uninstallation tasks.
- Always verify the current Elastic Agent version and update the script if necessary.
- It is advisable to backup important data before running the uninstallation process.
This script is provided as-is with no warranties. Users should use it at their own risk. Always test scripts in a controlled environment before deploying them in a production setting.