Skip to content

Instantly share code, notes, and snippets.

@valachi
Forked from deepakkumarnd/server_setup.sh
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valachi/4a2697452a9297c7d7b2 to your computer and use it in GitHub Desktop.
Save valachi/4a2697452a9297c7d7b2 to your computer and use it in GitHub Desktop.
echo "* Updating system"
apt-get update
apt-get -y upgrade
echo "* Installing packages"
apt-get -y install build-essential libmagickcore-dev imagemagick libmagickwand-dev libxml2-dev libxslt1-dev git-core nginx redis-server curl nodejs htop
id -u deploy &> /dev/null
if [ $? -ne 0 ]
then
echo "* Creating user deploy"
useradd -m -g staff -s /bin/bash deploy
echo "* Adding user deploy to sudoers"
chmod +w /etc/sudoers
echo "deploy ALL=(ALL) ALL" >> /etc/sudoers
chmod -w /etc/sudoers
else
echo "* deploy user already exists"
fi
cat /etc/environment | grep RAILS_ENV
if [ $? -ne 0 ]
then
echo "RAILS_ENV=production" >> /etc/environment
fi
echo "* Adding a gemrc file to deploy user"
echo -e "verbose: true\nbulk_threshold: 1000\ninstall: --no-ri --no-rdoc --env-shebang\nupdate: --no-ri --no-rdoc --env-shebang" > /home/deploy/.gemrc
chmod 644 /home/deploy/.gemrc
chown deploy /home/deploy/.gemrc
chgrp staff /home/deploy/.gemrc
echo "* Adding ssh key to authorized_keys"
test -d /home/deploy/.ssh
if [ $? -ne 0 ]
then
mkdir /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
chown deploy /home/deploy/.ssh
chgrp staff /home/deploy/.ssh
fi
# deepak's public key
echo "deepak's public key" > /home/deploy/.ssh/authorized_keys
chmod 600 /home/deploy/.ssh/authorized_keys
chown deploy /home/deploy/.ssh/authorized_keys
chgrp staff /home/deploy/.ssh/authorized_keys
echo "* Add user deploy to rvm group"
usermod -a -G rvm deploy
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment