Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@silentjay
Last active June 19, 2020 18:30
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 silentjay/09dc0f2e4bfce7fa17a2f4bee374b5eb to your computer and use it in GitHub Desktop.
Save silentjay/09dc0f2e4bfce7fa17a2f4bee374b5eb to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
################################################################################
# Set up new site DigitalOcean Ubuntu droplet
echo
echo "Setting up new site on droplet"
echo
echo "Please enter the domain name e.g. mysite.co.uk"
read domain
echo "Creating ~/$domain"
sudo mkdir ~/$domain
echo "Creating virtualenv at ~/$domain/venv"
sudo virtualenv ~/$domain/venv
echo "Creating git folder /home/git/repos/$domain.co.uk.git"
sudo mkdir /home/git/repos/$domain.co.uk.git
echo "Chaning permissions on git folder /home/git/repos/$domain.co.uk.git"
sudo chown -R john:john /home/git/repos/$domain.co.uk.git
git init /home/git/repos/$domain.co.uk.git --bare
cd hooks
touch post-receive
sudo nano post-receive
#!/bin/sh
git --work-tree=/home/john/mydomain.co.uk --git-dir=/home/git/repos/mydomain.co.uk.git checkout -f
sudo chmod +x post-receive
sudo echo "/swapfile none swap sw 0 0" >> /etc/fstab
echo
echo "DONE! You should see swap in use now:"
free -m
echo "Swappiness should now be 10:"
cat /proc/sys/vm/swappiness
echo "Cache pressure should be set to 50:"
cat /proc/sys/vm/vfs_cache_pressure
echo "We've edited /etc/sysctl.conf by adding two lines to the end of the file"
echo "which should cause these new settings to persist across reboots."
echo
echo "All done!"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment