Created
October 30, 2017 12:21
-
-
Save boxhock/6ce13024273a0c4bf9ee7ce9c64475ae to your computer and use it in GitHub Desktop.
A startup script for VPS providers such as Vultr to automatically set up geth and chainlink
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
#!/bin/bash | |
# If you are using Vultr as a VPS service and you run this in as your startup script, then you should see the results in /tmp/firstboot.log | |
# The script will take some time to run. You can view progress when you first log in by typing in the command: | |
# tail -f /tmp/firstboot.log | |
echo "Starting installation of Geth + ChainLink node" | |
# Install dependencies | |
apt update -y && apt upgrade -y | |
apt -y install git build-essential net-tools apt-transport-https ca-certificates curl wget gnupg2 software-properties-common ntp postgresql | |
# Start ntp service | |
/etc/init.d/ntp start | |
echo "Install Docker" | |
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | apt-key add - | |
add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" | |
apt -y update | |
apt -y install docker-ce | |
echo "Install Go(lang) 1.9.1" | |
curl -O https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz | |
tar -xvf go1.9.1.linux-amd64.tar.gz | |
mv go /usr/local | |
# Set the Go paths | |
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile | |
source ~/.profile | |
echo "Install Go-Ethereum (Geth)" | |
git clone https://github.com/ethereum/go-ethereum.git && cd go-ethereum | |
make geth | |
# Start Geth in the background with & | |
./build/bin/geth --rpc --rpcaddr 172.17.0.1 --syncmode "light" & | |
echo "Configure PostgreSQL" | |
echo "This may require a manual restart with '/etc/init.d/postgresql restart'" | |
cd /etc/postgresql/*/main/ | |
echo "listen_addresses = '172.17.0.1'" >> postgresql.conf | |
echo "host all all 172.17.0.0/16 trust" >> pg_hba.conf | |
/etc/init.d/postgresql restart | |
echo "Set up ChainLink" | |
cd /root/ | |
docker pull smartcontract/chainlink | |
# Save .env file | |
echo "DATABASE_URL=postgresql://[email protected]:5432/nayru_development?encoding=utf8&pool=5&timeout=5000" > .env | |
echo "ETHEREUM_URL=http://172.17.0.1:8545" >> .env | |
echo "ETHEREUM_EXPLORER_URL=https://etherscan.io" >> .env | |
echo "" | |
echo "" | |
echo "ChainLink node has been made ready" | |
echo "===================================" | |
echo "Remember to restart PostgreSQL manually if it hasn't been done '/etc/init.d/postgresql restart'" | |
echo "Make sure you initialize the database with 'docker run -it --env-file=.env smartcontract/chainlink rake oracle:initialize'" | |
echo "Then start ChainLink by running 'docker run -t --env-file=.env smartcontract/smartoracle'" | |
echo "===================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment