Skip to content

Commit

Permalink
chore(install-script): show upgrade instructions
Browse files Browse the repository at this point in the history
* (Linux-only) Prevents installing over an existing package
installation. Shows a message with instructions on how to upgrade.

* (Linux-only) Adds the package name to the upgrade commands.

Signed-off-by: Justin Kolberg <[email protected]>
  • Loading branch information
amdprophet committed Nov 8, 2024
1 parent a1dc9c0 commit 063db05
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions install-script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,12 @@ function upgrade() {
function upgrade_linux() {
case $(get_package_manager) in
yum | dnf)
yum update --quiet -y
yum update otelcol-sumo --quiet -y
;;
apt-get)
apt-get update --quiet && apt-get upgrade --quiet -y
apt-get update --quiet && apt-get upgrade otelcol-sumo --quiet -y
;;
esac

}

# uninstall otelcol-sumo on darwin
Expand Down Expand Up @@ -880,6 +879,19 @@ function install_linux_package() {
esac
}

function show_upgrade_instructions() {
echo -n "Upgrades can be performed using the native package manager: "

case $(get_package_manager) in
yum | dnf)
echo "yum update otelcol-sumo -y"
;;
apt-get)
echo "apt-get update && apt-get upgrade otelcol-sumo -y"
;;
esac
}

function check_deprecated_linux_flags() {
if [[ -n "${BINARY_BRANCH}" ]]; then
echo "warning: --binary-branch is deprecated"
Expand All @@ -895,7 +907,8 @@ function check_deprecated_linux_flags() {
fi

if [[ -n "${DOWNLOAD_ONLY}" ]]; then
echo "--download-only is only supported on darwin, use 'install.sh --upgrade' to upgrade otelcol-sumo"
echo "--download-only is only supported on darwin"
show_upgrade_instructions
exit 1
fi
}
Expand Down Expand Up @@ -1180,6 +1193,12 @@ if has_prepackaging_installation; then
HAD_PREPACKAGING_INSTALLATION="true"
fi

if is_package_installed; then
echo "The otelcol-sumo package is already installed"
show_upgrade_instructions
exit 1
fi

install_linux_package "${package_name}"
verify_installation
setup_config
Expand Down

0 comments on commit 063db05

Please sign in to comment.