Skip to content

Instantly share code, notes, and snippets.

@rubi022
Created July 18, 2024 06:22
Show Gist options
  • Save rubi022/3acc7b305f5885cebe616af083c99978 to your computer and use it in GitHub Desktop.
Save rubi022/3acc7b305f5885cebe616af083c99978 to your computer and use it in GitHub Desktop.
linuxQuickStart
#!/usr/bin/env bash
function cleanup() {
echo "Cleaning up..."
sudo rm -f /etc/sudoers.d/ubuntu_nopasswd
}
function install_brew() {
$(which sudo) apt-get update
$(which sudo) apt-get install -y sudo curl git
sudo passwd -d ubuntu
echo 'ubuntu ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/ubuntu_nopasswd
# Install Homebrew
sudo -u ubuntu bash -c '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)"') >> /home/ubuntu/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
}
function install_zsh() {
$(which sudo) apt-get update
$(which sudo) apt-get install -y sudo git zsh
sudo chsh -s $(which zsh) ubuntu
touch ~/.zshrc
sudo git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
sudo echo "source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh" >> ~/.zshrc
sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zsh/zsh-syntax-highlighting
sudo echo "source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ~/.zshrc
sudo echo "HISTFILE=~/.zsh_history" >> ~/.zshrc
sudo echo "HISTSIZE=10000" >> ~/.zshrc
sudo echo "SAVEHIST=10000" >> ~/.zshrc
sudo echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zshrc
sudo echo 'git config --global user.name' >> ~/.zshrc
sudo echo 'git config --global user.email' >> ~/.zshrc
}
function install_docker() {
$(which sudo) apt-get update
$(which sudo) apt-get install -y sudo ca-certificates curl qemu-user-static
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker ubuntu
echo "Please start a new shell session or log out and log back in to apply Docker group membership changes."
}
function main() {
install_brew
install_zsh
install_docker
}
set -o errexit
trap cleanup EXIT
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment