Skip to content

Instantly share code, notes, and snippets.

@ericboehs
Created February 28, 2012 00:22
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 ericboehs/1928092 to your computer and use it in GitHub Desktop.
Save ericboehs/1928092 to your computer and use it in GitHub Desktop.
#! /bin/bash
# Setup variables
USER=ericboehs
SSH_PUBLIC_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApqtopvozpyuX+ELj9a78eFY0AmU5Zl3V3l2n7XW49ZVszdJFGX6l3Lsb9tZW1zNSPtt9hDzh7m4R/y0l/Qxzitk0xcQWyuIFIIifiqY2ZFgEPXKcZ/i+6E1rQL8f44eLkgIH8evTB15TPcIefbdWHlhLXn7WoG/aboC9TzLgtUG05m2Mtp8/gDYI93cZHgK9hLsuQR/iSbt3obx6id2bB4MQSjPu7wPpjVbsn6pglbbjgkE9qkERckLDAUDuFQfJRQUMjbJ01Vnp6w0D6Ffg8kE3VFnBxNc4eZHS/nvPTTd35ZhCnnOIQ5brfTAoMpvctlfoh0fjaWhXJbny39CHow== ericboehs@Airic.local"
GITHUB_USER=$USER
GITHUB_KEY=abcdefg # <---- CHANGE ME
# Create an admin and rvm group
/usr/sbin/groupadd admin
/usr/sbin/groupadd rvm
# Add the admin group to the sudoers list (with no password)
sed 's/admin ALL=(ALL) ALL/admin ALL=(ALL) NOPASSWD:ALL/g' /etc/sudoers > /tmp/sudoers.new
mv /tmp/sudoers.new /etc/sudoers && chmod 440 /etc/sudoers
# Create the user '$USER' and make him an admin
/usr/sbin/useradd -m -G admin,rvm -s /bin/bash -d /home/$USER $USER
# Setup $USER user for ssh access
su $USER -c "mkdir ~/.ssh"
su $USER -c "echo $SSH_PUBLIC_KEY >> ~/.ssh/authorized_keys"
su $USER -c "chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"
# Install the essentials (zsh, curl, git, htop, tmux, mysql-client, etc)
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y build-essential zsh curl git htop ack tmux vim-nox exuberant-ctags
apt-get install -y sqlite3 postgresql postgresql-client mysql-client mysql-server redis-server
apt-get install -y ruby-full rubygems libxslt-dev libxml2-dev libmysqlclient-dev libssl-dev libsqlite3-dev libpq-dev
gem install rake --pre --no-rdoc --no-ri #FIXME: Is this needed?
# Divert ack to ack-grep
sudo dpkg-divert --local --divert /usr/bin/ack --rename --add /usr/bin/ack-grep
# Setup postgresql roles
su postgres -c "createuser -s $USER"
# Fix for some mysql problem and rails default sock location
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
# Install NodeJS
apt-get install -y python-software-properties
add-apt-repository -y ppa:chris-lea/node.js
apt-get update && apt-get install -y nodejs
curl http://npmjs.org/install.sh |sh
# Install rvm and ruby 1.9.3
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
source /etc/profile
rvm install 1.9.3
rvm use 1.9.3 --default
gem install bundler --pre --no-rdoc --no-ri
# Setup dotfiles for user $USER
su $USER -c "mv ~/.bashrc ~/.bashrc.bak"
su $USER -c "git clone git://github.com/ericboehs/dotfiles.git ~/.dotfiles"
su $USER -c "cd ~/.dotfiles && git submodule init && git submodule update"
su $USER -c "source /etc/profile && cd ~/.dotfiles && rake install && cd ~/.dotfiles/vim && rake"
su $USER -c "echo 'export GITHUB_USER=$GITHUB_USER' >> ~/.zsh/config.private"
su $USER -c "echo 'export GITHUB_TOKEN=$GITHUB_TOKEN' >> ~/.zsh/config.private"
su $USER -c "gem install tmuxinator" # TODO: move this into dotfiles rake install
# Set default shell
chsh -s /bin/zsh $USER
#TODO: Copy keys
#TODO: Copy code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment