#!/bin/bash set -xe # Detect the operating system if [ -f /etc/os-release ]; then . /etc/os-release OS=$NAME elif [ -f /etc/lsb-release ]; then . /etc/lsb-release OS=$DISTRIB_ID else OS=$(uname -s) fi # Set the appropriate user based on the detected OS if [[ "$OS" == "Ubuntu" ]]; then USER="ubuntu" COMMENT="Setting password for Ubuntu default user" elif [[ "$OS" == "Amazon Linux" ]]; then USER="ec2-user" COMMENT="Setting password for Amazon Linux default user" elif [[ "$OS" == "Darwin" ]]; then USER=$(whoami) COMMENT="Using current macOS user" else echo "Unsupported operating system: $OS" exit 1 fi # Check if Homebrew is already installed if ! command -v brew &> /dev/null; then echo "Homebrew not found. Installing Homebrew..." # Install Homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" if [[ "$OS" != "Darwin" ]]; then # Linux-specific Homebrew setup CI=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> ~/.bashrc eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" else # macOS-specific Homebrew setup if [[ $(uname -m) == "arm64" ]]; then # For Apple Silicon eval "$(/opt/homebrew/bin/brew shellenv)" echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc else # For Intel Mac eval "$(/usr/local/bin/brew shellenv)" echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zshrc fi fi echo "Homebrew installation completed." else echo "Homebrew is already installed." fi # Install system packages based on OS if [[ "$OS" == "Ubuntu" ]]; then sudo apt update && sudo apt install -y sqlite telnet jq strace tree python3 python3-pip gettext bash-completion zsh golang-go plocate elif [[ "$OS" == "Amazon Linux" ]]; then sudo yum update && sudo yum -y install sqlite telnet jq strace tree gcc glibc-static python3 python3-pip gettext bash-completion npm zsh util-linux-user golang-go sudo dnf install findutils elif [[ "$OS" == "Darwin" ]]; then brew install sqlite telnet jq tree python3 gettext bash-completion zsh golang # macOS already has most of these tools or equivalents else echo "Unsupported operating system for package installation: $OS" exit 1 fi # Install common utils with Homebrew brew install ag brew install findutils brew install fzf # AWS CLI configuration aws configure set cli_pager "" # Kubernetes setup if command -v kubectl &> /dev/null; then # Set up kubectl completion based on default shell if [[ "$SHELL" == */zsh ]]; then kubectl completion zsh > "${fpath[1]}/_kubectl" echo "alias k=kubectl" >> ~/.zshrc echo "compdef __start_kubectl k" >> ~/.zshrc else kubectl completion bash >> ~/.bash_completion echo "alias k=kubectl" >> ~/.bashrc echo "complete -F __start_kubectl k" >> ~/.bashrc fi fi # Common aliases if [[ "$SHELL" == */zsh ]]; then echo "alias ll='ls -la'" >> ~/.zshrc else echo "alias ll='ls -la'" >> ~/.bashrc fi # Install code-server alias if it exists (Linux only) if [[ "$OS" != "Darwin" && -f /usr/lib/code-server/bin/code-server ]]; then echo "alias code=/usr/lib/code-server/bin/code-server" >> ~/.bashrc # Install VSCode extensions /usr/lib/code-server/bin/code-server --install-extension hashicorp.terraform /usr/lib/code-server/bin/code-server --install-extension moshfeu.compare-folders /usr/lib/code-server/bin/code-server --install-extension amazonwebservices.amazon-q-vscode || true fi # Install k9s curl -sS https://webinstall.dev/k9s | bash # Install fzf git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf ~/.fzf/install --all # Install direnv curl -sfL https://direnv.net/install.sh | bash if [[ "$SHELL" == */zsh ]]; then echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc else echo 'eval "$(direnv hook bash)"' >> ~/.bashrc fi # Install Amazon Q (platform specific) if [[ "$OS" == "Darwin" ]]; then if [[ $(uname -m) == "arm64" ]]; then # For Apple Silicon curl --proto '=https' --tlsv1.2 -sSf "https://desktop-release.q.us-east-1.amazonaws.com/latest/q-arm64-darwin.zip" -o "/tmp/q.zip" else # For Intel Mac curl --proto '=https' --tlsv1.2 -sSf "https://desktop-release.q.us-east-1.amazonaws.com/latest/q-x86_64-darwin.zip" -o "/tmp/q.zip" fi unzip /tmp/q.zip -d /tmp /tmp/q/install.sh --no-confirm else # For Linux curl --proto '=https' --tlsv1.2 -sSf "https://desktop-release.q.us-east-1.amazonaws.com/latest/q-x86_64-linux.zip" -o "/tmp/q.zip" unzip /tmp/q.zip -d /tmp /tmp/q/install.sh --no-confirm fi # Download the latest Argo CD CLI if [[ "$OS" == "Darwin" ]]; then if [[ $(uname -m) == "arm64" ]]; then # For Apple Silicon curl -sSL -o argocd-darwin-arm64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-darwin-arm64 chmod +x argocd-darwin-arm64 sudo mv argocd-darwin-arm64 /usr/local/bin/argocd else # For Intel Mac curl -sSL -o argocd-darwin-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-darwin-amd64 chmod +x argocd-darwin-amd64 sudo mv argocd-darwin-amd64 /usr/local/bin/argocd fi else # For Linux curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 chmod +x argocd-linux-amd64 sudo mv argocd-linux-amd64 /usr/local/bin/argocd fi # Install oh-my-zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" || true echo "continue" # Customize ZSH git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k export ZSH_THEME="powerlevel10k/powerlevel10k" # Install ZSH plugins git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search # Copy config files if they exist if [[ -f .zshrc ]]; then cp .zshrc ~/ fi if [[ -f .p10k.zsh ]]; then cp .p10k.zsh ~/ fi # Install krew ( set -x; cd "$(mktemp -d)" && OS="$(uname | tr '[:upper:]' '[:lower:]')" && ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" && KREW="krew-${OS}_${ARCH}" && curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" && tar zxvf "${KREW}.tar.gz" && ./"${KREW}" install krew ) # Add krew to PATH if [[ "$SHELL" == */zsh ]]; then echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' >> ~/.zshrc else echo 'export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"' >> ~/.bashrc fi # Install kubectl plugins export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" kubectl krew install stern # Install AWS CLI tools brew install aws/tap/eksdemo brew install kubectx echo "Installation completed successfully!"