|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 4 | +# SPDX-License-Identifier: MIT-0 |
| 5 | + |
| 6 | +############################################################################################## |
| 7 | +# Linux Development Environment Setup Script |
| 8 | +# |
| 9 | +# This script automates the installation of development tools for the GenAI IDP accelerator |
| 10 | +# on Amazon Linux 2023 systems. It installs Python 3.13, AWS CLI, SAM CLI, Node.js, Docker, |
| 11 | +# and other essential development tools. |
| 12 | +# |
| 13 | +# Usage: ./linux_dev_setup.sh |
| 14 | +# Note: Reboot required after completion |
| 15 | +############################################################################################## |
| 16 | + |
| 17 | +# exit on failure |
| 18 | +set -ex |
| 19 | + |
| 20 | +pushd /tmp |
| 21 | + |
| 22 | +# force python 3.9 (yum/dnf don;t seem to work well with 3.12) |
| 23 | +sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 |
| 24 | +sudo alternatives --set python3 /usr/bin/python3.9 |
| 25 | + |
| 26 | +# developer tools |
| 27 | +sudo yum groupinstall "Development Tools" -y |
| 28 | + |
| 29 | +# python/pip/conda |
| 30 | +sudo dnf update -y |
| 31 | +sudo dnf install python3.12 -y |
| 32 | +sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 1 |
| 33 | +sudo alternatives --install /usr/bin/python python /usr/bin/python3.13 1 |
| 34 | +python3.12 -m ensurepip --upgrade |
| 35 | +pip3 install --upgrade pip |
| 36 | +pip3 install virtualenv |
| 37 | +curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh |
| 38 | +bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda || bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda -u |
| 39 | + |
| 40 | +# aws cli |
| 41 | +sudo yum remove awscli -y |
| 42 | +curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" |
| 43 | +unzip awscliv2.zip |
| 44 | +sudo ./aws/install --update |
| 45 | + |
| 46 | +# sam cli |
| 47 | +wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip |
| 48 | +unzip aws-sam-cli-linux-x86_64.zip -d ./sam-cli |
| 49 | +sudo ./sam-cli/install --update |
| 50 | + |
| 51 | +# node 18 |
| 52 | +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash |
| 53 | +source ~/.bashrc |
| 54 | +nvm install 18 |
| 55 | + |
| 56 | +# docker |
| 57 | +sudo yum install docker -y |
| 58 | +sudo service docker start |
| 59 | +sudo usermod -a -G docker ec2-user |
| 60 | + |
| 61 | +# interpreter |
| 62 | +pip install open-interpreter |
| 63 | + |
| 64 | +# local .bashrc scripts |
| 65 | +mkdir -p ~/.bashrc.d |
| 66 | +cat <<_EOF > ~/.bashrc.d/bob-prefs |
| 67 | +
|
| 68 | +_bash_history_sync() { |
| 69 | + builtin history -a |
| 70 | +} |
| 71 | +
|
| 72 | +# modifications needed only in interactive mode |
| 73 | +if [ "\$PS1" != "" ]; then |
| 74 | + # keep more history |
| 75 | + shopt -s histappend |
| 76 | + export HISTSIZE=100000 |
| 77 | + export HISTFILESIZE=100000 |
| 78 | + export PROMPT_COMMAND="history -a;" |
| 79 | +
|
| 80 | + if [[ "$PROMPT_COMMAND" != *_bash_history_sync* ]]; then |
| 81 | + PROMPT_COMMAND="_bash_history_sync; $PROMPT_COMMAND" |
| 82 | + fi |
| 83 | +
|
| 84 | + # default prompt (from Cloud9) |
| 85 | + _prompt_user() { |
| 86 | + if [ "\$USER" = root ]; then |
| 87 | + echo "\$USER" |
| 88 | + else |
| 89 | + echo "" |
| 90 | + fi |
| 91 | + } |
| 92 | + PS1='\[\033[01;32m\]\$(_prompt_user)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$(__git_ps1 " (%s)" 2>/dev/null) \$ ' |
| 93 | + |
| 94 | + alias python=python3 |
| 95 | + alias pip=pip3 |
| 96 | + alias interpreter="interpreter --model bedrock/us.anthropic.claude-3-haiku-20240307-v1:0" |
| 97 | +fi |
| 98 | +_EOF |
| 99 | + |
| 100 | +popd |
| 101 | + |
| 102 | +echo "DONE - Please reboot to complete the setup." |
0 commit comments