Skip to content

Commit

Permalink
feat: add linux install script for manual installation support
Browse files Browse the repository at this point in the history
  • Loading branch information
obs-gh-mattcotter committed Dec 3, 2024
1 parent cdb91d8 commit 48bafce
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions scripts/install_linux.sh
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"

0 comments on commit 48bafce

Please sign in to comment.