Skip to content

Instantly share code, notes, and snippets.

@pablete
Forked from christianberg/bootstrap.sh
Created October 17, 2013 18:02
Show Gist options
  • Save pablete/7029458 to your computer and use it in GitHub Desktop.
Save pablete/7029458 to your computer and use it in GitHub Desktop.
#/bin/bash
set -e
echo "=== Activating Firewall (only SSH allowed) ==="
ufw allow ssh
ufw --force enable
if [ ! -f /swapfile ]; then
echo "=== Activating swap ==="
fallocate -l 1G /swapfile
mkswap /swapfile
swapon /swapfile
chmod 0600 /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
fi
echo "=== Installing Kernel with LXC and AUFS Support ==="
export DEBIAN_FRONTEND=noninteractive
apt-get -qq update
apt-get install -qqy linux-image-extra-`uname -r`
echo "=== Installing Docker and git ==="
curl http://get.docker.io/gpg | apt-key add -
echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
apt-get -qq update
apt-get install -qqy lxc-docker git
echo "=== Opening Firewall for Docker Network ==="
sed -i.bak 's/DEFAULT_FORWARD_POLICY=".*"/DEFAULT_FORWARD_POLICY="ACCEPT"/' /etc/default/ufw
sed -r -i.bak 's/^#(net\/ipv4\/ip_forward=1|net\/ipv6\/conf\/default\/forwarding=1|net\/ipv6\/conf\/all\/forwarding=1)$/\1/' /etc/ufw/sysctl.conf
ufw disable
ufw --force enable
ufw allow out on docker0
ufw allow in on docker0
echo "=== Verifying Installation ==="
docker run busybox /bin/echo '*** It works! ***'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment