Skip to content

Commit

Permalink
Merge pull request #83 from SumoLogic/chore/install-script/drop-worka…
Browse files Browse the repository at this point in the history
…rounds

chore(install.sh): drop workarounds for old collector versions
  • Loading branch information
swiatekm authored May 27, 2024
2 parents 54af053 + 3c392dc commit 2a146ee
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions install-script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1249,11 +1249,7 @@ function write_installation_token_env() {
readonly file="${2}"

local token_name
if (( MAJOR_VERSION == 0 && MINOR_VERSION <= 71 )); then
token_name="${DEPRECATED_ENV_TOKEN}"
else
token_name="${ENV_TOKEN}"
fi
token_name="${ENV_TOKEN}"
readonly token_name

# ToDo: ensure we override only ${ENV_TOKEN}" env value
Expand Down Expand Up @@ -1888,11 +1884,7 @@ if [[ "${OS_TYPE}" == "darwin" ]]; then
VERSION="$(get_latest_package_version "${VERSIONS}")"
fi

VERSION_PREFIX="${VERSION%.*}" # cut off the suffix starting with the last stop
MAJOR_VERSION="${VERSION_PREFIX%.*}" # take the prefix from before the first stop
MINOR_VERSION="${VERSION_PREFIX#*.}" # take the suffix after the first stop

readonly VERSIONS VERSION INSTALLED_VERSION VERSION_PREFIX MAJOR_VERSION MINOR_VERSION
readonly VERSIONS VERSION

echo -e "Version to install:\t${VERSION}"

Expand Down Expand Up @@ -2001,23 +1993,9 @@ if [[ -z "${VERSION}" ]]; then
VERSION="$(get_latest_version "${VERSIONS}")"
fi

VERSION_PREFIX="${VERSION%.*}" # cut off the suffix starting with the last stop
MAJOR_VERSION="${VERSION_PREFIX%.*}" # take the prefix from before the first stop
MINOR_VERSION="${VERSION_PREFIX#*.}" # take the suffix after the first stop


readonly VERSIONS VERSION INSTALLED_VERSION VERSION_PREFIX MAJOR_VERSION MINOR_VERSION

echo -e "Version to install:\t${VERSION}"

if [[ -z "${CONFIG_BRANCH}" ]]; then
# Remove glob for versions up to 0.57
if (( MAJOR_VERSION == 0 && MINOR_VERSION <= 57 )); then
CONFIG_BRANCH="9e06ada346b5e7fb3df582f28e582e07730899de"
else
CONFIG_BRANCH="v${VERSION}"
fi
fi
CONFIG_BRANCH="v${VERSION}"
readonly CONFIG_BRANCH BINARY_BRANCH

# Check if otelcol is already in newest version
Expand Down Expand Up @@ -2076,13 +2054,7 @@ if [[ "${SYSTEMD_DISABLED}" == "true" ]]; then
if [[ "${REMOTELY_MANAGED}" == "true" ]]; then
COMMAND_FLAGS="--remote-config \"opamp:${CONFIG_PATH}\""
else
COMMAND_FLAGS="--config=${CONFIG_PATH}"
# Add glob for versions above 0.57
if (( MAJOR_VERSION >= 0 && MINOR_VERSION > 57 )); then
COMMAND_FLAGS="${COMMAND_FLAGS} --config \"glob:${CONFIG_DIRECTORY}/conf.d/*.yaml\""
else
COMMAND_FLAGS="${COMMAND_FLAGS} --config ${COMMON_CONFIG_PATH}"
fi
COMMAND_FLAGS="--config=${CONFIG_PATH} --config \"glob:${CONFIG_DIRECTORY}/conf.d/*.yaml\""
fi

echo ""
Expand Down Expand Up @@ -2137,11 +2109,6 @@ curl --retry 5 --connect-timeout 5 --max-time 30 --retry-delay 0 --retry-max-tim
sed -i.bak -e "s%/etc/otelcol-sumo%${CONFIG_DIRECTORY}%" "${TMP_SYSTEMD_CONFIG}"
sed -i.bak -e "s%/etc/otelcol-sumo/env%${USER_ENV_DIRECTORY}%" "${TMP_SYSTEMD_CONFIG}"

# Remove glob for versions up to 0.57
if (( MAJOR_VERSION == 0 && MINOR_VERSION <= 57 )); then
sed -i.bak -e "s% --config \"glob.*\"% --config ${COMMON_CONFIG_PATH}%" "${TMP_SYSTEMD_CONFIG}"
fi

if [[ "${REMOTELY_MANAGED}" == "true" ]]; then
sed -i.bak -e "s% --config.*$% --remote-config \"opamp:${CONFIG_PATH}\"%" "${TMP_SYSTEMD_CONFIG}"
fi
Expand Down

0 comments on commit 2a146ee

Please sign in to comment.