Skip to content

Commit

Permalink
fix user_data.sh for linux instances - retry command not found (#5373)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanschmidt authored Jun 26, 2024
1 parent 8c79032 commit 36b5f2c
Showing 1 changed file with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,38 @@ fi

sudo sh -c "curl https://raw.githubusercontent.com/kadwanev/retry/master/retry -o /usr/local/bin/retry && chmod +x /usr/local/bin/retry"

sudo retry "$PKG_MANAGER update -y"
sleep 3

sudo /usr/local/bin/retry "$PKG_MANAGER update -y"

if ! command -v jq 2>/dev/null; then
echo "Installing jq"
sudo retry "$PKG_MANAGER install -y jq"
sudo /usr/local/bin/retry "$PKG_MANAGER install -y jq"
fi
if ! command -v git 2>/dev/null; then
echo "Installing git"
sudo retry "$PKG_MANAGER install -y git"
sudo /usr/local/bin/retry "$PKG_MANAGER install -y git"
fi
if ! command -v pip3 2>/dev/null; then
echo "Installing git"
sudo retry "$PKG_MANAGER install -y pip"
sudo /usr/local/bin/retry "$PKG_MANAGER install -y pip"
fi

%{ if enable_cloudwatch_agent ~}
sudo retry "$PKG_MANAGER install amazon-cloudwatch-agent -y"
sudo /usr/local/bin/retry "$PKG_MANAGER install amazon-cloudwatch-agent -y"
amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c ssm:${ssm_key_cloudwatch_agent_config}
%{ endif ~}

# Install docker
if [ "$(uname -m)" == "aarch64" ]; then
sudo retry "$PKG_MANAGER install -y docker"
sudo /usr/local/bin/retry "$PKG_MANAGER install -y docker"
else
if command -v amazon-linux-extras 2>/dev/null; then
echo "Installing docker using amazon-linux-extras"
sudo retry "amazon-linux-extras install docker"
sudo /usr/local/bin/retry "amazon-linux-extras install docker"
else
echo "Installing docker using dnf"
sudo retry "dnf install docker -y"
sudo /usr/local/bin/retry "dnf install docker -y"
fi
fi

Expand All @@ -59,33 +61,33 @@ usermod -a -G docker ec2-user
USER_NAME=ec2-user
${install_config_runner}

sudo retry "$PKG_MANAGER groupinstall -y 'Development Tools'"
sudo retry "$PKG_MANAGER install -y 'kernel-devel-uname-r == $(uname -r)'"
sudo /usr/local/bin/retry "$PKG_MANAGER groupinstall -y 'Development Tools'"
sudo /usr/local/bin/retry "$PKG_MANAGER install -y 'kernel-devel-uname-r == $(uname -r)'"

echo Checking if nvidia install required ${nvidia_driver_install}
%{ if nvidia_driver_install ~}
echo "NVIDIA driver install required"
if [[ "$OS_ID" =~ ^amzn.* ]]; then
if [[ "$OS_ID" =~ "amzn2023" ]] ; then
echo "On Amazon Linux 2023, installing kernel-modules-extra"
sudo retry "dnf install kernel-modules-extra -y"
sudo /usr/local/bin/retry "dnf install kernel-modules-extra -y"
fi
echo Installing Development Tools
sudo modprobe backlight
fi
sudo retry "curl -fsL -o /tmp/nvidia_driver 'https://s3.amazonaws.com/ossci-linux/nvidia_driver/NVIDIA-Linux-x86_64-550.54.15.run'"
sudo retry "/bin/bash /tmp/nvidia_driver -s --no-drm"
sudo /usr/local/bin/retry "curl -fsL -o /tmp/nvidia_driver 'https://s3.amazonaws.com/ossci-linux/nvidia_driver/NVIDIA-Linux-x86_64-550.54.15.run'"
sudo /usr/local/bin/retry "/bin/bash /tmp/nvidia_driver -s --no-drm"
sudo rm -fv /tmp/nvidia_driver
if [[ "$OS_ID" =~ ^amzn.* ]]; then
if [[ "$OS_ID" == ^amzn2023* ]]; then
sudo retry "dnf install -y dnf-plugins-core"
sudo retry "dnf config-manager --add-repo 'https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo'"
sudo /usr/local/bin/retry "dnf install -y dnf-plugins-core"
sudo /usr/local/bin/retry "dnf config-manager --add-repo 'https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo'"
else
sudo retry "yum install -y yum-utils"
sudo retry "yum-config-manager --add-repo 'https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo'"
sudo /usr/local/bin/retry "yum install -y yum-utils"
sudo /usr/local/bin/retry "yum-config-manager --add-repo 'https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo'"
fi
echo Installing nvidia-docker tools
sudo retry "$PKG_MANAGER install -y nvidia-docker2"
sudo /usr/local/bin/retry "$PKG_MANAGER install -y nvidia-docker2"
sudo systemctl restart docker
fi
%{ endif ~}
Expand Down

0 comments on commit 36b5f2c

Please sign in to comment.