-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add linux install script for manual installation support
- Loading branch information
1 parent
cdb91d8
commit 48bafce
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
observeagent_install_dir="/etc/observe-agent" | ||
tmp_dir="/tmp/observe-agent" | ||
|
||
if [ -z "$ZIP_DIR" ]; then | ||
# Download the file from the latest release when there is no zip provided | ||
echo "Downloading latest release from GitHub" | ||
curl -L -o /tmp/observe-agent.tar.gz https://github.com/observeinc/observe-agent/releases/latest/download/observe-agent_Linux_$(arch).tar.gz | ||
ZIP_DIR="/tmp/observe-agent.tar.gz" | ||
else | ||
echo "Installing from provided zip file: $ZIP_DIR" | ||
fi | ||
|
||
# Set up the temp dir and extract files. | ||
rm -rf $tmp_dir | ||
mkdir -p $tmp_dir | ||
tar -xzf $ZIP_DIR -C $tmp_dir | ||
|
||
# If the observe-agent.yaml file already exists, leave it alone. | ||
# Otherwise we need to know what the collection endpoint and token are. | ||
if [ ! -f "$observeagent_install_dir/observe-agent.yaml" ]; then | ||
if [ -z "$OBSERVE_URL" ]; then | ||
echo "OBSERVE_URL env var is not set" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$TOKEN" ]; then | ||
echo "TOKEN env var is not set" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Create the needed directories | ||
echo "Creating system install folders. This may ask for your password..." | ||
sudo mkdir -p $observeagent_install_dir /var/lib/observe-agent/filestorage | ||
sudo chmod +rw /var/lib/observe-agent/filestorage | ||
|
||
# Copy all files to the install dir. | ||
sudo cp -f $tmp_dir/observe-agent /usr/bin/observe-agent | ||
sudo cp -f $tmp_dir/otel-collector.yaml $observeagent_install_dir/otel-collector.yaml | ||
sudo rm -rf $observeagent_install_dir/connections | ||
sudo cp -fR $tmp_dir/connections $observeagent_install_dir/connections | ||
sudo chown -R root:root $observeagent_install_dir | ||
|
||
# Initialize the agent config file if it doesn't exist | ||
if [ -f "$observeagent_install_dir/observe-agent.yaml" ]; then | ||
echo "Leaving existing observe-agent.yaml in place." | ||
else | ||
echo "Initializing observe-agent.yaml" | ||
sudo /usr/bin/observe-agent init-config --token $TOKEN --observe_url $OBSERVE_URL --config_path $observeagent_install_dir/observe-agent.yaml | ||
sudo chown root:root $observeagent_install_dir/observe-agent.yaml | ||
fi | ||
|
||
echo "Observe agent successfully installed to $observeagent_install_dir" |