|
| 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 Ubuntu 24.04 systems. It installs Python 3.12, AWS CLI, SAM CLI, Node.js, Docker, |
| 11 | +# and other essential development tools. |
| 12 | +# |
| 13 | +# Usage: ./dev_setup_ubuntu.sh |
| 14 | +# Note: Logout/login required after completion for Docker group permissions |
| 15 | +############################################################################################## |
| 16 | + |
| 17 | +# exit on failure |
| 18 | +set -ex |
| 19 | + |
| 20 | +pushd /tmp |
| 21 | + |
| 22 | +# developer tools |
| 23 | +sudo apt update -y |
| 24 | +sudo apt install build-essential -y |
| 25 | + |
| 26 | +# python/pip/conda |
| 27 | +sudo apt install python3.12 python3.12-venv python3-pip unzip wget zip -y |
| 28 | +sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 |
| 29 | +sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1 |
| 30 | +pip3 install --upgrade pip --break-system-packages |
| 31 | +pip3 install virtualenv typer ruff --break-system-packages |
| 32 | +curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh |
| 33 | +bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda || bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda -u |
| 34 | + |
| 35 | +# aws cli |
| 36 | +sudo apt remove awscli -y || true |
| 37 | +curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" |
| 38 | +unzip -q awscliv2.zip |
| 39 | +sudo ./aws/install --update |
| 40 | + |
| 41 | +# sam cli |
| 42 | +wget -q https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip |
| 43 | +unzip -q aws-sam-cli-linux-x86_64.zip -d ./sam-cli |
| 44 | +sudo ./sam-cli/install --update |
| 45 | + |
| 46 | +# node 20 |
| 47 | +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash |
| 48 | +export NVM_DIR="$HOME/.nvm" |
| 49 | +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" |
| 50 | +nvm install 20 |
| 51 | + |
| 52 | +# docker |
| 53 | +sudo apt install docker.io -y |
| 54 | +sudo systemctl start docker |
| 55 | +sudo systemctl enable docker |
| 56 | +sudo usermod -a -G docker $USER |
| 57 | + |
| 58 | +# local .bashrc scripts |
| 59 | +mkdir -p ~/.bashrc.d |
| 60 | +cat <<'_EOF' > ~/.bashrc.d/bob-prefs |
| 61 | +
|
| 62 | +_bash_history_sync() { |
| 63 | + builtin history -a |
| 64 | +} |
| 65 | +
|
| 66 | +# modifications needed only in interactive mode |
| 67 | +if [ "$PS1" != "" ]; then |
| 68 | + # keep more history |
| 69 | + shopt -s histappend |
| 70 | + export HISTSIZE=100000 |
| 71 | + export HISTFILESIZE=100000 |
| 72 | + export PROMPT_COMMAND="history -a;" |
| 73 | +
|
| 74 | + if [[ "$PROMPT_COMMAND" != *_bash_history_sync* ]]; then |
| 75 | + PROMPT_COMMAND="_bash_history_sync; $PROMPT_COMMAND" |
| 76 | + fi |
| 77 | +
|
| 78 | + # default prompt (from Cloud9) |
| 79 | + _prompt_user() { |
| 80 | + if [ "$USER" = root ]; then |
| 81 | + echo "$USER" |
| 82 | + else |
| 83 | + echo "" |
| 84 | + fi |
| 85 | + } |
| 86 | + PS1='\[\033[01;32m\]$(_prompt_user)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 " (%s)" 2>/dev/null) \$ ' |
| 87 | + |
| 88 | + alias python=python3 |
| 89 | + alias pip=pip3 |
| 90 | + alias interpreter="interpreter --model bedrock/us.anthropic.claude-3-haiku-20240307-v1:0" |
| 91 | + |
| 92 | + # Add local bin to PATH |
| 93 | + export PATH="$HOME/.local/bin:$PATH" |
| 94 | +fi |
| 95 | +_EOF |
| 96 | + |
| 97 | +popd |
| 98 | + |
| 99 | +echo "DONE - Please log out and log back in for Docker group permissions to take effect." |
0 commit comments