Skip to content

Instantly share code, notes, and snippets.

@evantahler
Last active September 3, 2019 22:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evantahler/ddfbe3101c3c9fe8451c6412e288c9fa to your computer and use it in GitHub Desktop.
Save evantahler/ddfbe3101c3c9fe8451c6412e288c9fa to your computer and use it in GitHub Desktop.
Setting up a new computer via sshcode
#!/bin/bash
# First, configure the host to run VSCode with SSHCODE - https://github.com/cdr/sshcode
# Then, run this command via the command line exposed from the new VSCode window (assuming as Root)
# Inspired by https://github.com/evantahler/workstation
###
# Run Command:
# wget https://gist.githubusercontent.com/evantahler/ddfbe3101c3c9fe8451c6412e288c9fa/raw/85e544e513591f316ec23a482419e6e060431fac/setup.sh && chmod 0766 setup.sh && ./setup.sh
###
set -ex
# Variables
ONE_PASSWORD_VERSION="v0.5.5"
NODE_VERSION="12"
RUBY_VERSION="2.6.4"
ONE_PASSWORD_DOMAIN="https://my.1password.com"
# Install base system
RUN apt-get update && apt-get upgrade -y && apt-get install -qq -y \
build-essential \
clang \
cmake \
curl \
git \
jq \
htop \
iftop \
less \
mosh \
net-tools \
openssh-server \
vim \
tmux
# Install 1Password
apt-get update && apt-get install -y curl ca-certificates unzip
curl -sS -o 1password.zip https://cache.agilebits.com/dist/1P/op/pkg/$ONE_PASSWORD_VERSION/op_linux_amd64_$ONE_PASSWORD_VERSION.zip
unzip -o 1password.zip op -d /usr/bin
rm 1password.zip
# Node.JS, NVM, and Yarn
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
. /root/.nvm/nvm.sh && nvm install $NODE_VERSION
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update && apt-get install --no-install-recommends yarn
# Ruby and RVM
apt-get update && apt-get upgrade -y && apt-get install -qq -y \
autoconf \
bison \
build-essential \
libssl-dev \
libyaml-dev \
libreadline6-dev \
zlib1g-dev \
libncurses5-dev \
libffi-dev \
libgdbm5 \
libgdbm-dev
rm -rf ~/.rbenv && git clone https://github.com/rbenv/rbenv.git ~/.rbenv
rm -rf ~/.rbenv/plugins/ruby-build && git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
/root/.rbenv/bin/rbenv install $RUBY_VERSION
/root/.rbenv/bin/rbenv global $RUBY_VERSION
/root/.rbenv/bin/rbenv exec gem install bundler
# Insall Docker
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
sudo apt install docker-ce -y
# Make Workspace
mkdir -p ~/workspace
# Setup 1Password for this user
echo "Enter 1Password account email"
read ONE_PASSWORD_ACCOUNT
echo "OK, $ONE_PASSWORD_ACCOUNT. You will be prompted for you 1Password password next..."
echo "Authenticating with 1Password"
export OP_SESSION_my=$(op signin $ONE_PASSWORD_DOMAIN $ONE_PASSWORD_ACCOUNT --output=raw)
echo "Pulling secrets"
# keys
op get document 'workstation_id_rsa' > id_rsa
op get document 'workstation_id_rsa.pub' > id_rsa.pub
rm -f ~/.ssh/id_rsa
rm -f ~/.ssh/id_rsa.pub
mv $(pwd)/id_rsa ~/.ssh/id_rsa
mv $(pwd)/id_rsa.pub ~/.ssh/id_rsa.pub
chmod 0600 ~/.ssh/id_rsa
echo "ssh keys configured"
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment