Skip to content

Commit

Permalink
(fleet) small optmisation to the installer script (DataDog#31953)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbll authored Dec 10, 2024
1 parent fdbee01 commit 6778936
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions pkg/fleet/installer/setup/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ install() {
$sudo_cmd mkdir -p "${tmp_dir}"
case "$(uname -m)" in
x86_64)
echo "${downloader_bin_linux_amd64}" | base64 -d | $sudo_cmd tee "${downloader_path}" >/dev/null
write_installer_amd64 "$sudo_cmd" "$downloader_path"
;;
aarch64)
echo "${downloader_bin_linux_arm64}" | base64 -d | $sudo_cmd tee "${downloader_path}" >/dev/null
write_installer_arm64 "$sudo_cmd" "$downloader_path"
;;
esac
$sudo_cmd chmod +x "${downloader_path}"
Expand All @@ -37,16 +37,16 @@ install() {
# Embedded binaries used to install Datadog.
# Source: https://github.com/DataDog/datadog-agent/tree/INSTALLER_COMMIT/pkg/fleet/installer
# DO NOT EDIT THIS SECTION MANUALLY.
downloader_bin_linux_amd64=$(
cat <<EOM
DOWNLOADER_BIN_LINUX_AMD64
EOM
)
downloader_bin_linux_arm64=$(
cat <<EOM
DOWNLOADER_BIN_LINUX_ARM64
EOM
)
write_installer_amd64() {
local sudo_cmd=$1
local path=$2
base64 -d <<<"DOWNLOADER_BIN_LINUX_AMD64" | $sudo_cmd tee "${path}" >/dev/null
}
write_installer_arm64() {
local sudo_cmd=$1
local path=$2
base64 -d <<<"DOWNLOADER_BIN_LINUX_ARM64" | $sudo_cmd tee "${path}" >/dev/null
}

install "$@"
exit 0
2 changes: 1 addition & 1 deletion tasks/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def build_linux_script(
build_downloader(ctx, flavor=flavor, version=version, os='linux', arch=arch)
with open(DOWNLOADER_BIN, 'rb') as f:
encoded_bin = base64.encodebytes(f.read()).decode('utf-8')
install_script = install_script.replace(f'DOWNLOADER_BIN_{arch.upper()}', encoded_bin)
install_script = install_script.replace(f'DOWNLOADER_BIN_LINUX_{arch.upper()}', encoded_bin)

commit_sha = ctx.run('git rev-parse HEAD', hide=True).stdout.strip()
install_script = install_script.replace('INSTALLER_COMMIT', commit_sha)
Expand Down

0 comments on commit 6778936

Please sign in to comment.