|
507 | 507 | echo "$telemetry_trace" | $sudo_cmd tee /tmp/datadog-installer-trace.json > /dev/null
|
508 | 508 | }
|
509 | 509 |
|
510 |
| -function _install_installer() { |
511 |
| - local sudo_cmd="$1" |
512 |
| - local os="$2" |
513 |
| - local distribution="$3" |
514 |
| - |
515 |
| - local command_prefix |
516 |
| - |
517 |
| - if [ "$os" == "Debian" ]; then |
518 |
| - echo -e "\033[34m\n* Installing the Datadog installer\n\033[0m" |
519 |
| - $sudo_cmd apt-get install -o Acquire::Retries="5" -y --force-yes "datadog-installer" || return $? |
520 |
| - elif [ "$os" == "Red Hat" ]; then |
521 |
| - echo -e "\033[34m\n* Installing the Datadog installer\n\033[0m" |
522 |
| - $sudo_cmd yum -y --disablerepo='*' --enablerepo='datadog' install "datadog-installer" || $sudo_cmd yum -y install "datadog-installer" || return $? |
523 |
| - elif [ "$os" == "SUSE" ]; then |
524 |
| - echo -e "\033[34m\n* Installing the Datadog installer\n\033[0m" |
525 |
| - $sudo_cmd zypper --non-interactive --no-refresh install "datadog-installer" || return $? |
526 |
| - else |
527 |
| - return 0 |
528 |
| - fi |
529 |
| - command_prefix="${sudo_cmd:+$sudo_cmd -E}" |
530 |
| - $command_prefix sh -c "DD_API_KEY=\"${apikey}\" DD_SITE=\"${site}\" DATADOG_TRACE_ID=\"${DATADOG_TRACE_ID}\" DATADOG_PARENT_ID=\"${DATADOG_TRACE_ID}\" /usr/bin/datadog-bootstrap bootstrap" |
531 |
| - return $? |
532 |
| -} |
533 |
| - |
534 | 510 | function is_installed_by_installer() {
|
535 | 511 | local sudo_cmd="$1"
|
536 | 512 | local package="$2"
|
@@ -568,39 +544,6 @@ function filter_packages_installed_by_installer() {
|
568 | 544 | eval "$pkg_array_name=(\"\${not_installed_packages[@]}\")"
|
569 | 545 | }
|
570 | 546 |
|
571 |
| -# Install the Datadog installer package |
572 |
| -function install_installer() { |
573 |
| - local sudo_cmd="$1" |
574 |
| - local os="$2" |
575 |
| - local distribution="$3" |
576 |
| - local datadog_installer="$4" |
577 |
| - local remote_updates="$5" |
578 |
| - local apm_instrumentation_enabled="$6" |
579 |
| - local pkg_array_name="$7" |
580 |
| - |
581 |
| - local trace_id |
582 |
| - local start_time |
583 |
| - local exit_status |
584 |
| - |
585 |
| - # The installer is currently only being rolled out to APM instrumentation users |
586 |
| - if [ -z "$apm_instrumentation_enabled" ] && [ -z "$datadog_installer" ] && [ -z "$remote_updates" ]; then |
587 |
| - return 0 |
588 |
| - fi |
589 |
| - |
590 |
| - start_time=$(date +%s%N) |
591 |
| - |
592 |
| - (_install_installer "$sudo_cmd" "$os" "$distribution" > /tmp/datadog-installer-stdout.log 2> /tmp/datadog-installer-stderr.log) || exit_status=$? |
593 |
| - exit_status=${exit_status:-0} |
594 |
| - |
595 |
| - filter_packages_installed_by_installer "$sudo_cmd" "$pkg_array_name" |
596 |
| - |
597 |
| - if [ "$exit_status" -ne 0 ] && { [ -n "$datadog_installer" ] || [ -n "$remote_updates" ]; } then |
598 |
| - echo -e "\033[31m\n* Failed to install the Datadog installer\n\033[0m" |
599 |
| - exit "$exit_status" |
600 |
| - fi |
601 |
| - return "$exit_status" |
602 |
| -} |
603 |
| - |
604 | 547 | function remove_existing_packages_for_fips_flavor() {
|
605 | 548 | local sudo_cmd="$1"
|
606 | 549 | local os="$2"
|
@@ -640,37 +583,58 @@ function remove_existing_packages_for_fips_flavor() {
|
640 | 583 | return "$exit_status"
|
641 | 584 | }
|
642 | 585 |
|
643 |
| -# install_managed_agent installs the agent with Fleet Automation's agent management (preview feature). |
644 |
| -function install_managed_agent() { |
645 |
| - echo "Installing the Datadog Agent with Remote Agent Management" |
646 |
| - installer_domain=${DD_INSTALLER_REGISTRY_URL_INSTALLER_PACKAGE:-$([[ "$DD_SITE" == "datad0g.com" ]] && echo "install.datad0g.com" || echo "install.datadoghq.com")} |
647 |
| - installer_url="https://${installer_domain}/scripts/install.sh" |
648 |
| - if [ -n "$DD_AGENT_MINOR_VERSION" ]; then |
649 |
| - installer_url="https://${installer_domain}/scripts/install-7.${DD_AGENT_MINOR_VERSION}.sh" |
650 |
| - fi |
| 586 | +function _install_installer_script() { |
| 587 | + local installer_url="$1" |
| 588 | + |
651 | 589 | if command -v curl >/dev/null; then
|
652 | 590 | http_code=$(curl -ILsf --retry 3 -w "%{http_code}" -o /dev/null "$installer_url" || true)
|
653 | 591 | if [ "$http_code" -ne "200" ]; then
|
654 | 592 | echo "Error: Unable to download the installer script from $installer_url. HTTP status code: $http_code"
|
655 |
| - exit 1 |
| 593 | + return 1 |
656 | 594 | fi
|
657 | 595 | if ! bash <(curl -L -s -f --retry 3 "$installer_url"); then
|
658 |
| - exit 1 |
| 596 | + return 1 |
659 | 597 | fi
|
660 | 598 | elif command -v wget >/dev/null; then
|
661 | 599 | http_code=$(wget -q --tries=3 --server-response --spider --tries=3 "$installer_url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -n1 | tr -d '\n')
|
662 | 600 | if [ "$http_code" -ne 200 ]; then
|
663 | 601 | echo "Error: Unable to download the installer script from $installer_url. HTTP status code: $http_code"
|
664 |
| - exit 1 |
| 602 | + return 1 |
665 | 603 | fi
|
666 | 604 | if ! bash <(wget -q --tries=3 -O - "$installer_url"); then
|
667 |
| - exit 1 |
| 605 | + return 1 |
668 | 606 | fi
|
669 | 607 | else
|
670 | 608 | echo "Error: Curl or wget is required to install the agent with Remote Agent Management."
|
671 |
| - exit 1 |
| 609 | + return 1 |
672 | 610 | fi
|
673 |
| - exit 0 |
| 611 | + return 0 |
| 612 | +} |
| 613 | + |
| 614 | +# install_managed_agent installs the agent with Fleet Automation's agent management (preview feature). |
| 615 | +function install_managed_agent() { |
| 616 | + echo "Installing the Datadog Agent with Remote Agent Management" |
| 617 | + installer_domain=${DD_INSTALLER_REGISTRY_URL_INSTALLER_PACKAGE:-$([[ "$DD_SITE" == "datad0g.com" ]] && echo "install.datad0g.com" || echo "install.datadoghq.com")} |
| 618 | + installer_url="https://${installer_domain}/scripts/install.sh" |
| 619 | + if [ -n "$DD_AGENT_MINOR_VERSION" ]; then |
| 620 | + installer_url="https://${installer_domain}/scripts/install-7.${DD_AGENT_MINOR_VERSION}.sh" |
| 621 | + fi |
| 622 | + |
| 623 | + _install_installer_script "$installer_url" |
| 624 | + exit $? |
| 625 | +} |
| 626 | + |
| 627 | +# install_apm_ssi installs APM Single Step Instrumentation. |
| 628 | +function install_apm_ssi() { |
| 629 | + local sudo_cmd="$1" |
| 630 | + local pkg_array_name="$2" |
| 631 | + |
| 632 | + installer_domain=${DD_INSTALLER_REGISTRY_URL_INSTALLER_PACKAGE:-$([[ "$DD_SITE" == "datad0g.com" ]] && echo "install.datad0g.com" || echo "install.datadoghq.com")} |
| 633 | + installer_url="https://${installer_domain}/scripts/install-ssi.sh" # TODO: support pinning? |
| 634 | + |
| 635 | + _install_installer_script "$installer_url" |
| 636 | + |
| 637 | + filter_packages_installed_by_installer "$sudo_cmd" "$pkg_array_name" |
674 | 638 | }
|
675 | 639 |
|
676 | 640 | ##
|
@@ -762,22 +726,6 @@ if [ -n "$DD_AGENT_FLAVOR" ]; then
|
762 | 726 | agent_flavor=$DD_AGENT_FLAVOR #Eg: datadog-iot-agent
|
763 | 727 | fi
|
764 | 728 |
|
765 |
| -datadog_installer= |
766 |
| -if [ -n "$DD_INSTALLER" ]; then |
767 |
| - datadog_installer=true |
768 |
| -fi |
769 |
| - |
770 |
| - |
771 |
| -installer_registry_url= |
772 |
| -if [ -n "$DD_INSTALLER_REGISTRY_URL" ]; then |
773 |
| - installer_registry_url=$DD_INSTALLER_REGISTRY_URL |
774 |
| -fi |
775 |
| - |
776 |
| -installer_registry_auth= |
777 |
| -if [ -n "$DD_INSTALLER_REGISTRY_AUTH" ]; then |
778 |
| - installer_registry_auth=$DD_INSTALLER_REGISTRY_AUTH |
779 |
| -fi |
780 |
| - |
781 | 729 | ##
|
782 | 730 | # INSTALL SCRIPT CONFIGURATION OPTIONS
|
783 | 731 | # Technical options to test with non-production values for signature keys, packages or reporting telemetry.
|
@@ -869,10 +817,6 @@ if [ -n "$fips_mode" ]; then
|
869 | 817 | services+=("datadog-fips-proxy")
|
870 | 818 | fi
|
871 | 819 |
|
872 |
| -if [ -n "$remote_updates" ]; then |
873 |
| - services+=("datadog-installer") |
874 |
| -fi |
875 |
| - |
876 | 820 | # Track running services to avoid stopping them if they were already running
|
877 | 821 | if [[ $($sudo_cmd ps --no-headers -o comm 1 2>&1) == "systemd" ]] && command -v systemctl 2>&1; then
|
878 | 822 | # Check with services are already running
|
@@ -1175,7 +1119,7 @@ if [ "$OS" == "Red Hat" ]; then
|
1175 | 1119 |
|
1176 | 1120 | # Install the installer
|
1177 | 1121 | # Note: this function will remove installed packages from the "packages" array
|
1178 |
| - install_installer "$sudo_cmd" "$OS" "$DISTRIBUTION" "$DD_INSTALLER" "$DD_REMOTE_UPDATES" "$DD_APM_INSTRUMENTATION_ENABLED" "packages" || true |
| 1122 | + install_apm_ssi "$sudo_cmd" "packages" || true |
1179 | 1123 |
|
1180 | 1124 | if [ "$agent_flavor" == "datadog-fips-agent" ]; then
|
1181 | 1125 | remove_existing_packages_for_fips_flavor "$sudo_cmd" "$OS"
|
@@ -1322,7 +1266,7 @@ If the cause is unclear, please contact Datadog support.
|
1322 | 1266 |
|
1323 | 1267 | # Install the installer
|
1324 | 1268 | # Note: this function will remove installed packages from the "packages" array
|
1325 |
| - install_installer "$sudo_cmd" "$OS" "$DISTRIBUTION" "$DD_INSTALLER" "$DD_REMOTE_UPDATES" "$DD_APM_INSTRUMENTATION_ENABLED" "packages" || true |
| 1269 | + install_apm_ssi "$sudo_cmd" "packages" || true |
1326 | 1270 |
|
1327 | 1271 | if [ "$agent_flavor" == "datadog-fips-agent" ]; then
|
1328 | 1272 | remove_existing_packages_for_fips_flavor "$sudo_cmd" "$OS"
|
@@ -1476,7 +1420,7 @@ elif [ "$OS" == "SUSE" ]; then
|
1476 | 1420 |
|
1477 | 1421 | # Install the installer
|
1478 | 1422 | # Note: this function will remove installed packages from the "packages" array
|
1479 |
| - install_installer "$sudo_cmd" "$OS" "$DISTRIBUTION" "$DD_INSTALLER" "$DD_REMOTE_UPDATES" "$DD_APM_INSTRUMENTATION_ENABLED" "packages" || true |
| 1423 | + install_apm_ssi "$sudo_cmd" "packages" || true |
1480 | 1424 |
|
1481 | 1425 | if [ "$agent_flavor" == "datadog-fips-agent" ]; then
|
1482 | 1426 | remove_existing_packages_for_fips_flavor "$sudo_cmd" "$OS"
|
@@ -1617,20 +1561,6 @@ function update_env(){
|
1617 | 1561 | $sudo_cmd sh -c "sed -i 's|^# env:.*|env: $dd_env|' $config_file"
|
1618 | 1562 | fi
|
1619 | 1563 | }
|
1620 |
| -function update_installer_registry(){ |
1621 |
| - local sudo_cmd="$1" |
1622 |
| - local registry_url="$2" |
1623 |
| - local registry_auth="$3" |
1624 |
| - local config_file="$4" |
1625 |
| - if [ -n "$registry_url" ] || [ -n "$registry_auth" ]; then |
1626 |
| - printf "\033[34m\n* Adding your DD_INSTALLER_REGISTRY_URL and DD_INSTALLER_REGISTRY_AUTH to the $nice_flavor configuration: $config_file\n\033[0m\n" |
1627 |
| - if ! $sudo_cmd grep -q "^installer:" "$config_file"; then |
1628 |
| - $sudo_cmd sh -c "echo 'installer: {registry: {url: \"$registry_url\", auth: \"$registry_auth\" }}' >> $config_file" |
1629 |
| - else |
1630 |
| - printf "\033[31mInstaller configuration already exists in $config_file, skipping the update.\033[0m\n" |
1631 |
| - fi |
1632 |
| - fi |
1633 |
| -} |
1634 | 1564 | function update_security_and_or_compliance(){
|
1635 | 1565 | local sudo_cmd="$1"
|
1636 | 1566 | local local_config_file="$2"
|
@@ -1768,8 +1698,6 @@ if [ -e "$(dirname $dd_environment_file)" ]; then
|
1768 | 1698 | fi
|
1769 | 1699 | manage_error_tracking_standalone_config "$sudo_cmd" "$environment_file"
|
1770 | 1700 |
|
1771 |
| -update_installer_registry "$sudo_cmd" "$installer_registry_url" "$installer_registry_auth" "$config_file" |
1772 |
| - |
1773 | 1701 | if [ ! "$no_agent" ]; then
|
1774 | 1702 | $sudo_cmd chown dd-agent:dd-agent "$config_file"
|
1775 | 1703 | $sudo_cmd chmod 640 "$config_file"
|
|
0 commit comments