From c7e027d39313c732d71633049c06493b346d2f02 Mon Sep 17 00:00:00 2001 From: cubedro Date: Fri, 3 Apr 2015 18:14:39 +0300 Subject: [PATCH] eth.sh, build.sh and processes.json refactoring --- bin/build-go.sh | 25 ++++++++++++++++--------- bin/build.sh | 28 ++++++++++++++++------------ bin/eth.sh | 2 +- processes.json | 30 +++++++++++++++--------------- 4 files changed, 48 insertions(+), 37 deletions(-) diff --git a/bin/build-go.sh b/bin/build-go.sh index e0ed8c9..5ca3a6d 100644 --- a/bin/build-go.sh +++ b/bin/build-go.sh @@ -1,33 +1,40 @@ #!/bin/sh -# update repository & install dependencies +cd ~ + +[ ! -d "bin" ] && mkdir bin +[ ! -d "logs" ] && mkdir logs + +# update packages sudo apt-get update -y sudo apt-get upgrade -y -sudo apt-get install -y git mercurial build-essential software-properties-common wget pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev nodejs npm ntp # add ethereum repos sudo add-apt-repository -y ppa:ethereum/ethereum sudo add-apt-repository -y ppa:ethereum/ethereum-dev sudo apt-get update -y -# install ethereum -sudo apt-get install -y geth +# install ethereum & install dependencies +sudo apt-get install -y software-properties-common build-essential git unzip wget nodejs npm ntp cloud-utils geth -# add node symlink -sudo ln -s /usr/bin/nodejs /usr/bin/node +# remove previous eth symlink +[[ ! -f ~/bin/geth ]] && rm ~/bin/geth +# add eth symlink +ln -s /usr/bin/geth ~/bin/geth -# install cloud-utils to fetch instance meta-data -sudo apt-get -y install cloud-utils +# add node symlink if it doesn't exist +[[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node # add node service cd ~/bin [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api www cd www +git pull npm install npm install pm2 -g -cp -b ./processes-go.json ./../processes.json +[[ ! -f ~/bin/processes.json ]] && cp -b ./processes.json ./.. # set up time update cronjob cat > /etc/cron.hourly/ntpdate << EOF diff --git a/bin/build.sh b/bin/build.sh index 6534e7e..60e1cd4 100644 --- a/bin/build.sh +++ b/bin/build.sh @@ -2,35 +2,39 @@ cd ~ -mkdir bin -mkdir logs +[ ! -d "bin" ] && mkdir bin +[ ! -d "logs" ] && mkdir logs -# let's install packages -sudo apt-get -y update -sudo apt-get -y upgrade +# update packages +sudo apt-get update -y +sudo apt-get upgrade -y -# Setup Ethereum repos +# add ethereum repos sudo add-apt-repository -y ppa:ethereum/ethereum sudo add-apt-repository -y ppa:ethereum/ethereum-dev -sudo apt-get -y update +sudo apt-get update -y -sudo apt-get -y install software-properties-common build-essential git unzip wget nodejs npm ntp cloud-utils eth +# install ethereum & install dependencies +sudo apt-get install -y software-properties-common build-essential git unzip wget nodejs npm ntp cloud-utils eth +# remove previous eth symlink +[[ ! -f ~/bin/eth ]] && rm ~/bin/eth # add eth symlink -ln -s /usr/bin/eth ~/bin/eth +ln -s /usr/bin/eth ~/bin/eth -# add node symlink -sudo ln -s /usr/bin/nodejs /usr/bin/node +# add node symlink if it doesn't exist +[[ ! -f /usr/bin/node ]] && sudo ln -s /usr/bin/nodejs /usr/bin/node # add node service cd ~/bin [ ! -d "www" ] && git clone https://github.com/cubedro/eth-net-intelligence-api www cd www +git pull npm install npm install pm2 -g -cp -b ./processes.json ./.. +[[ ! -f ~/bin/processes.json ]] && cp -b ./processes.json ./.. # set up time update cronjob cat > /etc/cron.hourly/ntpdate << EOF diff --git a/bin/eth.sh b/bin/eth.sh index 27ae007..971a90c 100644 --- a/bin/eth.sh +++ b/bin/eth.sh @@ -2,7 +2,7 @@ trap "exit" INT if [[ -f /usr/bin/geth ]]; then - geth -rpc -maxpeers "50" -loglevel "1" + geth -rpc -rpcport "8080" -maxpeers "50" -loglevel "1" else eth -b -x 50 -r 52.16.188.185 -p 30303 -m off -n off -v 0 -j fi \ No newline at end of file diff --git a/processes.json b/processes.json index 29a9dad..ab1481e 100644 --- a/processes.json +++ b/processes.json @@ -1,27 +1,27 @@ [ { "name" : "eth", - "cwd" : "/home/ubuntu/bin/www/", - "script" : "bin/eth.sh", - "log_date_format" : "YYYY-MM-DD HH:mm Z", - "log_file" : "/home/ubuntu/logs/eth-log.log", - "out_file" : "/home/ubuntu/logs/eth-out.log", - "error_file" : "/home/ubuntu/logs/eth-err.log", - "merge_logs" : false, + "cwd" : "~/bin/www/", + "script" : "bin/eth.sh", + "log_date_format" : "YYYY-MM-DD HH:mm Z", + "log_file" : "~/logs/eth-log.log", + "out_file" : "~/logs/eth-out.log", + "error_file" : "~/logs/eth-err.log", + "merge_logs" : false, "watch" : false, - "exec_interpreter" : "bash", + "exec_interpreter" : "bash", "exec_mode" : "fork_mode" }, { "name" : "node-app", - "cwd" : "/home/ubuntu/bin/www/", - "script" : "app.js", - "log_file" : "/home/ubuntu/logs/node-app-log.log", - "out_file" : "/home/ubuntu/logs/node-app-out.log", - "error_file" : "/home/ubuntu/logs/node-app-err.log", - "merge_logs" : false, + "cwd" : "~/bin/www/", + "script" : "app.js", + "log_file" : "~/logs/node-app-log.log", + "out_file" : "~/logs/node-app-out.log", + "error_file" : "~/logs/node-app-err.log", + "merge_logs" : false, "watch" : false, - "exec_interpreter" : "node", + "exec_interpreter" : "node", "exec_mode" : "fork_mode", "env": {