diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000..64ceea08 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,87 @@ +# Development Environment Setup Script + +## Overview +This bash script automates the setup of a complete development environment on a Linux (Ubuntu) system. +The overall goal of this script is to install and configure your development environment to work on as a platform engineer. + +## Features +The following list involves all the installation in order to set up your development environment. +1. Network Connectivity Checks + * +2. System Updates and Upgrades + * +3. Installation of Essential Development Tools: + * git + * vim + * tilix + * curl + * wget + * jq + * unzip + * gnupg + * apt-transport-https + * ca-certificates + * software-properties-common +4. Installation of Major Cloud CLI Tools: + * Azure CLI + * AWS CLI + * Google Cloud SDK +5. Installation of Infrastructure as Code (IaC) Tools: + * Terraform + * OpenTofu + * Bicep + * Helm +6. Installation of Kubernetes Management Tools: + * kubectl + * K9s + * Minikube +7. Installation of Oh My Posh (Cosmetic Enhancements) +8. Installation of VS Code Extentions: + * Terraform + * Kubernetes + * Azure + * Bicep + * Gitlens + * Spell Checker +9. Semi-Automatic Git Configuration with SSH Setup + +## Prerequisites +* A Linux distribution with `sudo` privileges +* Active internet connection + +## How to Use +1. Clone this repository or copy the script into your local system. + * To copy, save the file `ubuntu_dev_env_setup.sh' onto your local machine. Remember the directory you placed it in +2. Open the terminal and head into the directory where this script is located. +3. Run the script using `./ubuntu_dev_env_setup.sh` +4. Follow along the on-screen prompts + +### Git Configuration Steps +The final step of this script will need manual inputs as generating an SSH key requires: +* Git username +* Git password +* Directory to save SSH keys properly + +When prompted on your terminal, ensure you fill out the following: +1. Primary email for git `Enter your primary email for git:` +2. Username for git `Enter your username for git:` +3. File Location to save the key `Enter file in which to save the key (/home/user/.ssh/id_ed25519)` + * Simply type out the folder location as written in the brackets +4. Leave passphrase empty by pressing your enter key +5. Leave passphrase empty (again) by pressing your enter key + #### Copying your SSH key to add into GitHub + * The terminal will write out the command `cat ~/.ssh/id_ed25519.pub` which allows you to view that generated SSH Key + * Highlight the following response and copy it + + 1. Log into your GitHub Account through a web browser + 2. Click on your account (top-right corner) + 3. Through the Settings page, head onto the SSH and GPG keys section on the left tab + 4. Click on the green "New SSH Key" + 5. Feel free to se the Title to whatever you would like, then ensure that Key Type is set to "Authentication key" + 6. In the Key Section, paste your SSH Key from your terminal + 7. Once you click the green "Add SSH Key" button, you are finished! + + + + + diff --git a/scripts/ubuntu_dev_env_setup.sh b/scripts/ubuntu_dev_env_setup.sh index 3cc268ce..23b961af 100755 --- a/scripts/ubuntu_dev_env_setup.sh +++ b/scripts/ubuntu_dev_env_setup.sh @@ -1,12 +1,31 @@ #!/bin/bash +# Colors for messages +GREEN="\e[32m" +RED="\e[31m" +YELLOW="\e[33m" +RESET="\e[0m" + +# Validate network +validate_network() { + echo -e "${YELLOW}Checking network connectivity...${RESET}" + if ping -c 3 google.com; then + echo -e "${GREEN}Network connectivity: SUCCESSFUL${RESET}" + else + echo -e "${RED}Network connectivity: FAILED${RESET}" + exit 1 + fi +} + # Update and upgrade the system upgrade_system() { + echo -e "${YELLOW}Updating and upgrading the system...${RESET}" sudo apt update && sudo apt upgrade -y } # Install essential development tools install_dev_tools() { + echo -e "${YELLOW}Installing core development tools...${RESET}" sudo apt install -y \ git \ vim \ @@ -14,61 +33,254 @@ install_dev_tools() { curl \ wget \ jq \ - unzip + unzip \ + gnupg \ + apt-transport-https \ + ca-certificates \ + software-properties-common } -# Install VS Code (via Flatpak) +# Install VS Code (via Snap) install_vscode() { - flatpak install -y flathub com.visualstudio.code + echo -e "${YELLOW}Installing VS Code (via Snap) ${RESET}" + sudo snap install --classic code } - # Install Cloud CLIs # ==================================== -# Azure - -# AWS +# Azure CLI +install_azure_cli() { + echo -e "${YELLOW}Installing Azure CLI...${RESET}" + curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash +} -# Google +# AWS CLI +install_aws_cli() { + echo -e "${YELLOW}Installing AWS CLI...${RESET}" + curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" + unzip awscliv2.zip + sudo ./aws/install + # Remove installation "junk" + rm -rf aws awscliv2.zip +} + +# Google Cloud SDK +install_google_cloud_sdk() { + echo -e "${YELLOW}Installing Google Cloud SDK...${RESET}" + curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg + echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list + sudo apt update && sudo apt -y install google-cloud-cli +} -#Install Infrastructure as Code tools +# Install Infrastructure as Code tools # ==================================== # Terraform +install_terraform() { + echo -e "${YELLOW}Installing Terraform...${RESET}" + + wget -O- https://apt.releases.hashicorp.com/gpg |\ + gpg --dearmor |\ + sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null + + echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \ + sudo tee /etc/apt/sources.list.d/hashicorp.list + + sudo apt update && sudo apt -y install terraform +} # OpenTofu +install_opentofu() { + echo -e "${YELLOW}Installing OpenTofu...${RESET}" + sudo snap install --classic opentofu +} # Bicep +install_bicep() { + echo -e "${YELLOW}Installing Bicep...${RESET}" + curl -Lo bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64 + chmod +x ./bicep + sudo mv ./bicep /usr/local/bin/bicep +} # Helm +install_helm() { + echo -e "${YELLOW}Installing Helm...${RESET}" + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + +} -# Instaall Kubernetes tools +# Install Kubernetes tools # ==================================== # kubectl +install_kubectl() { + echo -e "${YELLOW}Installing Kubectl...${RESET}" + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl + # Remove installation "junk" + rm -f kubectl +} # K9s +install_k9s() { + echo -e "${YELLOW}Installing K9s...${RESET}" + # Find the latest K9s Debian package URL from GitHub releases + latest_k9s=$(curl -s https://api.github.com/repos/derailed/k9s/releases/latest | grep "browser_download_url.*amd64.deb" | cut -d '"' -f 4) + # Download the latest K9s .deb package + wget "$latest_k9s" + # Install K9s using the .deb package + sudo apt install ./"$(basename "$latest_k9s")" + # Remove Installation "junk" + rm -f "$(basename "$latest_k9s")" +} # minikube +install_minikube() { + echo -e "${YELLOW}Installing Minikube...${RESET}" + curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64 + sudo install minikube-linux-amd64 /usr/local/bin/minikube + # Remove installation "junk" + rm -f minikube-linux-amd64 +} # Oh My Posh +install_oh_my_posh() { + echo -e "${YELLOW}Installing Oh My Posh...${RESET}" + curl -s https://ohmyposh.dev/install.sh | bash -s +} # VScode extensions # ==================================== -# terraform, kubernetes tools, azure tools, bicep, gitlen, spell checker +# terraform, kubernetes tools, azure tools, bicep, gitlen, spell checker, helm +install_vscode_extensions() { + echo -e "${YELLOW}Installing VS Code extensions...${RESET}" + code --install-extension hashicorp.terraform + code --install-extension ms-kubernetes-tools.vscode-kubernetes-tools + code --install-extension msazurermtools.azurerm-vscode-tools + code --install-extension ms-azuretools.vscode-bicep + code --install-extension eamodio.gitlens + code --install-extension streetsidesoftware.code-spell-checker +} + +check_installation() { + local cmd=$1 + local name=$2 + + if eval $cmd &>/dev/null; then + echo -e "${GREEN}${name} Installation: SUCCESS${RESET}" + else + echo -e "${RED}${name} Installation: FAILED${RESET}" + fi +} + +final_verification() { + echo -e "\n${YELLOW}Verifying all installations...${RESET}" + check_installation "git --version" "Git" + check_installation "vim --version" "Vim" + check_installation "tilix --version" "Tilix" + check_installation "curl --version" "cURL" + check_installation "wget --version" "Wget" + check_installation "jq --version" "jq" + check_installation "unzip -v" "Unzip" + check_installation "gpg --version" "GnuPG" + check_installation "apt-config dump" "APT Transport HTTPS (Check APT Config)" + check_installation "openssl version" "CA Certificates (Check OpenSSL)" + check_installation "apt-cache policy software-properties-common" "Software Properties Common" + check_installation "code --version" "VS Code" + check_installation "az version" "Azure CLI" + check_installation "sudo aws --version" "AWS CLI" + check_installation "gcloud version" "Google Cloud SDK" + check_installation "terraform version" "Terraform" + check_installation "tofu version" "OpenTofu" + check_installation "bicep --version" "Bicep" + check_installation "helm version" "Helm" + check_installation "kubectl version --client" "kubectl" + check_installation "k9s version" "K9s" + check_installation "minikube version" "Minikube" + check_installation "~/.local/bin/oh-my-posh --version" "Oh My Posh" + echo -e "${YELLOW}Listing all VS Code Extentions${RESET}" + code --list-extensions + echo -e "${GREEN}Development environment setup is almost complete!${RESET}" + +} # Config git with ssh authentication +# The following portion would require manual inputs" +configure_git() { + echo -e "${YELLOW}Configuring Git with SSH...${RESET}" + echo -e "${YELLOW}Enter your primary email for git:${RESET}" + read git_email + git config --global user.email "$git_email" -# Validate networking and permissions + echo -e "${YELLOW}Enter your username for git:${RESET}" + read git_name + git config --global user.name "$git_name" -# Final messages + if [[ ! -f ~/.ssh/id_ed25519 ]]; then + echo "${YELLOW}Generating SSH key for GitHub...${RESET}" + ssh-keygen -t ed25519 -C "$git_email" + eval "$(ssh-agent -s)" + ssh-add ~/.ssh/id_ed25519 + fi -main() { - # upgrade_system - # install_dev_tools - # install_vscode + # Refer to Markdown/Readme Instructions + echo -e "${YELLOW}Copy your SSH key and add it to GitHub:${RESET}" + cat ~/.ssh/id_ed25519.pub + echo -e "${YELLOW}Refer to README notes on the next steps${RESET}" +} + +next_steps_message() { + echo -e "${YELLOW}Last Step: SSH Authentication with GitHub${RESET}" +} - echo "Development environment setup complete!" - echo "Restart your terminal or run 'source ~/.bashrc' to apply changes." +final_message() { + echo -e "${GREEN}Congratulations! You have reached the end of this script. Refer back to the verification step and ensure that all installations did not ${RED}FAIL.${RESET} Ensure that your SSH key has been generated and set into your GitHub account." } +main() { + # Initial validation + validate_network + + # System update and upgrades + upgrade_system + + # Install Development tools + install_dev_tools + + # Install VS Code + install_vscode + + # Install Cloud CLIs + install_azure_cli + install_aws_cli + install_google_cloud_sdk + + # Install Infrastructure tools and validate + install_terraform + install_opentofu + install_bicep + install_helm + + # Install Kubernetes tools and validate + install_kubectl + install_k9s + install_minikube + + # Install Oh My Posh + install_oh_my_posh + + # Install VSCode Extensions + install_vscode_extensions + + # Verify all installations + final_verification + + # "Step 1 - END" message + next_steps_message + + # Configure Git + configure_git +} main \ No newline at end of file