Skip to content

Instantly share code, notes, and snippets.

@ryankurte
Last active November 29, 2018 02:34
Show Gist options
  • Save ryankurte/f4c60f7307889b2d0f2c5eacf8ca0e0e to your computer and use it in GitHub Desktop.
Save ryankurte/f4c60f7307889b2d0f2c5eacf8ca0e0e to your computer and use it in GitHub Desktop.
Helper script to setup a new debian machine
#!/bin/bash
set -e
# Update sources to nz mirrors
sudo sed -i"" 's|http://deb.debian.org|http://ftp.nz.debian.org|g' /etc/apt/sources.list.d/base.list
# Install backports
BACKPORT_FILE=/etc/apt/sources.list.d/debian-backports.list
if [ ! -f $BACKPORT_FILE ]; then
echo "deb http://ftp.nz.debian.org/debian stretch-backports main contrib non-free" | sudo tee $BACKPORT_FILE
fi
sudo apt update
# Update to backported kernel
sudo apt install -t stretch-backports -y linux-image-amd64
sudo apt install -t stretch-backports -y linux-headers-$(uname -r)
# Upgrade and cleanup
sudo apt upgrade -y
sudo apt autoclean
# Install the classics / build stuff
sudo apt install -y vim git build-essential cmake pkg-config clang apt-transport-https ca-certificates curl gnupg2 software-properties-common
# Unattended / security updates
sudo apt install -y unattended-upgrades apt-listchanges
# Install docker
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
DOCKER_FILE=/etc/apt/sources.list.d/docker.list
if [ ! -f $DOCKER_FILE ]; then
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee $DOCKER_FILE
fi
sudo apt update
sudo apt install -y docker-ce
sudo adduser $(whoami) docker
# Fetch nvidia driver (requires manual install outside of gui)
NVIDIA_URL="http://us.download.nvidia.com/XFree86/Linux-x86_64"
NVIDIA_DRIVER="NVIDIA-Linux-x86_64-410.78.run"
if [ ! -f "/tmp/$NVIDIA_DRIVER" ]; then
wget "$NVIDIA_URL/$NVIDIA_DRIVER" -O "/tmp/$NVIDIA_DRIVER"
fi
# Install KVM
sudo apt install -y qemu-kvm libvirt-clients qemu-utils libvirt-daemon-system qemu-system
sudo adduser $(whoami) libvirt
sudo adduser $(whoami) libvirt-qemu
# Install ZSH
if [ ! -d "$HOME/.oh-my-zsh" ]; then
sudo apt install -y zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
fi
# Install rust
RUSTUP_SH="/tmp/rustup.sh"
if [ ! -d "$HOME/.cargo" ]; then
wget "https://sh.rustup.rs" -O "$RUSTUP_SH"
sh $RUSTUP_SH
fi
# Install go
GO_VER=go1.11.2
GO_BIN="$GO_VER.linux-amd64.tar.gz"
GO_URL="https://dl.google.com/go/$GO_BIN"
if [ ! -d "/tmp/$GO_BIN" ]; then
wget $GO_URL -O "/tmp/$GO_BIN"
fi
if [ ! -d "/usr/local/go" ]; then
sudo tar -C /usr/local -xf /tmp/$GO_BIN
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment