Last active
August 9, 2018 20:21
-
-
Save sigwo/8536b695bf059b74d67609c1a629ba09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# | |
# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04 | |
# | |
# Don't run this script more than once! | |
if [ -f /.chainpoint-installer-run ]; then | |
echo "Looks like this script has already been run. Exiting!" | |
exit 0 | |
fi | |
# Make sure we're running on Ubuntu 16.04 (Xenial) | |
if [ "$(. /etc/os-release; echo $NAME)" != "Ubuntu" ]; then | |
echo "Looks like you are not running this on an Ubuntu OS. Exiting!" | |
exit 1 | |
fi | |
if [ "$(. /etc/os-release; echo $UBUNTU_CODENAME)" != "xenial" ]; then | |
echo "Looks like you are not running this on Ubuntu version 16.04 (Xenial). Exiting!" | |
exit 1 | |
fi | |
apt-get update && apt-get install sudo nano net-tools build-essential tcl -y | |
echo '#################################################' | |
echo 'Installing Docker' | |
echo '#################################################' | |
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 $(lsb_release -cs) stable" | |
sudo apt-get update | |
apt-cache policy docker-ce | |
sudo apt-get install -y docker-ce make | |
echo '#################################################' | |
echo 'Installing Postgres' | |
echo '#################################################' | |
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 | |
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list | |
apt-get update && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3 | |
/etc/init.d/postgresql start &&\ | |
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\ | |
createdb -O docker docker | |
echo '#################################################' | |
echo 'Installing Redis' | |
echo '#################################################' | |
curl -O http://download.redis.io/redis-stable.tar.gz | |
tar xzvf redis-stable.tar.gz | |
cd redis-stable | |
make | |
make install | |
nohup redis-server & | |
echo '#################################################' | |
echo 'Installing Docker Compose' | |
echo '#################################################' | |
sudo mkdir -p /usr/local/bin | |
sudo curl -s -L "https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
echo '#################################################' | |
echo 'Downloading chainpoint-node Github Repository' | |
echo '#################################################' | |
if [ ! -d "~/chainpoint-node" ]; then | |
cd ~ && git clone -b master https://github.com/chainpoint/chainpoint-node | |
fi | |
echo '#################################################' | |
echo 'Creating .env config file from .env.sample' | |
echo '#################################################' | |
cd ~/chainpoint-node && make build-config | |
echo '#################################################' | |
echo 'Creating swap file as needed' | |
echo '#################################################' | |
if free | awk '/^Swap:/ {exit !$2}'; then | |
echo "An existing swap file was detected. Skipping..." | |
else | |
echo "No swap file detected. Installing..." | |
sudo fallocate -l 2G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | |
sudo sysctl vm.swappiness=10 | |
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf | |
sudo sysctl vm.vfs_cache_pressure=50 | |
echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf | |
fi | |
echo '#################################################' | |
echo 'Docker and docker-compose installation completed!' | |
echo 'Please now exit and restart this SSH session' | |
echo 'before continuing with the README instructions.' | |
echo '#################################################' | |
sudo touch /.chainpoint-installer-run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment