#!/usr/bin/env bash set -e # TODO # kubernetes setup # minikube # kubectl # /etc/needrestart/needrestart.conf $nrconf{restart} = 'a'; ######################################################################################################################################################################## #Initial setup and updating of exiting base os software #Installing essential dev enviroment utils export NEOVIM_VERSION='0.10.2' export DELTA_VERSION='0.16.5' export NEEDRESTART_MODE='a' export OS_NAME='ubuntu' if [ -n "$1" ]; then OS_NAME=$1 fi echo "Setting this install for $OS_NAME" sudo apt-get --allow-releaseinfo-change update sudo apt update && sudo apt upgrade -y --no-install-recommends WORK_DIR=$(mktemp -d) cd "${WORK_DIR}" echo "Switching to ${PWD} as current working directory" sudo apt install -y --no-install-recommends \ ca-certificates \ build-essential \ apt-transport-https \ net-tools \ gnupg \ gzip \ curl \ unzip \ wget \ man \ vim ######################################################################################################################################################################## #Installing external sources for apt # Setup Docker source list entry for apt sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/"$OS_NAME"/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/"$OS_NAME" $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Setup github cli source list entry curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ # Setup JDK Sources from Adoptium wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list ######################################################################################################################################################################## #Installing developer tools and utilities # Installing local developer tools and sdks sudo apt update -y && sudo apt install -y --no-install-recommends \ zsh \ jq \ ncdu \ htop \ tmux \ tree \ git \ temurin-8-jdk \ temurin-11-jdk \ openjdk-17-jdk \ scala \ maven \ gh \ ripgrep \ exa \ fzf \ bat echo "Determine if user authenticates via ldap or locally" if grep -c -q $USER /etc/passwd; then echo "$USER authenticates locally" sudo chsh -s /bin/zsh $USER else echo "$USER authenticates via ldap" sudo apt install sssd-tools -y sudo sss_override user-add ${USER} --shell /bin/zsh sudo systemctl restart sssd fi export SHELL=/bin/zsh if ! command -v aws &> /dev/null then echo "Installing aws cli" curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \ && unzip awscliv2.zip \ && sudo ./aws/install --update fi wget "https://github.com/dandavison/delta/releases/download/${DELTA_VERSION}/git-delta_${DELTA_VERSION}_amd64.deb" sudo dpkg -i git-delta_${DELTA_VERSION}_amd64.deb # Installing Docker sudo apt install -y --no-install-recommends \ docker-ce \ docker-ce-cli \ containerd.io \ && sudo groupadd docker \ && sudo usermod -aG docker "$USER" # Installing Oh My ZShell zshell_home_dir="$HOME/.oh-my-zsh" if [ -d "$zshell_home_dir" ]; then echo "Oh My ZShell alreadly installed. Lets chuck it" bash ~/.oh-my-zsh/tools/uninstall.sh fi echo "Installing oh my zsh shell" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions sed -i 's/plugins=(git)/plugins=(zsh-autosuggestions)/' ~/.zshrc # Installing Node wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" nvm install 18 # Installing Neovim wget "https://github.com/neovim/neovim/releases/download/v${NEOVIM_VERSION}/nvim-linux64.tar.gz" sudo tar -xvzf nvim-linux64.tar.gz -C /usr/local sudo ln -sf /usr/local/nvim-linux64/bin/nvim /usr/local/bin/nvim #Installing Homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/mpg26/.zshrc eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" brew install glab ######################################################################################################################################################################## #Configurations for home directory rm -rf ${HOME}/.dotfiles git clone https://github.com/mgersty/.dotfiles.git ${HOME}/.dotfiles export DOT_FILES_LOCATION="${HOME}/.dotfiles" mkdir -p "${HOME}"/.config \ && ln -sf "${DOT_FILES_LOCATION}"/nvim "${HOME}/.config/nvim" \ && ln -sf "${DOT_FILES_LOCATION}"/.tmux.conf "${HOME}/.tmux.conf" \ && ln -sf "${DOT_FILES_LOCATION}"/.gitconfig "${HOME}/.gitconfig" \ && ln -sf "${DOT_FILES_LOCATION}"/.gitmessage "${HOME}/.gitmessage" rm -rf ${HOME}/.tmux/plugins/tpm git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm sed -i '/source ~\/.dotfiles\/.common/d' ~/.zshrc echo "source ~/.dotfiles/.common" >> ~/.zshrc mkdir $HOME/.ssh if [ ! -e "$HOME/.ssh/id_rsa" ]; then email="" key_filename="$HOME/.ssh/id_rsa" passphrase="" ssh-keygen -t rsa -b 2048 -C "$email" -f "$key_filename" -N "$passphrase" echo "Key pair generated:" echo "Private key: $key_filename" echo "Public key: ${key_filename}.pub" fi echo "Setup complete :)" echo "Please restart your machine"